browser/devtools/debugger/test/browser_dbg_reload-preferred-script-03.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 preferred source is shown when a page is loaded and
michael@0 6 * the preferred source is specified after another source was definitely shown.
michael@0 7 */
michael@0 8
michael@0 9 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
michael@0 10 const FIRST_URL = EXAMPLE_URL + "code_script-switching-01.js";
michael@0 11 const SECOND_URL = EXAMPLE_URL + "code_script-switching-02.js";
michael@0 12
michael@0 13 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 14 let gSources;
michael@0 15
michael@0 16 function test() {
michael@0 17 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 18 gTab = aTab;
michael@0 19 gDebuggee = aDebuggee;
michael@0 20 gPanel = aPanel;
michael@0 21 gDebugger = gPanel.panelWin;
michael@0 22 gSources = gDebugger.DebuggerView.Sources;
michael@0 23
michael@0 24 waitForSourceShown(gPanel, FIRST_URL)
michael@0 25 .then(() => testSource("", FIRST_URL))
michael@0 26 .then(() => switchToSource(SECOND_URL))
michael@0 27 .then(() => testSource(SECOND_URL))
michael@0 28 .then(() => switchToSource(FIRST_URL))
michael@0 29 .then(() => testSource(FIRST_URL))
michael@0 30 .then(() => closeDebuggerAndFinish(gPanel))
michael@0 31 .then(null, aError => {
michael@0 32 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 33 });
michael@0 34 });
michael@0 35 }
michael@0 36
michael@0 37 function testSource(aPreferredUrl, aSelectedUrl = aPreferredUrl) {
michael@0 38 info("Currently preferred source: " + gSources.preferredValue);
michael@0 39 info("Currently selected source: " + gSources.selectedValue);
michael@0 40
michael@0 41 is(gSources.preferredValue, aPreferredUrl,
michael@0 42 "The preferred source url wasn't set correctly.");
michael@0 43 is(gSources.selectedValue, aSelectedUrl,
michael@0 44 "The selected source isn't the correct one.");
michael@0 45 }
michael@0 46
michael@0 47 function switchToSource(aUrl) {
michael@0 48 let finished = waitForSourceShown(gPanel, aUrl);
michael@0 49 gSources.preferredSource = aUrl;
michael@0 50 return finished;
michael@0 51 }
michael@0 52
michael@0 53 registerCleanupFunction(function() {
michael@0 54 gTab = null;
michael@0 55 gDebuggee = null;
michael@0 56 gPanel = null;
michael@0 57 gDebugger = null;
michael@0 58 gSources = null;
michael@0 59 });

mercurial