browser/devtools/debugger/test/browser_dbg_searchbox-help-popup-02.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial