browser/devtools/debugger/test/browser_dbg_reload-preferred-script-03.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_reload-preferred-script-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Tests if the preferred source is shown when a page is loaded and
     1.9 + * the preferred source is specified after another source was definitely shown.
    1.10 + */
    1.11 +
    1.12 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
    1.13 +const FIRST_URL = EXAMPLE_URL + "code_script-switching-01.js";
    1.14 +const SECOND_URL = EXAMPLE_URL + "code_script-switching-02.js";
    1.15 +
    1.16 +let gTab, gDebuggee, gPanel, gDebugger;
    1.17 +let gSources;
    1.18 +
    1.19 +function test() {
    1.20 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.21 +    gTab = aTab;
    1.22 +    gDebuggee = aDebuggee;
    1.23 +    gPanel = aPanel;
    1.24 +    gDebugger = gPanel.panelWin;
    1.25 +    gSources = gDebugger.DebuggerView.Sources;
    1.26 +
    1.27 +    waitForSourceShown(gPanel, FIRST_URL)
    1.28 +      .then(() => testSource("", FIRST_URL))
    1.29 +      .then(() => switchToSource(SECOND_URL))
    1.30 +      .then(() => testSource(SECOND_URL))
    1.31 +      .then(() => switchToSource(FIRST_URL))
    1.32 +      .then(() => testSource(FIRST_URL))
    1.33 +      .then(() => closeDebuggerAndFinish(gPanel))
    1.34 +      .then(null, aError => {
    1.35 +        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    1.36 +      });
    1.37 +  });
    1.38 +}
    1.39 +
    1.40 +function testSource(aPreferredUrl, aSelectedUrl = aPreferredUrl) {
    1.41 +  info("Currently preferred source: " + gSources.preferredValue);
    1.42 +  info("Currently selected source: " + gSources.selectedValue);
    1.43 +
    1.44 +  is(gSources.preferredValue, aPreferredUrl,
    1.45 +    "The preferred source url wasn't set correctly.");
    1.46 +  is(gSources.selectedValue, aSelectedUrl,
    1.47 +    "The selected source isn't the correct one.");
    1.48 +}
    1.49 +
    1.50 +function switchToSource(aUrl) {
    1.51 +  let finished = waitForSourceShown(gPanel, aUrl);
    1.52 +  gSources.preferredSource = aUrl;
    1.53 +  return finished;
    1.54 +}
    1.55 +
    1.56 +registerCleanupFunction(function() {
    1.57 +  gTab = null;
    1.58 +  gDebuggee = null;
    1.59 +  gPanel = null;
    1.60 +  gDebugger = null;
    1.61 +  gSources = null;
    1.62 +});

mercurial