Bug 1453385 - Fix actors trying to transfer functions or xpcom objects. r=jryans
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 12 Apr 2018 14:45:10 -0700
changeset 413263 49862a0820f94e96d07d3e20174b01f24871bf6e
parent 413262 c611078b5add8c91a6df5f8a7dff2bedad4a11e2
child 413264 a7561379843f63c1a548ff1842ba5e7359580d43
push id62660
push userapoirot@mozilla.com
push dateFri, 13 Apr 2018 21:26:39 +0000
treeherderautoland@a7561379843f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1453385
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1453385 - Fix actors trying to transfer functions or xpcom objects. r=jryans MozReview-Commit-ID: 74l85ePCcrY
devtools/client/shared/test/test-actor.js
devtools/server/actors/inspector/node.js
--- a/devtools/client/shared/test/test-actor.js
+++ b/devtools/client/shared/test/test-actor.js
@@ -656,17 +656,25 @@ var TestActor = exports.TestActor = prot
   /**
    * Evaluate a JS string in the context of the content document.
    * @param {String} js JS string to evaluate
    * @return {json} The evaluation result
    */
   eval: function(js) {
     // We have to use a sandbox, as CSP prevent us from using eval on apps...
     let sb = Cu.Sandbox(this.content, { sandboxPrototype: this.content });
-    return Cu.evalInSandbox(js, sb);
+    let result = Cu.evalInSandbox(js, sb);
+
+    // Ensure passing only serializable data to RDP
+    if (typeof result == "function") {
+      return null;
+    } else if (typeof result == "object") {
+      return JSON.parse(JSON.stringify(result));
+    }
+    return result;
   },
 
   /**
    * Scrolls the window to a particular set of coordinates in the document, or
    * by the given amount if `relative` is set to `true`.
    *
    * @param {Number} x
    * @param {Number} y
--- a/devtools/server/actors/inspector/node.js
+++ b/devtools/server/actors/inspector/node.js
@@ -173,32 +173,32 @@ const NodeActor = protocol.ActorClassWit
   },
 
   get isAfterPseudoElement() {
     return this.rawNode.nodeName === "_moz_generated_content_after";
   },
 
   get isShadowRoot() {
     let isFragment = this.rawNode.nodeType === Ci.nsIDOMNode.DOCUMENT_FRAGMENT_NODE;
-    return isFragment && this.rawNode.host;
+    return isFragment && !!this.rawNode.host;
   },
 
   get isShadowHost() {
     let shadowRoot = this.rawNode.shadowRoot;
     return shadowRoot && shadowRoot.nodeType === Ci.nsIDOMNode.DOCUMENT_FRAGMENT_NODE;
   },
 
   get isDirectShadowHostChild() {
     // Pseudo elements are always part of the anonymous tree.
     if (this.isBeforePseudoElement || this.isAfterPseudoElement) {
       return false;
     }
 
     let parentNode = this.rawNode.parentNode;
-    return parentNode && parentNode.shadowRoot;
+    return parentNode && !!parentNode.shadowRoot;
   },
 
   // Estimate the number of children that the walker will return without making
   // a call to children() if possible.
   get numChildren() {
     // For pseudo elements, childNodes.length returns 1, but the walker
     // will return 0.
     if (this.isBeforePseudoElement || this.isAfterPseudoElement) {