1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_search-sources-03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,100 @@ 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 while searching for files, the sources list remains unchanged. 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 gSources, 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 + gSources = gDebugger.DebuggerView.Sources; 1.23 + gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; 1.24 + 1.25 + waitForSourceShown(gPanel, "-01.js") 1.26 + .then(superGenericSearch) 1.27 + .then(verifySourcesPane) 1.28 + .then(kindaInterpretableSearch) 1.29 + .then(verifySourcesPane) 1.30 + .then(incrediblySpecificSearch) 1.31 + .then(verifySourcesPane) 1.32 + .then(returnAndHide) 1.33 + .then(verifySourcesPane) 1.34 + .then(() => closeDebuggerAndFinish(gPanel)) 1.35 + .then(null, aError => { 1.36 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.37 + }); 1.38 + }); 1.39 +} 1.40 + 1.41 +function waitForMatchFoundAndResultsShown() { 1.42 + return promise.all([ 1.43 + once(gDebugger, "popupshown"), 1.44 + waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND) 1.45 + ]).then(() => promise.all([ 1.46 + ensureSourceIs(gPanel, "-01.js"), 1.47 + ensureCaretAt(gPanel, 1) 1.48 + ])); 1.49 +} 1.50 + 1.51 +function waitForResultsHidden() { 1.52 + return once(gDebugger, "popuphidden").then(() => promise.all([ 1.53 + ensureSourceIs(gPanel, "-01.js"), 1.54 + ensureCaretAt(gPanel, 1) 1.55 + ])); 1.56 +} 1.57 + 1.58 +function superGenericSearch() { 1.59 + let finished = waitForMatchFoundAndResultsShown(); 1.60 + setText(gSearchBox, "."); 1.61 + return finished; 1.62 +} 1.63 + 1.64 +function kindaInterpretableSearch() { 1.65 + let finished = waitForMatchFoundAndResultsShown(); 1.66 + typeText(gSearchBox, "-0"); 1.67 + return finished; 1.68 +} 1.69 + 1.70 +function incrediblySpecificSearch() { 1.71 + let finished = waitForMatchFoundAndResultsShown(); 1.72 + typeText(gSearchBox, "1.js"); 1.73 + return finished; 1.74 +} 1.75 + 1.76 +function returnAndHide() { 1.77 + let finished = waitForResultsHidden(); 1.78 + EventUtils.sendKey("RETURN", gDebugger); 1.79 + return finished; 1.80 +} 1.81 + 1.82 +function verifySourcesPane() { 1.83 + is(gSources.itemCount, 3, 1.84 + "There should be 3 items present in the sources container."); 1.85 + is(gSources.visibleItems.length, 3, 1.86 + "There should be no hidden items in the sources container."); 1.87 + 1.88 + ok(gSources.getItemForAttachment(e => e.label == "code_script-switching-01.js"), 1.89 + "The first source's label should be correct."); 1.90 + ok(gSources.getItemForAttachment(e => e.label == "code_test-editor-mode"), 1.91 + "The second source's label should be correct."); 1.92 + ok(gSources.getItemForAttachment(e => e.label == "doc_editor-mode.html"), 1.93 + "The third source's label should be correct."); 1.94 +} 1.95 + 1.96 +registerCleanupFunction(function() { 1.97 + gTab = null; 1.98 + gDebuggee = null; 1.99 + gPanel = null; 1.100 + gDebugger = null; 1.101 + gSources = null; 1.102 + gSearchBox = null; 1.103 +});