Bug 1053898 - Update Walker and Node actors to observe mutations in shadow roots;r=bgrins draft
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 05 Mar 2018 19:16:03 +0100
changeset 773667 b42b7e42c86d5ad1e4e3d435a3f2908dda08d1f1
parent 773666 d4f9698a772c1ac3bc749303e96ef132c247d850
child 773668 bf3a2d42ddb07b5bac08fc95226e9751874c1f7a
push id104269
push userjdescottes@mozilla.com
push dateWed, 28 Mar 2018 08:16:27 +0000
reviewersbgrins
bugs1053898
milestone61.0a1
Bug 1053898 - Update Walker and Node actors to observe mutations in shadow roots;r=bgrins MozReview-Commit-ID: Djlo8ZC84Vm
devtools/server/actors/inspector/node.js
devtools/server/actors/inspector/walker.js
--- a/devtools/server/actors/inspector/node.js
+++ b/devtools/server/actors/inspector/node.js
@@ -154,21 +154,21 @@ const NodeActor = protocol.ActorClassWit
 
     return form;
   },
 
   /**
    * Watch the given document node for mutations using the DOM observer
    * API.
    */
-  watchDocument: function(callback) {
+  watchDocument: function(doc, callback) {
     let node = this.rawNode;
     // Create the observer on the node's actor.  The node will make sure
     // the observer is cleaned up when the actor is released.
-    let observer = new node.defaultView.MutationObserver(callback);
+    let observer = new doc.defaultView.MutationObserver(callback);
     observer.mergeAttributeRecords = true;
     observer.observe(node, {
       nativeAnonymousChildList: true,
       attributes: true,
       characterData: true,
       characterDataOldValue: true,
       childList: true,
       subtree: true
--- a/devtools/server/actors/inspector/walker.js
+++ b/devtools/server/actors/inspector/walker.js
@@ -302,20 +302,21 @@ var WalkerActor = protocol.ActorClassWit
     actor = new NodeActor(this, node);
 
     // Add the node actor as a child of this walker actor, assigning
     // it an actorID.
     this.manage(actor);
     this._refMap.set(node, actor);
 
     if (node.nodeType === Ci.nsIDOMNode.DOCUMENT_NODE) {
-      actor.watchDocument(this.onMutations);
+      actor.watchDocument(node, this.onMutations);
     }
 
     if (actor.isShadowRoot) {
+      actor.watchDocument(node.ownerDocument, this.onMutations);
       actor.watchSlotchange(this.onSlotchange);
     }
 
     return actor;
   },
 
   _onReflows: function(reflows) {
     // Going through the nodes the walker knows about, see which ones have