|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that source contents are invalidated when the target navigates. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_random-javascript.html"; |
|
9 const JS_URL = EXAMPLE_URL + "sjs_random-javascript.sjs"; |
|
10 |
|
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; |
|
17 |
|
18 Task.spawn(function() { |
|
19 yield waitForSourceShown(aPanel, JS_URL); |
|
20 |
|
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!"); |
|
27 |
|
28 let { source } = gSources.selectedItem.attachment; |
|
29 let [, firstText] = yield gControllerSources.getText(source); |
|
30 let firstNumber = parseFloat(firstText.match(/\d\.\d+/)[0]); |
|
31 |
|
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."); |
|
36 |
|
37 yield reloadActiveTab(aPanel, gDebugger.EVENTS.SOURCE_SHOWN); |
|
38 |
|
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!"); |
|
45 |
|
46 let { source } = gSources.selectedItem.attachment; |
|
47 let [, secondText] = yield gControllerSources.getText(source); |
|
48 let secondNumber = parseFloat(secondText.match(/\d\.\d+/)[0]); |
|
49 |
|
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."); |
|
54 |
|
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."); |
|
59 |
|
60 yield closeDebuggerAndFinish(aPanel); |
|
61 }); |
|
62 }); |
|
63 } |