Bug 1575671 - Improve DOM Mutation breakpoints test r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D42964

--HG--
extra : moz-landing-system : lando
This commit is contained in:
David Walsh 2019-08-21 22:14:18 +00:00
parent e2930d8d52
commit b77166ea94
4 changed files with 29 additions and 8 deletions

View File

@ -29,11 +29,14 @@ add_task(async function() {
info("Sellecting the body node");
await selectNode("body", inspector);
info("Adding a DOM mutation breakpoint to body");
info("Adding DOM mutation breakpoints to body");
const allMenuItems = openContextMenuAndGetAllItems(inspector);
const breakOnMenuItem = allMenuItems.find(item => item.id === "node-menu-mutation-breakpoint-attribute");
breakOnMenuItem.click();
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");
@ -41,12 +44,12 @@ add_task(async function() {
const dbg = createDebuggerContext(toolbox);
info("Confirms that one DOM mutation breakpoint exists");
const mutationItem = await waitForElementWithSelector(dbg, ".dom-mutation-list li");
const mutationItem = await waitForElement(dbg, "domMutationItem");
ok(mutationItem, "A DOM mutation breakpoint exists");
mutationItem.scrollIntoView();
info("Enabling and disabling the DOM mutation breakpoint works ");
info("Enabling and disabling the DOM mutation breakpoint works");
const checkbox = mutationItem.querySelector("input");
checkbox.click();
await waitFor(() => !checkbox.checked);
@ -55,8 +58,19 @@ add_task(async function() {
info("Changing attribute to trigger debugger pause");
ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
content.document.querySelector("button").click();
content.document.querySelector("#attribute").click();
});
await waitForPaused(dbg);
await resume(dbg);
});
info("Changing subtree to trigger debugger pause");
ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
content.document.querySelector("#subtree").click();
});
await waitForPaused(dbg);
await resume(dbg);
info("Removing a breakpoint works")
dbg.win.document.querySelector(".dom-mutation-list .close-btn").click();
await waitForAllElements(dbg, "domMutationItem", 1);
});

View File

@ -9,11 +9,16 @@
</head>
<body>
<button title="Hello" onclick="changeAttribute()">Click me!</button>
<button title="Hello" id="attribute" onclick="changeAttribute()">Click me!</button>
<button id="subtree" onclick="changeSubtree()">Click me!</button>
<script>
function changeAttribute() {
document.body.setAttribute("title", "Goodbye");
}
function changeSubtree() {
document.body.appendChild(document.createElement("div"));
}
</script>
</body>
</html>

View File

@ -1194,6 +1194,7 @@ function assertBreakpointSnippet(dbg, index, snippet) {
const selectors = {
callStackHeader: ".call-stack-pane ._header",
callStackBody: ".call-stack-pane .pane",
domMutationItem: ".dom-mutation-list li",
expressionNode: i =>
`.expressions-list .expression-container:nth-child(${i}) .object-label`,
expressionValue: i =>

View File

@ -537,6 +537,7 @@ class MarkupContextMenu {
menu.append(
new MenuItem({
id: "node-menu-mutation-breakpoint-subtree",
checked: mutationBreakpoints.subtree,
click: () => this.markup.toggleMutationBreakpoint("subtree"),
disabled: !isSelectionElement,