1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_searchbox-help-popup-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Make sure that the searchbox popup isn't displayed when there's some text 1.9 + * already present. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; 1.13 + 1.14 +let gTab, gDebuggee, gPanel, gDebugger; 1.15 +let gEditor, gSearchBox, gSearchBoxPanel; 1.16 + 1.17 +function test() { 1.18 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.19 + gTab = aTab; 1.20 + gDebuggee = aDebuggee; 1.21 + gPanel = aPanel; 1.22 + gDebugger = gPanel.panelWin; 1.23 + gEditor = gDebugger.DebuggerView.editor; 1.24 + gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; 1.25 + gSearchBoxPanel = gDebugger.DebuggerView.Filtering._searchboxHelpPanel; 1.26 + 1.27 + once(gSearchBoxPanel, "popupshown").then(() => { 1.28 + ok(false, "Damn it, this shouldn't have happened."); 1.29 + }); 1.30 + 1.31 + waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1) 1.32 + .then(tryShowPopup) 1.33 + .then(focusEditor) 1.34 + .then(testFocusLost) 1.35 + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) 1.36 + .then(null, aError => { 1.37 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.38 + }); 1.39 + 1.40 + gDebuggee.firstCall(); 1.41 + }); 1.42 +} 1.43 + 1.44 +function tryShowPopup() { 1.45 + setText(gSearchBox, "#call()"); 1.46 + ok(isCaretPos(gPanel, 4, 22), 1.47 + "The editor caret position appears to be correct."); 1.48 + ok(isEditorSel(gPanel, [125, 131]), 1.49 + "The editor selection appears to be correct."); 1.50 + is(gEditor.getSelection(), "Call()", 1.51 + "The editor selected text appears to be correct."); 1.52 + 1.53 + is(gSearchBoxPanel.state, "closed", 1.54 + "The search box panel shouldn't be visible yet."); 1.55 + 1.56 + EventUtils.sendMouseEvent({ type: "click" }, gSearchBox, gDebugger); 1.57 +} 1.58 + 1.59 +function focusEditor() { 1.60 + let deferred = promise.defer(); 1.61 + 1.62 + // Focusing the editor takes a tick to update the caret and selection. 1.63 + gEditor.focus(); 1.64 + executeSoon(deferred.resolve); 1.65 + 1.66 + return deferred.promise; 1.67 +} 1.68 + 1.69 +function testFocusLost() { 1.70 + ok(isCaretPos(gPanel, 1, 1), 1.71 + "The editor caret position appears to be correct after gaining focus."); 1.72 + ok(isEditorSel(gPanel, [1, 1]), 1.73 + "The editor selection appears to be correct after gaining focus."); 1.74 + is(gEditor.getSelection(), "", 1.75 + "The editor selected text appears to be correct after gaining focus."); 1.76 + 1.77 + is(gSearchBoxPanel.state, "closed", 1.78 + "The search box panel should still not be visible."); 1.79 +} 1.80 + 1.81 +registerCleanupFunction(function() { 1.82 + gTab = null; 1.83 + gDebuggee = null; 1.84 + gPanel = null; 1.85 + gDebugger = null; 1.86 + gEditor = null; 1.87 + gSearchBox = null; 1.88 + gSearchBoxPanel = null; 1.89 +});