browser/devtools/debugger/test/browser_dbg_file-reload.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Tests that source contents are invalidated when the target navigates.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_random-javascript.html";
     9 const JS_URL = EXAMPLE_URL + "sjs_random-javascript.sjs";
    11 function test() {
    12   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    13     let gDebugger = aPanel.panelWin;
    14     let gEditor = gDebugger.DebuggerView.editor;
    15     let gSources = gDebugger.DebuggerView.Sources;
    16     let gControllerSources = gDebugger.DebuggerController.SourceScripts;
    18     Task.spawn(function() {
    19       yield waitForSourceShown(aPanel, JS_URL);
    21       is(gSources.itemCount, 1,
    22         "There should be one source displayed in the view.")
    23       is(gSources.selectedValue, JS_URL,
    24         "The correct source is currently selected in the view.");
    25       ok(gEditor.getText().contains("bacon"),
    26         "The currently shown source contains bacon. Mmm, delicious!");
    28       let { source } = gSources.selectedItem.attachment;
    29       let [, firstText] = yield gControllerSources.getText(source);
    30       let firstNumber = parseFloat(firstText.match(/\d\.\d+/)[0]);
    32       is(firstText, gEditor.getText(),
    33         "gControllerSources.getText() returned the expected contents.");
    34       ok(firstNumber <= 1 && firstNumber >= 0,
    35         "The generated number seems to be created correctly.");
    37       yield reloadActiveTab(aPanel, gDebugger.EVENTS.SOURCE_SHOWN);
    39       is(gSources.itemCount, 1,
    40         "There should be one source displayed in the view after reloading.")
    41       is(gSources.selectedValue, JS_URL,
    42         "The correct source is currently selected in the view after reloading.");
    43       ok(gEditor.getText().contains("bacon"),
    44         "The newly shown source contains bacon. Mmm, delicious!");
    46       let { source } = gSources.selectedItem.attachment;
    47       let [, secondText] = yield gControllerSources.getText(source);
    48       let secondNumber = parseFloat(secondText.match(/\d\.\d+/)[0]);
    50       is(secondText, gEditor.getText(),
    51         "gControllerSources.getText() returned the expected contents.");
    52       ok(secondNumber <= 1 && secondNumber >= 0,
    53         "The generated number seems to be created correctly.");
    55       isnot(firstText, secondText,
    56         "The displayed sources were different across reloads.");
    57       isnot(firstNumber, secondNumber,
    58         "The displayed sources differences were correct across reloads.");
    60       yield closeDebuggerAndFinish(aPanel);
    61     });
    62   });
    63 }

mercurial