browser/devtools/debugger/test/browser_dbg_file-reload.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_file-reload.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,63 @@
     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 that source contents are invalidated when the target navigates.
     1.9 + */
    1.10 +
    1.11 +const TAB_URL = EXAMPLE_URL + "doc_random-javascript.html";
    1.12 +const JS_URL = EXAMPLE_URL + "sjs_random-javascript.sjs";
    1.13 +
    1.14 +function test() {
    1.15 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.16 +    let gDebugger = aPanel.panelWin;
    1.17 +    let gEditor = gDebugger.DebuggerView.editor;
    1.18 +    let gSources = gDebugger.DebuggerView.Sources;
    1.19 +    let gControllerSources = gDebugger.DebuggerController.SourceScripts;
    1.20 +
    1.21 +    Task.spawn(function() {
    1.22 +      yield waitForSourceShown(aPanel, JS_URL);
    1.23 +
    1.24 +      is(gSources.itemCount, 1,
    1.25 +        "There should be one source displayed in the view.")
    1.26 +      is(gSources.selectedValue, JS_URL,
    1.27 +        "The correct source is currently selected in the view.");
    1.28 +      ok(gEditor.getText().contains("bacon"),
    1.29 +        "The currently shown source contains bacon. Mmm, delicious!");
    1.30 +
    1.31 +      let { source } = gSources.selectedItem.attachment;
    1.32 +      let [, firstText] = yield gControllerSources.getText(source);
    1.33 +      let firstNumber = parseFloat(firstText.match(/\d\.\d+/)[0]);
    1.34 +
    1.35 +      is(firstText, gEditor.getText(),
    1.36 +        "gControllerSources.getText() returned the expected contents.");
    1.37 +      ok(firstNumber <= 1 && firstNumber >= 0,
    1.38 +        "The generated number seems to be created correctly.");
    1.39 +
    1.40 +      yield reloadActiveTab(aPanel, gDebugger.EVENTS.SOURCE_SHOWN);
    1.41 +
    1.42 +      is(gSources.itemCount, 1,
    1.43 +        "There should be one source displayed in the view after reloading.")
    1.44 +      is(gSources.selectedValue, JS_URL,
    1.45 +        "The correct source is currently selected in the view after reloading.");
    1.46 +      ok(gEditor.getText().contains("bacon"),
    1.47 +        "The newly shown source contains bacon. Mmm, delicious!");
    1.48 +
    1.49 +      let { source } = gSources.selectedItem.attachment;
    1.50 +      let [, secondText] = yield gControllerSources.getText(source);
    1.51 +      let secondNumber = parseFloat(secondText.match(/\d\.\d+/)[0]);
    1.52 +
    1.53 +      is(secondText, gEditor.getText(),
    1.54 +        "gControllerSources.getText() returned the expected contents.");
    1.55 +      ok(secondNumber <= 1 && secondNumber >= 0,
    1.56 +        "The generated number seems to be created correctly.");
    1.57 +
    1.58 +      isnot(firstText, secondText,
    1.59 +        "The displayed sources were different across reloads.");
    1.60 +      isnot(firstNumber, secondNumber,
    1.61 +        "The displayed sources differences were correct across reloads.");
    1.62 +
    1.63 +      yield closeDebuggerAndFinish(aPanel);
    1.64 +    });
    1.65 +  });
    1.66 +}

mercurial