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