browser/devtools/debugger/test/browser_dbg_search-sources-01.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 basic functionality of sources filtering (file search).
michael@0 6 */
michael@0 7
michael@0 8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
michael@0 9
michael@0 10 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 11 let gSources, gSearchView, gSearchBox;
michael@0 12
michael@0 13 function test() {
michael@0 14 // Debug test slaves are a bit slow at this test.
michael@0 15 requestLongerTimeout(3);
michael@0 16
michael@0 17 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 18 gTab = aTab;
michael@0 19 gDebuggee = aDebuggee;
michael@0 20 gPanel = aPanel;
michael@0 21 gDebugger = gPanel.panelWin;
michael@0 22 gSources = gDebugger.DebuggerView.Sources;
michael@0 23 gSearchView = gDebugger.DebuggerView.FilteredSources;
michael@0 24 gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
michael@0 25
michael@0 26 waitForSourceShown(gPanel, "-01.js")
michael@0 27 .then(bogusSearch)
michael@0 28 .then(firstSearch)
michael@0 29 .then(secondSearch)
michael@0 30 .then(thirdSearch)
michael@0 31 .then(fourthSearch)
michael@0 32 .then(fifthSearch)
michael@0 33 .then(sixthSearch)
michael@0 34 .then(seventhSearch)
michael@0 35 .then(() => closeDebuggerAndFinish(gPanel))
michael@0 36 .then(null, aError => {
michael@0 37 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 38 });
michael@0 39 });
michael@0 40 }
michael@0 41
michael@0 42 function bogusSearch() {
michael@0 43 let finished = promise.all([
michael@0 44 ensureSourceIs(gPanel, "-01.js"),
michael@0 45 ensureCaretAt(gPanel, 1),
michael@0 46 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_NOT_FOUND)
michael@0 47 ]);
michael@0 48
michael@0 49 setText(gSearchBox, "BOGUS");
michael@0 50
michael@0 51 return finished.then(() => promise.all([
michael@0 52 ensureSourceIs(gPanel, "-01.js"),
michael@0 53 ensureCaretAt(gPanel, 1),
michael@0 54 verifyContents({ itemCount: 0, hidden: true })
michael@0 55 ]));
michael@0 56 }
michael@0 57
michael@0 58 function firstSearch() {
michael@0 59 let finished = promise.all([
michael@0 60 ensureSourceIs(gPanel, "-01.js"),
michael@0 61 ensureCaretAt(gPanel, 1),
michael@0 62 once(gDebugger, "popupshown"),
michael@0 63 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 64 waitForSourceShown(gPanel, "-02.js")
michael@0 65 ]);
michael@0 66
michael@0 67 setText(gSearchBox, "-02.js");
michael@0 68
michael@0 69 return finished.then(() => promise.all([
michael@0 70 ensureSourceIs(gPanel, "-02.js"),
michael@0 71 ensureCaretAt(gPanel, 1),
michael@0 72 verifyContents({ itemCount: 1, hidden: false })
michael@0 73 ]));
michael@0 74 }
michael@0 75
michael@0 76 function secondSearch() {
michael@0 77 let finished = promise.all([
michael@0 78 once(gDebugger, "popupshown"),
michael@0 79 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 80 waitForSourceShown(gPanel, "-01.js")
michael@0 81 ])
michael@0 82 .then(() => {
michael@0 83 let finished = promise.all([
michael@0 84 once(gDebugger, "popupshown"),
michael@0 85 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 86 waitForCaretUpdated(gPanel, 5)
michael@0 87 ])
michael@0 88 .then(() => promise.all([
michael@0 89 ensureSourceIs(gPanel, "-01.js"),
michael@0 90 ensureCaretAt(gPanel, 5),
michael@0 91 verifyContents({ itemCount: 1, hidden: false })
michael@0 92 ]));
michael@0 93
michael@0 94 typeText(gSearchBox, ":5");
michael@0 95 return finished;
michael@0 96 });
michael@0 97
michael@0 98 setText(gSearchBox, ".*-01\.js");
michael@0 99 return finished;
michael@0 100 }
michael@0 101
michael@0 102 function thirdSearch() {
michael@0 103 let finished = promise.all([
michael@0 104 once(gDebugger, "popupshown"),
michael@0 105 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 106 waitForSourceShown(gPanel, "-02.js")
michael@0 107 ])
michael@0 108 .then(() => {
michael@0 109 let finished = promise.all([
michael@0 110 once(gDebugger, "popupshown"),
michael@0 111 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 112 waitForCaretUpdated(gPanel, 6, 12)
michael@0 113 ])
michael@0 114 .then(() => promise.all([
michael@0 115 ensureSourceIs(gPanel, "-02.js"),
michael@0 116 ensureCaretAt(gPanel, 6, 12),
michael@0 117 verifyContents({ itemCount: 1, hidden: false })
michael@0 118 ]));
michael@0 119
michael@0 120 typeText(gSearchBox, "#deb");
michael@0 121 return finished;
michael@0 122 });
michael@0 123
michael@0 124 setText(gSearchBox, ".*-02\.js");
michael@0 125 return finished;
michael@0 126 }
michael@0 127
michael@0 128 function fourthSearch() {
michael@0 129 let finished = promise.all([
michael@0 130 once(gDebugger, "popupshown"),
michael@0 131 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 132 waitForSourceShown(gPanel, "-01.js")
michael@0 133 ])
michael@0 134 .then(() => {
michael@0 135 let finished = promise.all([
michael@0 136 once(gDebugger, "popupshown"),
michael@0 137 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 138 waitForCaretUpdated(gPanel, 2, 9),
michael@0 139 ])
michael@0 140 .then(() => promise.all([
michael@0 141 ensureSourceIs(gPanel, "-01.js"),
michael@0 142 ensureCaretAt(gPanel, 2, 9),
michael@0 143 verifyContents({ itemCount: 1, hidden: false })
michael@0 144 // ...because we simply searched for ":" in the current file.
michael@0 145 ]));
michael@0 146
michael@0 147 typeText(gSearchBox, "#:"); // # has precedence.
michael@0 148 return finished;
michael@0 149 });
michael@0 150
michael@0 151 setText(gSearchBox, ".*-01\.js");
michael@0 152 return finished;
michael@0 153 }
michael@0 154
michael@0 155 function fifthSearch() {
michael@0 156 let finished = promise.all([
michael@0 157 once(gDebugger, "popupshown"),
michael@0 158 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 159 waitForSourceShown(gPanel, "-02.js")
michael@0 160 ])
michael@0 161 .then(() => {
michael@0 162 let finished = promise.all([
michael@0 163 once(gDebugger, "popuphidden"),
michael@0 164 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_NOT_FOUND),
michael@0 165 waitForCaretUpdated(gPanel, 1, 3)
michael@0 166 ])
michael@0 167 .then(() => promise.all([
michael@0 168 ensureSourceIs(gPanel, "-02.js"),
michael@0 169 ensureCaretAt(gPanel, 1, 3),
michael@0 170 verifyContents({ itemCount: 0, hidden: true })
michael@0 171 // ...because the searched label includes ":5", so nothing is found.
michael@0 172 ]));
michael@0 173
michael@0 174 typeText(gSearchBox, ":5#*"); // # has precedence.
michael@0 175 return finished;
michael@0 176 });
michael@0 177
michael@0 178 setText(gSearchBox, ".*-02\.js");
michael@0 179 return finished;
michael@0 180 }
michael@0 181
michael@0 182 function sixthSearch() {
michael@0 183 let finished = promise.all([
michael@0 184 ensureSourceIs(gPanel, "-02.js"),
michael@0 185 ensureCaretAt(gPanel, 1, 3),
michael@0 186 once(gDebugger, "popupshown"),
michael@0 187 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 188 waitForCaretUpdated(gPanel, 5)
michael@0 189 ]);
michael@0 190
michael@0 191 backspaceText(gSearchBox, 2);
michael@0 192
michael@0 193 return finished.then(() => promise.all([
michael@0 194 ensureSourceIs(gPanel, "-02.js"),
michael@0 195 ensureCaretAt(gPanel, 5),
michael@0 196 verifyContents({ itemCount: 1, hidden: false })
michael@0 197 ]));
michael@0 198 }
michael@0 199
michael@0 200 function seventhSearch() {
michael@0 201 let finished = promise.all([
michael@0 202 ensureSourceIs(gPanel, "-02.js"),
michael@0 203 ensureCaretAt(gPanel, 5),
michael@0 204 once(gDebugger, "popupshown"),
michael@0 205 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND),
michael@0 206 waitForSourceShown(gPanel, "-01.js"),
michael@0 207 ]);
michael@0 208
michael@0 209 backspaceText(gSearchBox, 6);
michael@0 210
michael@0 211 return finished.then(() => promise.all([
michael@0 212 ensureSourceIs(gPanel, "-01.js"),
michael@0 213 ensureCaretAt(gPanel, 1),
michael@0 214 verifyContents({ itemCount: 2, hidden: false })
michael@0 215 ]));
michael@0 216 }
michael@0 217
michael@0 218 function verifyContents(aArgs) {
michael@0 219 is(gSources.visibleItems.length, 2,
michael@0 220 "The unmatched sources in the widget should not be hidden.");
michael@0 221 is(gSearchView.itemCount, aArgs.itemCount,
michael@0 222 "No sources should be displayed in the sources container after a bogus search.");
michael@0 223 is(gSearchView.hidden, aArgs.hidden,
michael@0 224 "No sources should be displayed in the sources container after a bogus search.");
michael@0 225 }
michael@0 226
michael@0 227 registerCleanupFunction(function() {
michael@0 228 gTab = null;
michael@0 229 gDebuggee = null;
michael@0 230 gPanel = null;
michael@0 231 gDebugger = null;
michael@0 232 gSources = null;
michael@0 233 gSearchView = null;
michael@0 234 gSearchBox = null;
michael@0 235 });

mercurial