1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_reload-same-script.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,78 @@ 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 if the same source is shown after a page is reloaded. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; 1.12 +const FIRST_URL = EXAMPLE_URL + "code_script-switching-01.js"; 1.13 +const SECOND_URL = EXAMPLE_URL + "code_script-switching-02.js"; 1.14 + 1.15 +function test() { 1.16 + // Debug test slaves are a bit slow at this test. 1.17 + requestLongerTimeout(2); 1.18 + 1.19 + let gTab, gDebuggee, gPanel, gDebugger; 1.20 + let gSources, gStep; 1.21 + 1.22 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.23 + gTab = aTab; 1.24 + gDebuggee = aDebuggee; 1.25 + gPanel = aPanel; 1.26 + gDebugger = aPanel.panelWin; 1.27 + gSources = gDebugger.DebuggerView.Sources; 1.28 + gStep = 0; 1.29 + 1.30 + waitForSourceShown(gPanel, FIRST_URL).then(performTest); 1.31 + }); 1.32 + 1.33 + function performTest() { 1.34 + switch (gStep++) { 1.35 + case 0: 1.36 + testCurrentSource(FIRST_URL, ""); 1.37 + reload().then(performTest); 1.38 + break; 1.39 + case 1: 1.40 + testCurrentSource(FIRST_URL); 1.41 + reload().then(performTest); 1.42 + break; 1.43 + case 2: 1.44 + testCurrentSource(FIRST_URL); 1.45 + switchAndReload(SECOND_URL).then(performTest); 1.46 + break; 1.47 + case 3: 1.48 + testCurrentSource(SECOND_URL); 1.49 + reload().then(performTest); 1.50 + break; 1.51 + case 4: 1.52 + testCurrentSource(SECOND_URL); 1.53 + reload().then(performTest); 1.54 + break; 1.55 + case 5: 1.56 + testCurrentSource(SECOND_URL); 1.57 + closeDebuggerAndFinish(gPanel); 1.58 + break; 1.59 + } 1.60 + } 1.61 + 1.62 + function reload() { 1.63 + return reloadActiveTab(gPanel, gDebugger.EVENTS.SOURCES_ADDED); 1.64 + } 1.65 + 1.66 + function switchAndReload(aUrl) { 1.67 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN).then(reload); 1.68 + gSources.selectedValue = aUrl; 1.69 + return finished; 1.70 + } 1.71 + 1.72 + function testCurrentSource(aUrl, aExpectedUrl = aUrl) { 1.73 + info("Currently preferred source: '" + gSources.preferredValue + "'."); 1.74 + info("Currently selected source: '" + gSources.selectedValue + "'."); 1.75 + 1.76 + is(gSources.preferredValue, aExpectedUrl, 1.77 + "The preferred source url wasn't set correctly (" + gStep + ")."); 1.78 + is(gSources.selectedValue, aUrl, 1.79 + "The selected source isn't the correct one (" + gStep + ")."); 1.80 + } 1.81 +}