Bug 1453385 - Fix actors trying to transfer functions or xpcom objects. r=jryans
MozReview-Commit-ID: 74l85ePCcrY
--- 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) {