browser/devtools/debugger/test/browser_dbg_search-global-06.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  * Tests if the global search results are hidden when they're supposed to
     6  * (after a focus lost, or when ESCAPE is pressed).
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
    11 let gTab, gDebuggee, gPanel, gDebugger;
    12 let gEditor, gSources, gSearchView, gSearchBox;
    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     gSources = gDebugger.DebuggerView.Sources;
    22     gSearchView = gDebugger.DebuggerView.GlobalSearch;
    23     gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
    25     waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1)
    26       .then(doSearch)
    27       .then(testFocusLost)
    28       .then(doSearch)
    29       .then(testEscape)
    30       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    31       .then(null, aError => {
    32         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    33       });
    35     gDebuggee.firstCall();
    36   });
    37 }
    39 function doSearch() {
    40   let deferred = promise.defer();
    42   is(gSearchView.itemCount, 0,
    43     "The global search pane shouldn't have any entries yet.");
    44   is(gSearchView.widget._parent.hidden, true,
    45     "The global search pane shouldn't be visible yet.");
    46   is(gSearchView._splitter.hidden, true,
    47     "The global search pane splitter shouldn't be visible yet.");
    49   gDebugger.once(gDebugger.EVENTS.GLOBAL_SEARCH_MATCH_FOUND, () => {
    50     // Some operations are synchronously dispatched on the main thread,
    51     // to avoid blocking UI, thus giving the impression of faster searching.
    52     executeSoon(() => {
    53       info("Current source url:\n" + gSources.selectedValue);
    54       info("Debugger editor text:\n" + gEditor.getText());
    56       ok(isCaretPos(gPanel, 1),
    57         "The editor shouldn't have jumped to a matching line yet.");
    58       ok(gSources.selectedValue.contains("-02.js"),
    59         "The current source shouldn't have changed after a global search.");
    60       is(gSources.visibleItems.length, 2,
    61         "Not all the sources are shown after the global search.");
    63       deferred.resolve();
    64     });
    65   });
    67   setText(gSearchBox, "!a");
    69   return deferred.promise;
    70 }
    72 function testFocusLost() {
    73   is(gSearchView.itemCount, 2,
    74     "The global search pane should have some entries from the previous search.");
    75   is(gSearchView.widget._parent.hidden, false,
    76     "The global search pane should be visible from the previous search.");
    77   is(gSearchView._splitter.hidden, false,
    78     "The global search pane splitter should be visible from the previous search.");
    80   gDebugger.DebuggerView.editor.focus();
    82   info("Current source url:\n" + gSources.selectedValue);
    83   info("Debugger editor text:\n" + gEditor.getText());
    85   is(gSearchView.itemCount, 0,
    86     "The global search pane shouldn't have any child nodes after clearing.");
    87   is(gSearchView.widget._parent.hidden, true,
    88     "The global search pane shouldn't be visible after clearing.");
    89   is(gSearchView._splitter.hidden, true,
    90     "The global search pane splitter shouldn't be visible after clearing.");
    91 }
    93 function testEscape() {
    94   is(gSearchView.itemCount, 2,
    95     "The global search pane should have some entries from the previous search.");
    96   is(gSearchView.widget._parent.hidden, false,
    97     "The global search pane should be visible from the previous search.");
    98   is(gSearchView._splitter.hidden, false,
    99     "The global search pane splitter should be visible from the previous search.");
   101    gSearchBox.focus();
   102    EventUtils.sendKey("ESCAPE", gDebugger);
   104   is(gSearchView.itemCount, 0,
   105     "The global search pane shouldn't have any child nodes after clearing.");
   106   is(gSearchView.widget._parent.hidden, true,
   107     "The global search pane shouldn't be visible after clearing.");
   108   is(gSearchView._splitter.hidden, true,
   109     "The global search pane splitter shouldn't be visible after clearing.");
   110 }
   112 registerCleanupFunction(function() {
   113   gTab = null;
   114   gDebuggee = null;
   115   gPanel = null;
   116   gDebugger = null;
   117   gEditor = null;
   118   gSources = null;
   119   gSearchView = null;
   120   gSearchBox = null;
   121 });

mercurial