browser/devtools/debugger/test/browser_dbg_search-sources-03.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 that while searching for files, the sources list remains unchanged.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_editor-mode.html";
    10 let gTab, gDebuggee, gPanel, gDebugger;
    11 let gSources, gSearchBox;
    13 function test() {
    14   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    15     gTab = aTab;
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    19     gSources = gDebugger.DebuggerView.Sources;
    20     gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
    22     waitForSourceShown(gPanel, "-01.js")
    23       .then(superGenericSearch)
    24       .then(verifySourcesPane)
    25       .then(kindaInterpretableSearch)
    26       .then(verifySourcesPane)
    27       .then(incrediblySpecificSearch)
    28       .then(verifySourcesPane)
    29       .then(returnAndHide)
    30       .then(verifySourcesPane)
    31       .then(() => closeDebuggerAndFinish(gPanel))
    32       .then(null, aError => {
    33         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    34       });
    35   });
    36 }
    38 function waitForMatchFoundAndResultsShown() {
    39   return promise.all([
    40     once(gDebugger, "popupshown"),
    41     waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND)
    42   ]).then(() => promise.all([
    43     ensureSourceIs(gPanel, "-01.js"),
    44     ensureCaretAt(gPanel, 1)
    45   ]));
    46 }
    48 function waitForResultsHidden() {
    49   return once(gDebugger, "popuphidden").then(() => promise.all([
    50     ensureSourceIs(gPanel, "-01.js"),
    51     ensureCaretAt(gPanel, 1)
    52   ]));
    53 }
    55 function superGenericSearch() {
    56   let finished = waitForMatchFoundAndResultsShown();
    57   setText(gSearchBox, ".");
    58   return finished;
    59 }
    61 function kindaInterpretableSearch() {
    62   let finished = waitForMatchFoundAndResultsShown();
    63   typeText(gSearchBox, "-0");
    64   return finished;
    65 }
    67 function incrediblySpecificSearch() {
    68   let finished = waitForMatchFoundAndResultsShown();
    69   typeText(gSearchBox, "1.js");
    70   return finished;
    71 }
    73 function returnAndHide() {
    74   let finished = waitForResultsHidden();
    75   EventUtils.sendKey("RETURN", gDebugger);
    76   return finished;
    77 }
    79 function verifySourcesPane() {
    80   is(gSources.itemCount, 3,
    81     "There should be 3 items present in the sources container.");
    82   is(gSources.visibleItems.length, 3,
    83     "There should be no hidden items in the sources container.");
    85   ok(gSources.getItemForAttachment(e => e.label == "code_script-switching-01.js"),
    86     "The first source's label should be correct.");
    87   ok(gSources.getItemForAttachment(e => e.label == "code_test-editor-mode"),
    88     "The second source's label should be correct.");
    89   ok(gSources.getItemForAttachment(e => e.label == "doc_editor-mode.html"),
    90     "The third source's label should be correct.");
    91 }
    93 registerCleanupFunction(function() {
    94   gTab = null;
    95   gDebuggee = null;
    96   gPanel = null;
    97   gDebugger = null;
    98   gSources = null;
    99   gSearchBox = null;
   100 });

mercurial