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
|
/* 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/>. */
add_task(async function() {
await pushPref(
"devtools.debugger.features.event-listeners-breakpoints",
true
);
const dbg = await initDebugger(
"doc-event-breakpoints.html",
"event-breakpoints"
);
await selectSource(dbg, "event-breakpoints");
await waitForSelectedSource(dbg, "event-breakpoints");
await dbg.actions.addEventListenerBreakpoints([
"event.mouse.click",
"event.xhr.load",
"timer.timeout.set",
"timer.timeout.fire",
"script.source.firstStatement",
]);
invokeInTab("clickHandler");
await waitForPaused(dbg);
assertPauseLocation(dbg, 12);
await resume(dbg);
invokeInTab("xhrHandler");
await waitForPaused(dbg);
assertPauseLocation(dbg, 20);
await resume(dbg);
invokeInTab("timerHandler");
await waitForPaused(dbg);
assertPauseLocation(dbg, 27);
await resume(dbg);
await waitForPaused(dbg);
assertPauseLocation(dbg, 28);
await resume(dbg);
invokeInTab("evalHandler");
await waitForPaused(dbg);
assertPauseLocation(dbg, 2, "http://example.com/eval-test.js");
await resume(dbg);
// Test that we don't pause on event breakpoints when source is blackboxed.
await clickElement(dbg, "blackbox");
await waitForDispatch(dbg, "BLACKBOX");
invokeInTab("clickHandler");
is(isPaused(dbg), false);
invokeInTab("xhrHandler");
is(isPaused(dbg), false);
invokeInTab("timerHandler");
is(isPaused(dbg), false);
// Cleanup - unblackbox the source
await clickElement(dbg, "blackbox");
await waitForDispatch(dbg, "BLACKBOX");
});
function assertPauseLocation(dbg, line, url = "event-breakpoints.js") {
const { location } = dbg.selectors.getVisibleSelectedFrame();
const source = findSource(dbg, url);
is(location.sourceId, source.id, `correct sourceId`);
is(location.line, line, `correct line`);
assertPausedLocation(dbg);
}
|