Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Make sure that the searchbox popup isn't displayed when there's some text |
michael@0 | 6 | * already present. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | let gEditor, gSearchBox, gSearchBoxPanel; |
michael@0 | 13 | |
michael@0 | 14 | function test() { |
michael@0 | 15 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 16 | gTab = aTab; |
michael@0 | 17 | gDebuggee = aDebuggee; |
michael@0 | 18 | gPanel = aPanel; |
michael@0 | 19 | gDebugger = gPanel.panelWin; |
michael@0 | 20 | gEditor = gDebugger.DebuggerView.editor; |
michael@0 | 21 | gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; |
michael@0 | 22 | gSearchBoxPanel = gDebugger.DebuggerView.Filtering._searchboxHelpPanel; |
michael@0 | 23 | |
michael@0 | 24 | once(gSearchBoxPanel, "popupshown").then(() => { |
michael@0 | 25 | ok(false, "Damn it, this shouldn't have happened."); |
michael@0 | 26 | }); |
michael@0 | 27 | |
michael@0 | 28 | waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1) |
michael@0 | 29 | .then(tryShowPopup) |
michael@0 | 30 | .then(focusEditor) |
michael@0 | 31 | .then(testFocusLost) |
michael@0 | 32 | .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
michael@0 | 33 | .then(null, aError => { |
michael@0 | 34 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 35 | }); |
michael@0 | 36 | |
michael@0 | 37 | gDebuggee.firstCall(); |
michael@0 | 38 | }); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function tryShowPopup() { |
michael@0 | 42 | setText(gSearchBox, "#call()"); |
michael@0 | 43 | ok(isCaretPos(gPanel, 4, 22), |
michael@0 | 44 | "The editor caret position appears to be correct."); |
michael@0 | 45 | ok(isEditorSel(gPanel, [125, 131]), |
michael@0 | 46 | "The editor selection appears to be correct."); |
michael@0 | 47 | is(gEditor.getSelection(), "Call()", |
michael@0 | 48 | "The editor selected text appears to be correct."); |
michael@0 | 49 | |
michael@0 | 50 | is(gSearchBoxPanel.state, "closed", |
michael@0 | 51 | "The search box panel shouldn't be visible yet."); |
michael@0 | 52 | |
michael@0 | 53 | EventUtils.sendMouseEvent({ type: "click" }, gSearchBox, gDebugger); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function focusEditor() { |
michael@0 | 57 | let deferred = promise.defer(); |
michael@0 | 58 | |
michael@0 | 59 | // Focusing the editor takes a tick to update the caret and selection. |
michael@0 | 60 | gEditor.focus(); |
michael@0 | 61 | executeSoon(deferred.resolve); |
michael@0 | 62 | |
michael@0 | 63 | return deferred.promise; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | function testFocusLost() { |
michael@0 | 67 | ok(isCaretPos(gPanel, 1, 1), |
michael@0 | 68 | "The editor caret position appears to be correct after gaining focus."); |
michael@0 | 69 | ok(isEditorSel(gPanel, [1, 1]), |
michael@0 | 70 | "The editor selection appears to be correct after gaining focus."); |
michael@0 | 71 | is(gEditor.getSelection(), "", |
michael@0 | 72 | "The editor selected text appears to be correct after gaining focus."); |
michael@0 | 73 | |
michael@0 | 74 | is(gSearchBoxPanel.state, "closed", |
michael@0 | 75 | "The search box panel should still not be visible."); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | registerCleanupFunction(function() { |
michael@0 | 79 | gTab = null; |
michael@0 | 80 | gDebuggee = null; |
michael@0 | 81 | gPanel = null; |
michael@0 | 82 | gDebugger = null; |
michael@0 | 83 | gEditor = null; |
michael@0 | 84 | gSearchBox = null; |
michael@0 | 85 | gSearchBoxPanel = null; |
michael@0 | 86 | }); |