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.

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

mercurial