From e6e86f81a1415349ebdab4c10b36f28cf0be6fe2 Mon Sep 17 00:00:00 2001 From: Victor Porof Date: Tue, 11 Dec 2012 09:38:04 +0200 Subject: [PATCH] Bug 818430 - Having line and token operators in the same query makes the scripts menulist behave weirdly, r=past --- browser/devtools/debugger/debugger-toolbar.js | 13 +++- .../test/browser_dbg_scripts-searching-01.js | 60 ++++++++++++++++++- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/browser/devtools/debugger/debugger-toolbar.js b/browser/devtools/debugger/debugger-toolbar.js index 0a329fd7cb1..27ed753d2e2 100644 --- a/browser/devtools/debugger/debugger-toolbar.js +++ b/browser/devtools/debugger/debugger-toolbar.js @@ -754,6 +754,7 @@ FilterView.prototype = { if (!found) { found = true; view.selectedItem = item; + view.refresh(); } } // Item not matched, hide the corresponding node. @@ -778,9 +779,13 @@ FilterView.prototype = { */ _performLineSearch: function DVF__performLineSearch(aLine) { // Don't search for lines if the input hasn't changed. - if (this._prevSearchedLine != aLine && aLine > 0) { + if (this._prevSearchedLine != aLine && aLine) { DebuggerView.editor.setCaretPosition(aLine - 1); } + // Can't search for lines and tokens at the same time. + if (this._prevSearchedToken && !aLine) { + this._target.refresh(); + } this._prevSearchedLine = aLine; }, @@ -793,13 +798,17 @@ FilterView.prototype = { */ _performTokenSearch: function DVF__performTokenSearch(aToken) { // Don't search for tokens if the input hasn't changed. - if (this._prevSearchedToken != aToken && aToken.length > 0) { + if (this._prevSearchedToken != aToken && aToken) { let editor = DebuggerView.editor; let offset = editor.find(aToken, { ignoreCase: true }); if (offset > -1) { editor.setSelection(offset, offset + aToken.length) } } + // Can't search for tokens and lines at the same time. + if (this._prevSearchedLine && !aToken) { + this._target.refresh(); + } this._prevSearchedToken = aToken; }, diff --git a/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js b/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js index d44a5aa1881..23b2c10b5c3 100644 --- a/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js +++ b/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js @@ -50,6 +50,7 @@ function test() } function testScriptSearching() { + let noMatchingScripts = gDebugger.L10N.getStr("noMatchingScriptsText"); var token; gDebugger.DebuggerController.activeThread.resume(function() { @@ -135,37 +136,87 @@ function testScriptSearching() { ok(gEditor.getCaretPosition().line == 8 && gEditor.getCaretPosition().col == 2 + token.length, "The editor didn't jump to the correct token. (6)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); write(":13#" + token); ok(gEditor.getCaretPosition().line == 8 && gEditor.getCaretPosition().col == 2 + token.length, "The editor didn't jump to the correct token. (7)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); write(":#" + token); ok(gEditor.getCaretPosition().line == 8 && gEditor.getCaretPosition().col == 2 + token.length, "The editor didn't jump to the correct token. (8)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); write("::#" + token); ok(gEditor.getCaretPosition().line == 8 && gEditor.getCaretPosition().col == 2 + token.length, "The editor didn't jump to the correct token. (9)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); write(":::#" + token); ok(gEditor.getCaretPosition().line == 8 && gEditor.getCaretPosition().col == 2 + token.length, "The editor didn't jump to the correct token. (10)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); + + + write("#" + token + ":bogus"); + ok(gEditor.getCaretPosition().line == 8 && + gEditor.getCaretPosition().col == 2 + token.length, + "The editor didn't jump to the correct token. (6)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); + + write("#" + token + ":13"); + ok(gEditor.getCaretPosition().line == 8 && + gEditor.getCaretPosition().col == 2 + token.length, + "The editor didn't jump to the correct token. (7)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); + + write("#" + token + ":"); + ok(gEditor.getCaretPosition().line == 8 && + gEditor.getCaretPosition().col == 2 + token.length, + "The editor didn't jump to the correct token. (8)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); + + write("#" + token + "::"); + ok(gEditor.getCaretPosition().line == 8 && + gEditor.getCaretPosition().col == 2 + token.length, + "The editor didn't jump to the correct token. (9)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); + + write("#" + token + ":::"); + ok(gEditor.getCaretPosition().line == 8 && + gEditor.getCaretPosition().col == 2 + token.length, + "The editor didn't jump to the correct token. (10)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); write(":i am not a number"); ok(gEditor.getCaretPosition().line == 8 && gEditor.getCaretPosition().col == 2 + token.length, "The editor didn't remain at the correct token. (11)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); write("#__i do not exist__"); ok(gEditor.getCaretPosition().line == 8 && gEditor.getCaretPosition().col == 2 + token.length, "The editor didn't remain at the correct token. (12)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); token = "debugger"; @@ -173,17 +224,23 @@ function testScriptSearching() { ok(gEditor.getCaretPosition().line == 2 && gEditor.getCaretPosition().col == 44 + token.length, "The editor didn't jump to the correct token. (12.1)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); clear(); EventUtils.sendKey("RETURN"); ok(gEditor.getCaretPosition().line == 2 && gEditor.getCaretPosition().col == 44 + token.length, "The editor shouldn't jump to another token. (12.2)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); EventUtils.sendKey("ENTER"); ok(gEditor.getCaretPosition().line == 2 && gEditor.getCaretPosition().col == 44 + token.length, "The editor shouldn't jump to another token. (12.3)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); write(":1:2:3:a:b:c:::12"); @@ -196,7 +253,6 @@ function testScriptSearching() { gEditor.getCaretPosition().col == 44 + token.length, "The editor didn't jump to the correct token. (14)"); - EventUtils.sendKey("DOWN"); ok(gEditor.getCaretPosition().line == 8 && gEditor.getCaretPosition().col == 2 + token.length, @@ -229,6 +285,8 @@ function testScriptSearching() { "The editor didn't remain at the correct token. (19)"); is(gScripts.visibleItems, 1, "Not all the scripts are shown after the search. (20)"); + isnot(gMenulist.getAttribute("label"), noMatchingScripts, + "The menulist should not display a notice that matches are found."); closeDebuggerAndFinish(); });