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.

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

mercurial