browser/devtools/debugger/test/browser_dbg_reload-same-script.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 same source is shown after a page is reloaded.
michael@0 6 */
michael@0 7
michael@0 8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
michael@0 9 const FIRST_URL = EXAMPLE_URL + "code_script-switching-01.js";
michael@0 10 const SECOND_URL = EXAMPLE_URL + "code_script-switching-02.js";
michael@0 11
michael@0 12 function test() {
michael@0 13 // Debug test slaves are a bit slow at this test.
michael@0 14 requestLongerTimeout(2);
michael@0 15
michael@0 16 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 17 let gSources, gStep;
michael@0 18
michael@0 19 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 20 gTab = aTab;
michael@0 21 gDebuggee = aDebuggee;
michael@0 22 gPanel = aPanel;
michael@0 23 gDebugger = aPanel.panelWin;
michael@0 24 gSources = gDebugger.DebuggerView.Sources;
michael@0 25 gStep = 0;
michael@0 26
michael@0 27 waitForSourceShown(gPanel, FIRST_URL).then(performTest);
michael@0 28 });
michael@0 29
michael@0 30 function performTest() {
michael@0 31 switch (gStep++) {
michael@0 32 case 0:
michael@0 33 testCurrentSource(FIRST_URL, "");
michael@0 34 reload().then(performTest);
michael@0 35 break;
michael@0 36 case 1:
michael@0 37 testCurrentSource(FIRST_URL);
michael@0 38 reload().then(performTest);
michael@0 39 break;
michael@0 40 case 2:
michael@0 41 testCurrentSource(FIRST_URL);
michael@0 42 switchAndReload(SECOND_URL).then(performTest);
michael@0 43 break;
michael@0 44 case 3:
michael@0 45 testCurrentSource(SECOND_URL);
michael@0 46 reload().then(performTest);
michael@0 47 break;
michael@0 48 case 4:
michael@0 49 testCurrentSource(SECOND_URL);
michael@0 50 reload().then(performTest);
michael@0 51 break;
michael@0 52 case 5:
michael@0 53 testCurrentSource(SECOND_URL);
michael@0 54 closeDebuggerAndFinish(gPanel);
michael@0 55 break;
michael@0 56 }
michael@0 57 }
michael@0 58
michael@0 59 function reload() {
michael@0 60 return reloadActiveTab(gPanel, gDebugger.EVENTS.SOURCES_ADDED);
michael@0 61 }
michael@0 62
michael@0 63 function switchAndReload(aUrl) {
michael@0 64 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN).then(reload);
michael@0 65 gSources.selectedValue = aUrl;
michael@0 66 return finished;
michael@0 67 }
michael@0 68
michael@0 69 function testCurrentSource(aUrl, aExpectedUrl = aUrl) {
michael@0 70 info("Currently preferred source: '" + gSources.preferredValue + "'.");
michael@0 71 info("Currently selected source: '" + gSources.selectedValue + "'.");
michael@0 72
michael@0 73 is(gSources.preferredValue, aExpectedUrl,
michael@0 74 "The preferred source url wasn't set correctly (" + gStep + ").");
michael@0 75 is(gSources.selectedValue, aUrl,
michael@0 76 "The selected source isn't the correct one (" + gStep + ").");
michael@0 77 }
michael@0 78 }

mercurial