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.

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

mercurial