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
|
/* 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 adding, disble/enable, and removal of dom mutation breakpoints
/* import-globals-from ../../../inspector/test/shared-head.js */
// Import helpers for the inspector
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/devtools/client/inspector/test/shared-head.js",
this
);
const DMB_TEST_URL =
"http://example.com/browser/devtools/client/debugger/test/mochitest/examples/doc-dom-mutation.html";
add_task(async function() {
// Enable features
await pushPref("devtools.debugger.features.dom-mutation-breakpoints", true);
await pushPref("devtools.markup.mutationBreakpoints.enabled", true);
await pushPref("devtools.debugger.dom-mutation-breakpoints-visible", true);
info("Switches over to the inspector pane");
const { inspector, toolbox } = await openInspectorForURL(DMB_TEST_URL);
info("Selecting the body node");
await selectNode("body", inspector);
info("Adding DOM mutation breakpoints to body");
const allMenuItems = openContextMenuAndGetAllItems(inspector);
const attributeMenuItem = allMenuItems.find(
item => item.id === "node-menu-mutation-breakpoint-attribute"
);
attributeMenuItem.click();
const subtreeMenuItem = allMenuItems.find(
item => item.id === "node-menu-mutation-breakpoint-subtree"
);
subtreeMenuItem.click();
info("Switches over to the debugger pane");
await toolbox.selectTool("jsdebugger");
const dbg = createDebuggerContext(toolbox);
info("Confirms that one DOM mutation breakpoint exists");
const mutationItem = await waitForElement(dbg, "domMutationItem");
ok(mutationItem, "A DOM mutation breakpoint exists");
mutationItem.scrollIntoView();
info("Enabling and disabling the DOM mutation breakpoint works");
const checkbox = mutationItem.querySelector("input");
checkbox.click();
await waitFor(() => !checkbox.checked);
checkbox.click();
await waitFor(() => checkbox.checked);
info("Changing attribute to trigger debugger pause");
SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
content.document.querySelector("#attribute").click();
});
await waitForPaused(dbg);
await resume(dbg);
info("Changing subtree to trigger debugger pause");
SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
content.document.querySelector("#subtree").click();
});
await waitForPaused(dbg);
await resume(dbg);
info("Blackboxing the source prevents debugger pause");
await waitForSource(dbg, "dom-mutation.original.js");
const source = findSource(dbg, "dom-mutation.original.js");
await selectSource(dbg, source);
await clickElement(dbg, "blackbox");
await waitForDispatch(dbg, "BLACKBOX");
SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
content.document.querySelector("#blackbox").click();
});
await waitForPaused(dbg, "click.js");
await resume(dbg);
await selectSource(dbg, source);
await clickElement(dbg, "blackbox");
await waitForDispatch(dbg, "BLACKBOX");
info("Removing breakpoints works");
dbg.win.document.querySelector(".dom-mutation-list .close-btn").click();
await waitForAllElements(dbg, "domMutationItem", 1, true);
});
|