browser/devtools/debugger/test/browser_dbg_search-popup-jank.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 sources aren't selected by default when finding a match.
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 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 gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
michael@0 20
michael@0 21 gDebugger.DebuggerView.FilteredSources._autoSelectFirstItem = false;
michael@0 22 gDebugger.DebuggerView.FilteredFunctions._autoSelectFirstItem = false;
michael@0 23
michael@0 24 waitForSourceShown(gPanel, "-01.js")
michael@0 25 .then(superGenericFileSearch)
michael@0 26 .then(() => ensureSourceIs(aPanel, "-01.js"))
michael@0 27 .then(() => ensureCaretAt(aPanel, 1))
michael@0 28
michael@0 29 .then(superAccurateFileSearch)
michael@0 30 .then(() => ensureSourceIs(aPanel, "-01.js"))
michael@0 31 .then(() => ensureCaretAt(aPanel, 1))
michael@0 32 .then(() => pressKeyToHide("RETURN"))
michael@0 33 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode", true))
michael@0 34 .then(() => ensureCaretAt(aPanel, 1))
michael@0 35
michael@0 36 .then(superGenericFileSearch)
michael@0 37 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode"))
michael@0 38 .then(() => ensureCaretAt(aPanel, 1))
michael@0 39 .then(() => pressKey("UP"))
michael@0 40 .then(() => ensureSourceIs(aPanel, "doc_editor-mode", true))
michael@0 41 .then(() => ensureCaretAt(aPanel, 1))
michael@0 42 .then(() => pressKeyToHide("RETURN"))
michael@0 43 .then(() => ensureSourceIs(aPanel, "doc_editor-mode"))
michael@0 44 .then(() => ensureCaretAt(aPanel, 1))
michael@0 45
michael@0 46 .then(superAccurateFileSearch)
michael@0 47 .then(() => ensureSourceIs(aPanel, "doc_editor-mode"))
michael@0 48 .then(() => ensureCaretAt(aPanel, 1))
michael@0 49 .then(() => typeText(gSearchBox, ":"))
michael@0 50 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode", true))
michael@0 51 .then(() => ensureCaretAt(aPanel, 1))
michael@0 52 .then(() => typeText(gSearchBox, "5"))
michael@0 53 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode"))
michael@0 54 .then(() => ensureCaretAt(aPanel, 5))
michael@0 55 .then(() => pressKey("DOWN"))
michael@0 56 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode"))
michael@0 57 .then(() => ensureCaretAt(aPanel, 6))
michael@0 58
michael@0 59 .then(superGenericFunctionSearch)
michael@0 60 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode"))
michael@0 61 .then(() => ensureCaretAt(aPanel, 6))
michael@0 62 .then(() => pressKey("RETURN"))
michael@0 63 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode"))
michael@0 64 .then(() => ensureCaretAt(aPanel, 4, 10))
michael@0 65
michael@0 66 .then(() => closeDebuggerAndFinish(gPanel))
michael@0 67 .then(null, aError => {
michael@0 68 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 69 });
michael@0 70 });
michael@0 71 }
michael@0 72
michael@0 73 function waitForMatchFoundAndResultsShown(aName) {
michael@0 74 return promise.all([
michael@0 75 once(gDebugger, "popupshown"),
michael@0 76 waitForDebuggerEvents(gPanel, gDebugger.EVENTS[aName])
michael@0 77 ]);
michael@0 78 }
michael@0 79
michael@0 80 function waitForResultsHidden() {
michael@0 81 return once(gDebugger, "popuphidden");
michael@0 82 }
michael@0 83
michael@0 84 function superGenericFunctionSearch() {
michael@0 85 let finished = waitForMatchFoundAndResultsShown("FUNCTION_SEARCH_MATCH_FOUND");
michael@0 86 setText(gSearchBox, "@");
michael@0 87 return finished;
michael@0 88 }
michael@0 89
michael@0 90 function superGenericFileSearch() {
michael@0 91 let finished = waitForMatchFoundAndResultsShown("FILE_SEARCH_MATCH_FOUND");
michael@0 92 setText(gSearchBox, ".");
michael@0 93 return finished;
michael@0 94 }
michael@0 95
michael@0 96 function superAccurateFileSearch() {
michael@0 97 let finished = waitForMatchFoundAndResultsShown("FILE_SEARCH_MATCH_FOUND");
michael@0 98 setText(gSearchBox, "editor");
michael@0 99 return finished;
michael@0 100 }
michael@0 101
michael@0 102 function pressKey(aKey) {
michael@0 103 EventUtils.sendKey(aKey, gDebugger);
michael@0 104 }
michael@0 105
michael@0 106 function pressKeyToHide(aKey) {
michael@0 107 let finished = waitForResultsHidden();
michael@0 108 EventUtils.sendKey(aKey, gDebugger);
michael@0 109 return finished;
michael@0 110 }
michael@0 111
michael@0 112 registerCleanupFunction(function() {
michael@0 113 gTab = null;
michael@0 114 gDebuggee = null;
michael@0 115 gPanel = null;
michael@0 116 gDebugger = null;
michael@0 117 gSearchBox = null;
michael@0 118 });

mercurial