browser/devtools/debugger/test/browser_dbg_search-global-04.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 if the global search results trigger MatchFound and NoMatchFound events
michael@0 6 * properly, and triggers the expected UI behavior.
michael@0 7 */
michael@0 8
michael@0 9 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
michael@0 10
michael@0 11 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 12 let gEditor, gSources, gSearchView, gSearchBox;
michael@0 13
michael@0 14 function test() {
michael@0 15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 16 gTab = aTab;
michael@0 17 gDebuggee = aDebuggee;
michael@0 18 gPanel = aPanel;
michael@0 19 gDebugger = gPanel.panelWin;
michael@0 20 gEditor = gDebugger.DebuggerView.editor;
michael@0 21 gSources = gDebugger.DebuggerView.Sources;
michael@0 22 gSearchView = gDebugger.DebuggerView.GlobalSearch;
michael@0 23 gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
michael@0 24
michael@0 25 waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1)
michael@0 26 .then(firstSearch)
michael@0 27 .then(secondSearch)
michael@0 28 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
michael@0 29 .then(null, aError => {
michael@0 30 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 31 });
michael@0 32
michael@0 33 gDebuggee.firstCall();
michael@0 34 });
michael@0 35 }
michael@0 36
michael@0 37 function firstSearch() {
michael@0 38 let deferred = promise.defer();
michael@0 39
michael@0 40 gDebugger.once(gDebugger.EVENTS.GLOBAL_SEARCH_MATCH_FOUND, () => {
michael@0 41 // Some operations are synchronously dispatched on the main thread,
michael@0 42 // to avoid blocking UI, thus giving the impression of faster searching.
michael@0 43 executeSoon(() => {
michael@0 44 info("Current source url:\n" + gSources.selectedValue);
michael@0 45 info("Debugger editor text:\n" + gEditor.getText());
michael@0 46
michael@0 47 ok(isCaretPos(gPanel, 1),
michael@0 48 "The editor shouldn't have jumped to a matching line yet.");
michael@0 49 ok(gSources.selectedValue.contains("-02.js"),
michael@0 50 "The current source shouldn't have changed after a global search.");
michael@0 51 is(gSources.visibleItems.length, 2,
michael@0 52 "Not all the sources are shown after the global search.");
michael@0 53
michael@0 54 deferred.resolve();
michael@0 55 });
michael@0 56 });
michael@0 57
michael@0 58 setText(gSearchBox, "!eval");
michael@0 59
michael@0 60 return deferred.promise;
michael@0 61 }
michael@0 62
michael@0 63 function secondSearch() {
michael@0 64 let deferred = promise.defer();
michael@0 65
michael@0 66 gDebugger.once(gDebugger.EVENTS.GLOBAL_SEARCH_MATCH_NOT_FOUND, () => {
michael@0 67 info("Current source url:\n" + gSources.selectedValue);
michael@0 68 info("Debugger editor text:\n" + gEditor.getText());
michael@0 69
michael@0 70 ok(isCaretPos(gPanel, 1),
michael@0 71 "The editor shouldn't have jumped to a matching line yet.");
michael@0 72 ok(gSources.selectedValue.contains("-02.js"),
michael@0 73 "The current source shouldn't have changed after a global search.");
michael@0 74 is(gSources.visibleItems.length, 2,
michael@0 75 "Not all the sources are shown after the global search.");
michael@0 76
michael@0 77 deferred.resolve();
michael@0 78 });
michael@0 79
michael@0 80 typeText(gSearchBox, "/");
michael@0 81
michael@0 82 return deferred.promise;
michael@0 83 }
michael@0 84
michael@0 85 registerCleanupFunction(function() {
michael@0 86 gTab = null;
michael@0 87 gDebuggee = null;
michael@0 88 gPanel = null;
michael@0 89 gDebugger = null;
michael@0 90 gEditor = null;
michael@0 91 gSources = null;
michael@0 92 gSearchView = null;
michael@0 93 gSearchBox = null;
michael@0 94 });

mercurial