michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Make sure that the searchbox popup isn't displayed when there's some text michael@0: * already present. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gEditor, gSearchBox, gSearchBoxPanel; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gEditor = gDebugger.DebuggerView.editor; michael@0: gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; michael@0: gSearchBoxPanel = gDebugger.DebuggerView.Filtering._searchboxHelpPanel; michael@0: michael@0: once(gSearchBoxPanel, "popupshown").then(() => { michael@0: ok(false, "Damn it, this shouldn't have happened."); michael@0: }); michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1) michael@0: .then(tryShowPopup) michael@0: .then(focusEditor) michael@0: .then(testFocusLost) michael@0: .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: michael@0: gDebuggee.firstCall(); michael@0: }); michael@0: } michael@0: michael@0: function tryShowPopup() { michael@0: setText(gSearchBox, "#call()"); michael@0: ok(isCaretPos(gPanel, 4, 22), michael@0: "The editor caret position appears to be correct."); michael@0: ok(isEditorSel(gPanel, [125, 131]), michael@0: "The editor selection appears to be correct."); michael@0: is(gEditor.getSelection(), "Call()", michael@0: "The editor selected text appears to be correct."); michael@0: michael@0: is(gSearchBoxPanel.state, "closed", michael@0: "The search box panel shouldn't be visible yet."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "click" }, gSearchBox, gDebugger); michael@0: } michael@0: michael@0: function focusEditor() { michael@0: let deferred = promise.defer(); michael@0: michael@0: // Focusing the editor takes a tick to update the caret and selection. michael@0: gEditor.focus(); michael@0: executeSoon(deferred.resolve); michael@0: michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function testFocusLost() { michael@0: ok(isCaretPos(gPanel, 1, 1), michael@0: "The editor caret position appears to be correct after gaining focus."); michael@0: ok(isEditorSel(gPanel, [1, 1]), michael@0: "The editor selection appears to be correct after gaining focus."); michael@0: is(gEditor.getSelection(), "", michael@0: "The editor selected text appears to be correct after gaining focus."); michael@0: michael@0: is(gSearchBoxPanel.state, "closed", michael@0: "The search box panel should still not be visible."); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gEditor = null; michael@0: gSearchBox = null; michael@0: gSearchBoxPanel = null; michael@0: });