michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that source contents are invalidated when the target navigates. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_random-javascript.html"; michael@0: const JS_URL = EXAMPLE_URL + "sjs_random-javascript.sjs"; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: let gDebugger = aPanel.panelWin; michael@0: let gEditor = gDebugger.DebuggerView.editor; michael@0: let gSources = gDebugger.DebuggerView.Sources; michael@0: let gControllerSources = gDebugger.DebuggerController.SourceScripts; michael@0: michael@0: Task.spawn(function() { michael@0: yield waitForSourceShown(aPanel, JS_URL); michael@0: michael@0: is(gSources.itemCount, 1, michael@0: "There should be one source displayed in the view.") michael@0: is(gSources.selectedValue, JS_URL, michael@0: "The correct source is currently selected in the view."); michael@0: ok(gEditor.getText().contains("bacon"), michael@0: "The currently shown source contains bacon. Mmm, delicious!"); michael@0: michael@0: let { source } = gSources.selectedItem.attachment; michael@0: let [, firstText] = yield gControllerSources.getText(source); michael@0: let firstNumber = parseFloat(firstText.match(/\d\.\d+/)[0]); michael@0: michael@0: is(firstText, gEditor.getText(), michael@0: "gControllerSources.getText() returned the expected contents."); michael@0: ok(firstNumber <= 1 && firstNumber >= 0, michael@0: "The generated number seems to be created correctly."); michael@0: michael@0: yield reloadActiveTab(aPanel, gDebugger.EVENTS.SOURCE_SHOWN); michael@0: michael@0: is(gSources.itemCount, 1, michael@0: "There should be one source displayed in the view after reloading.") michael@0: is(gSources.selectedValue, JS_URL, michael@0: "The correct source is currently selected in the view after reloading."); michael@0: ok(gEditor.getText().contains("bacon"), michael@0: "The newly shown source contains bacon. Mmm, delicious!"); michael@0: michael@0: let { source } = gSources.selectedItem.attachment; michael@0: let [, secondText] = yield gControllerSources.getText(source); michael@0: let secondNumber = parseFloat(secondText.match(/\d\.\d+/)[0]); michael@0: michael@0: is(secondText, gEditor.getText(), michael@0: "gControllerSources.getText() returned the expected contents."); michael@0: ok(secondNumber <= 1 && secondNumber >= 0, michael@0: "The generated number seems to be created correctly."); michael@0: michael@0: isnot(firstText, secondText, michael@0: "The displayed sources were different across reloads."); michael@0: isnot(firstNumber, secondNumber, michael@0: "The displayed sources differences were correct across reloads."); michael@0: michael@0: yield closeDebuggerAndFinish(aPanel); michael@0: }); michael@0: }); michael@0: }