1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_search-popup-jank.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,118 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests that sources aren't selected by default when finding a match. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_editor-mode.html"; 1.12 + 1.13 +let gTab, gDebuggee, gPanel, gDebugger; 1.14 +let gSearchBox; 1.15 + 1.16 +function test() { 1.17 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.18 + gTab = aTab; 1.19 + gDebuggee = aDebuggee; 1.20 + gPanel = aPanel; 1.21 + gDebugger = gPanel.panelWin; 1.22 + gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; 1.23 + 1.24 + gDebugger.DebuggerView.FilteredSources._autoSelectFirstItem = false; 1.25 + gDebugger.DebuggerView.FilteredFunctions._autoSelectFirstItem = false; 1.26 + 1.27 + waitForSourceShown(gPanel, "-01.js") 1.28 + .then(superGenericFileSearch) 1.29 + .then(() => ensureSourceIs(aPanel, "-01.js")) 1.30 + .then(() => ensureCaretAt(aPanel, 1)) 1.31 + 1.32 + .then(superAccurateFileSearch) 1.33 + .then(() => ensureSourceIs(aPanel, "-01.js")) 1.34 + .then(() => ensureCaretAt(aPanel, 1)) 1.35 + .then(() => pressKeyToHide("RETURN")) 1.36 + .then(() => ensureSourceIs(aPanel, "code_test-editor-mode", true)) 1.37 + .then(() => ensureCaretAt(aPanel, 1)) 1.38 + 1.39 + .then(superGenericFileSearch) 1.40 + .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) 1.41 + .then(() => ensureCaretAt(aPanel, 1)) 1.42 + .then(() => pressKey("UP")) 1.43 + .then(() => ensureSourceIs(aPanel, "doc_editor-mode", true)) 1.44 + .then(() => ensureCaretAt(aPanel, 1)) 1.45 + .then(() => pressKeyToHide("RETURN")) 1.46 + .then(() => ensureSourceIs(aPanel, "doc_editor-mode")) 1.47 + .then(() => ensureCaretAt(aPanel, 1)) 1.48 + 1.49 + .then(superAccurateFileSearch) 1.50 + .then(() => ensureSourceIs(aPanel, "doc_editor-mode")) 1.51 + .then(() => ensureCaretAt(aPanel, 1)) 1.52 + .then(() => typeText(gSearchBox, ":")) 1.53 + .then(() => ensureSourceIs(aPanel, "code_test-editor-mode", true)) 1.54 + .then(() => ensureCaretAt(aPanel, 1)) 1.55 + .then(() => typeText(gSearchBox, "5")) 1.56 + .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) 1.57 + .then(() => ensureCaretAt(aPanel, 5)) 1.58 + .then(() => pressKey("DOWN")) 1.59 + .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) 1.60 + .then(() => ensureCaretAt(aPanel, 6)) 1.61 + 1.62 + .then(superGenericFunctionSearch) 1.63 + .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) 1.64 + .then(() => ensureCaretAt(aPanel, 6)) 1.65 + .then(() => pressKey("RETURN")) 1.66 + .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) 1.67 + .then(() => ensureCaretAt(aPanel, 4, 10)) 1.68 + 1.69 + .then(() => closeDebuggerAndFinish(gPanel)) 1.70 + .then(null, aError => { 1.71 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.72 + }); 1.73 + }); 1.74 +} 1.75 + 1.76 +function waitForMatchFoundAndResultsShown(aName) { 1.77 + return promise.all([ 1.78 + once(gDebugger, "popupshown"), 1.79 + waitForDebuggerEvents(gPanel, gDebugger.EVENTS[aName]) 1.80 + ]); 1.81 +} 1.82 + 1.83 +function waitForResultsHidden() { 1.84 + return once(gDebugger, "popuphidden"); 1.85 +} 1.86 + 1.87 +function superGenericFunctionSearch() { 1.88 + let finished = waitForMatchFoundAndResultsShown("FUNCTION_SEARCH_MATCH_FOUND"); 1.89 + setText(gSearchBox, "@"); 1.90 + return finished; 1.91 +} 1.92 + 1.93 +function superGenericFileSearch() { 1.94 + let finished = waitForMatchFoundAndResultsShown("FILE_SEARCH_MATCH_FOUND"); 1.95 + setText(gSearchBox, "."); 1.96 + return finished; 1.97 +} 1.98 + 1.99 +function superAccurateFileSearch() { 1.100 + let finished = waitForMatchFoundAndResultsShown("FILE_SEARCH_MATCH_FOUND"); 1.101 + setText(gSearchBox, "editor"); 1.102 + return finished; 1.103 +} 1.104 + 1.105 +function pressKey(aKey) { 1.106 + EventUtils.sendKey(aKey, gDebugger); 1.107 +} 1.108 + 1.109 +function pressKeyToHide(aKey) { 1.110 + let finished = waitForResultsHidden(); 1.111 + EventUtils.sendKey(aKey, gDebugger); 1.112 + return finished; 1.113 +} 1.114 + 1.115 +registerCleanupFunction(function() { 1.116 + gTab = null; 1.117 + gDebuggee = null; 1.118 + gPanel = null; 1.119 + gDebugger = null; 1.120 + gSearchBox = null; 1.121 +});