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
This commit is contained in:
Logan Smyth 2019-08-09 01:26:58 +00:00
Родитель e1e2f90a47
Коммит 75676e23ac
1 изменённых файлов: 19 добавлений и 3 удалений

Просмотреть файл

@ -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;