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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// Tests breakpoints syncing when reloading
"use strict";
requestLongerTimeout(3);
// Tests that a breakpoint set is correctly synced after reload
// and gets hit correctly.
add_task(async function () {
const dbg = await initDebugger("doc-scripts.html", "simple1.js", "long.js");
await selectSource(dbg, "simple1.js");
// Setting 2 breakpoints, one on line 61 which is expected
// to get hit, while the other on line 56 which is not expected
// to get hit, but to assert that it correctly set after reload.
await addBreakpointViaGutter(dbg, 61);
await addBreakpointViaGutter(dbg, 56);
await selectSource(dbg, "long.js");
await addBreakpointViaGutter(dbg, 1);
const onReloaded = reload(dbg);
await waitForPaused(dbg);
info("Assert that the source is not long.js");
// Adding this is redundant but just to make it explicit that we
// make sure long.js should not exist yet
assertSourceDoesNotExist(dbg, "long.js");
const source = findSource(dbg, "simple1.js");
await assertPausedAtSourceAndLine(dbg, source.id, 61);
info("The breakpoint for long.js does not exist yet");
await waitForState(dbg, () => dbg.selectors.getBreakpointCount() == 2);
// The breakpoints are available once their corresponding source
// has been processed. Let's assert that all the breakpoints for
// simple1.js have been restored.
await assertBreakpoint(dbg, 56);
await assertBreakpoint(dbg, 61);
await resume(dbg);
await waitForPaused(dbg);
const source2 = findSource(dbg, "long.js");
await assertPausedAtSourceAndLine(dbg, source2.id, 1);
info("All 3 breakpoints from simple1.js and long.js still exist");
await waitForState(dbg, () => dbg.selectors.getBreakpointCount() == 3);
await assertBreakpoint(dbg, 1);
await resume(dbg);
info("Wait for reload to complete after resume");
await onReloaded;
// remove breakpoints so they do not affect other
// tests.
await removeBreakpoint(dbg, source.id, 56);
await removeBreakpoint(dbg, source.id, 61);
await removeBreakpoint(dbg, source2.id, 1);
await dbg.toolbox.closeToolbox();
});
// Test that pending breakpoints are installed in inline scripts as they are
// sent to the client.
add_task(async function () {
const dbg = await initDebugger("doc-scripts.html", "doc-scripts.html");
await selectSource(dbg, "doc-scripts.html");
await addBreakpointViaGutter(dbg, 22);
await addBreakpointViaGutter(dbg, 27);
const onReloaded = reload(dbg, "doc-scripts.html");
await waitForPaused(dbg);
const source = findSource(dbg, "doc-scripts.html");
await assertPausedAtSourceAndLine(dbg, source.id, 22);
info("Only the breakpoint for the first inline script should exist");
await waitForState(dbg, () => dbg.selectors.getBreakpointCount() == 1);
await assertBreakpoint(dbg, 22);
// The second breakpoint we added is in a later inline script, and won't
// appear until after we have resumed from the first breakpoint and the
// second inline script has been created.
await assertNoBreakpoint(dbg, 27);
await resume(dbg);
await waitForPaused(dbg);
info("All 2 breakpoints from both inline scripts still exist");
await waitForState(dbg, () => dbg.selectors.getBreakpointCount() == 2);
await assertPausedAtSourceAndLine(dbg, source.id, 27);
await assertBreakpoint(dbg, 27);
await resume(dbg);
info("Wait for reload to complete after resume");
await onReloaded;
await removeBreakpoint(dbg, source.id, 22);
await removeBreakpoint(dbg, source.id, 27);
await dbg.toolbox.closeToolbox();
});
function assertSourceDoesNotExist(dbg, url) {
const source = findSource(dbg, url, { silent: true });
ok(!source, `Source for ${url} does not exist`);
}
|