diff --git a/browser/devtools/debugger/debugger-toolbar.js b/browser/devtools/debugger/debugger-toolbar.js index 8747f61fd14a..9759751f4bb3 100644 --- a/browser/devtools/debugger/debugger-toolbar.js +++ b/browser/devtools/debugger/debugger-toolbar.js @@ -945,7 +945,11 @@ FilterView.prototype = { * The click listener for the search container. */ _onClick: function() { - this._searchboxHelpPanel.openPopup(this._searchbox); + // If there's some text in the searchbox, displaying a panel would + // interfere with double/triple click default behaviors. + if (!this._searchbox.value) { + this._searchboxHelpPanel.openPopup(this._searchbox); + } }, /** diff --git a/browser/devtools/debugger/test/Makefile.in b/browser/devtools/debugger/test/Makefile.in index d9f58e4162b7..ca9601b875fc 100644 --- a/browser/devtools/debugger/test/Makefile.in +++ b/browser/devtools/debugger/test/Makefile.in @@ -70,7 +70,8 @@ MOCHITEST_BROWSER_TESTS = \ browser_dbg_search-sources-02.js \ browser_dbg_search-sources-03.js \ browser_dbg_search-symbols.js \ - browser_dbg_searchbox-help-popup.js \ + browser_dbg_searchbox-help-popup-01.js \ + browser_dbg_searchbox-help-popup-02.js \ browser_dbg_searchbox-parse.js \ browser_dbg_source-maps-01.js \ browser_dbg_source-maps-02.js \ diff --git a/browser/devtools/debugger/test/browser_dbg_searchbox-help-popup.js b/browser/devtools/debugger/test/browser_dbg_searchbox-help-popup-01.js similarity index 96% rename from browser/devtools/debugger/test/browser_dbg_searchbox-help-popup.js rename to browser/devtools/debugger/test/browser_dbg_searchbox-help-popup-01.js index 0dd4d569155e..3dbef7cbb397 100644 --- a/browser/devtools/debugger/test/browser_dbg_searchbox-help-popup.js +++ b/browser/devtools/debugger/test/browser_dbg_searchbox-help-popup-01.js @@ -22,8 +22,8 @@ function test() { gSearchBoxPanel = gDebugger.DebuggerView.Filtering._searchboxHelpPanel; waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6) - .then(() => showPopup()) - .then(() => hidePopup()) + .then(showPopup) + .then(hidePopup) .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) .then(null, aError => { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); diff --git a/browser/devtools/debugger/test/browser_dbg_searchbox-help-popup-02.js b/browser/devtools/debugger/test/browser_dbg_searchbox-help-popup-02.js new file mode 100644 index 000000000000..10a49264dba9 --- /dev/null +++ b/browser/devtools/debugger/test/browser_dbg_searchbox-help-popup-02.js @@ -0,0 +1,86 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Make sure that the searchbox popup isn't displayed when there's some text + * already present. + */ + +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; + +let gTab, gDebuggee, gPanel, gDebugger; +let gEditor, gSearchBox, gSearchBoxPanel; + +function test() { + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { + gTab = aTab; + gDebuggee = aDebuggee; + gPanel = aPanel; + gDebugger = gPanel.panelWin; + gEditor = gDebugger.DebuggerView.editor; + gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; + gSearchBoxPanel = gDebugger.DebuggerView.Filtering._searchboxHelpPanel; + + once(gSearchBoxPanel, "popupshown").then(() => { + ok(false, "Damn it, this shouldn't have happened."); + }); + + waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6) + .then(tryShowPopup) + .then(focusEditor) + .then(testFocusLost) + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) + .then(null, aError => { + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); + }); + + gDebuggee.firstCall(); + }); +} + +function tryShowPopup() { + setText(gSearchBox, "#call()"); + ok(isCaretPos(gPanel, 4, 22), + "The editor caret position appears to be correct."); + ok(isEditorSel(gPanel, [125, 131]), + "The editor selection appears to be correct."); + is(gEditor.getSelectedText(), "Call()", + "The editor selected text appears to be correct."); + + is(gSearchBoxPanel.state, "closed", + "The search box panel shouldn't be visible yet."); + + EventUtils.sendMouseEvent({ type: "click" }, gSearchBox, gDebugger); +} + +function focusEditor() { + let deferred = promise.defer(); + + // Focusing the editor takes a tick to update the caret and selection. + gEditor.focus(); + executeSoon(deferred.resolve); + + return deferred.promise; +} + +function testFocusLost() { + ok(isCaretPos(gPanel, 6, 1), + "The editor caret position appears to be correct after gaining focus."); + ok(isEditorSel(gPanel, [165, 165]), + "The editor selection appears to be correct after gaining focus."); + is(gEditor.getSelectedText(), "", + "The editor selected text appears to be correct after gaining focus."); + + is(gSearchBoxPanel.state, "closed", + "The search box panel should still not be visible."); +} + +registerCleanupFunction(function() { + gTab = null; + gDebuggee = null; + gPanel = null; + gDebugger = null; + gEditor = null; + gSearchBox = null; + gSearchBoxPanel = null; +});