From 75676e23ac2072c4f2b63866a2cd0307e114e6c8 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Fri, 9 Aug 2019 01:26:58 +0000 Subject: [PATCH] Bug 1550031 - Part 1: Clear DOM Mutation Breakpoint state on frame navigation. r=jlast Differential Revision: https://phabricator.services.mozilla.com/D40333 --HG-- extra : moz-landing-system : lando --- devtools/server/actors/inspector/walker.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/devtools/server/actors/inspector/walker.js b/devtools/server/actors/inspector/walker.js index cd49e6f17ade..b445b4988ef0 100644 --- a/devtools/server/actors/inspector/walker.js +++ b/devtools/server/actors/inspector/walker.js @@ -1960,7 +1960,11 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, { ); const originalBpsForNode = this._breakpointInfoForNode(rawNode) || {}; - docMutationBreakpoints.nodes.set(rawNode, bpsForNode); + if (Object.values(bpsForNode).some(Boolean)) { + docMutationBreakpoints.nodes.set(rawNode, bpsForNode); + } else { + docMutationBreakpoints.nodes.delete(rawNode); + } if (originalBpsForNode.subtree && !bpsForNode.subtree) { docMutationBreakpoints.counts.subtree -= 1; } else if (!originalBpsForNode.subtree && bpsForNode.subtree) { @@ -1999,7 +2003,7 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, { */ _updateNodeMutationListeners(rawNode) { const bpInfo = this._breakpointInfoForNode(rawNode); - if (bpInfo.subtree || bpInfo.removal || bpInfo.attribute) { + if (bpInfo && (bpInfo.subtree || bpInfo.removal || bpInfo.attribute)) { eventListenerService.addSystemEventListener( rawNode, "DOMNodeRemovedFromDocument", @@ -2093,7 +2097,7 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, { removal: 0, attribute: 0, }, - nodes: new WeakMap(), + nodes: new Map(), }; this._mutationBreakpoints.set(rawDoc, docMutationBreakpoints); } @@ -2494,6 +2498,18 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, { return; } + // Removing a frame also removes any mutation breakpoints set on that + // document so that clients can clear their set of active breakpoints. + const mutationBps = this._mutationBreakpointsForDoc(doc); + const nodes = mutationBps ? Array.from(mutationBps.nodes.keys()) : []; + for (const node of nodes) { + this._updateMutationBreakpointState(node, { + subtree: false, + removal: false, + attribute: false, + }); + } + if (this.rootDoc === doc) { this.rootDoc = null; this.rootNode = null;