1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests that source contents are invalidated when the target navigates.
*/
const TAB_URL = EXAMPLE_URL + "doc_random-javascript.html";
const JS_URL = EXAMPLE_URL + "sjs_random-javascript.sjs";
function test() {
let options = {
source: JS_URL,
line: 1
};
initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
const gPanel = aPanel;
const gDebugger = aPanel.panelWin;
const gEditor = gDebugger.DebuggerView.editor;
const gSources = gDebugger.DebuggerView.Sources;
const queries = gDebugger.require("./content/queries");
const constants = gDebugger.require("./content/constants");
const actions = bindActionCreators(gPanel);
const getState = gDebugger.DebuggerController.getState;
Task.spawn(function* () {
let source = queries.getSelectedSource(getState());
is(queries.getSourceCount(getState()), 1,
"There should be one source displayed in the view.");
is(source.url, JS_URL,
"The correct source is currently selected in the view.");
ok(gEditor.getText().includes("bacon"),
"The currently shown source contains bacon. Mmm, delicious!");
const { text: firstText } = yield queries.getSourceText(getState(), source.actor);
const firstNumber = parseFloat(firstText.match(/\d\.\d+/)[0]);
is(firstText, gEditor.getText(),
"gControllerSources.getText() returned the expected contents.");
ok(firstNumber <= 1 && firstNumber >= 0,
"The generated number seems to be created correctly.");
yield reloadActiveTab(aPanel, gDebugger.EVENTS.SOURCE_SHOWN);
is(queries.getSourceCount(getState()), 1,
"There should be one source displayed in the view.");
is(source.url, JS_URL,
"The correct source is currently selected in the view.");
ok(gEditor.getText().includes("bacon"),
"The newly shown source contains bacon. Mmm, delicious!");
source = queries.getSelectedSource(getState());
const { text: secondText } = yield queries.getSourceText(getState(), source.actor);
const secondNumber = parseFloat(secondText.match(/\d\.\d+/)[0]);
is(secondText, gEditor.getText(),
"gControllerSources.getText() returned the expected contents.");
ok(secondNumber <= 1 && secondNumber >= 0,
"The generated number seems to be created correctly.");
isnot(firstText, secondText,
"The displayed sources were different across reloads.");
isnot(firstNumber, secondNumber,
"The displayed sources differences were correct across reloads.");
yield closeDebuggerAndFinish(aPanel);
});
});
}
|