browser/devtools/debugger/test/browser_dbg_bfcache.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 * Make sure that the debugger is updated with the correct sources when moving
michael@0 6 * back and forward in the tab.
michael@0 7 */
michael@0 8
michael@0 9 const TAB_URL_1 = EXAMPLE_URL + "doc_script-switching-01.html";
michael@0 10 const TAB_URL_2 = EXAMPLE_URL + "doc_recursion-stack.html";
michael@0 11
michael@0 12 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 13 let gSources;
michael@0 14
michael@0 15 function test() {
michael@0 16 initDebugger(TAB_URL_1).then(([aTab, aDebuggee, aPanel]) => {
michael@0 17 gTab = aTab;
michael@0 18 gDebuggee = aDebuggee;
michael@0 19 gPanel = aPanel;
michael@0 20 gDebugger = gPanel.panelWin;
michael@0 21 gSources = gDebugger.DebuggerView.Sources;
michael@0 22
michael@0 23 testFirstPage()
michael@0 24 .then(testLocationChange)
michael@0 25 .then(testBack)
michael@0 26 .then(testForward)
michael@0 27 .then(() => closeDebuggerAndFinish(gPanel))
michael@0 28 .then(null, aError => {
michael@0 29 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 30 });
michael@0 31 });
michael@0 32 }
michael@0 33
michael@0 34 function testFirstPage() {
michael@0 35 info("Testing first page.");
michael@0 36
michael@0 37 // Spin the event loop before causing the debuggee to pause, to allow
michael@0 38 // this function to return first.
michael@0 39 executeSoon(() => gDebuggee.firstCall());
michael@0 40
michael@0 41 return waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(() => {
michael@0 42 validateFirstPage();
michael@0 43 });
michael@0 44 }
michael@0 45
michael@0 46 function testLocationChange() {
michael@0 47 info("Navigating to a different page.");
michael@0 48
michael@0 49 return navigateActiveTabTo(gPanel, TAB_URL_2, gDebugger.EVENTS.SOURCES_ADDED).then(() => {
michael@0 50 validateSecondPage();
michael@0 51 });
michael@0 52 }
michael@0 53
michael@0 54 function testBack() {
michael@0 55 info("Going back.");
michael@0 56
michael@0 57 return navigateActiveTabInHistory(gPanel, "back", gDebugger.EVENTS.SOURCES_ADDED).then(() => {
michael@0 58 validateFirstPage();
michael@0 59 });
michael@0 60 }
michael@0 61
michael@0 62 function testForward() {
michael@0 63 info("Going forward.");
michael@0 64
michael@0 65 return navigateActiveTabInHistory(gPanel, "forward", gDebugger.EVENTS.SOURCES_ADDED).then(() => {
michael@0 66 validateSecondPage();
michael@0 67 });
michael@0 68 }
michael@0 69
michael@0 70 function validateFirstPage() {
michael@0 71 is(gSources.itemCount, 2,
michael@0 72 "Found the expected number of sources.");
michael@0 73 ok(gSources.getItemForAttachment(e => e.label == "code_script-switching-01.js"),
michael@0 74 "Found the first source label.");
michael@0 75 ok(gSources.getItemForAttachment(e => e.label == "code_script-switching-02.js"),
michael@0 76 "Found the second source label.");
michael@0 77 }
michael@0 78
michael@0 79 function validateSecondPage() {
michael@0 80 is(gSources.itemCount, 1,
michael@0 81 "Found the expected number of sources.");
michael@0 82 ok(gSources.getItemForAttachment(e => e.label == "doc_recursion-stack.html"),
michael@0 83 "Found the single source label.");
michael@0 84 }
michael@0 85
michael@0 86 registerCleanupFunction(function() {
michael@0 87 gTab = null;
michael@0 88 gDebuggee = null;
michael@0 89 gPanel = null;
michael@0 90 gDebugger = null;
michael@0 91 gSources = null;
michael@0 92 });

mercurial