Bug 1031609 - XUL node import shim (r=mconley)
authorBill McCloskey <wmccloskey@mozilla.com>
Mon, 14 Jul 2014 22:10:06 -0700
changeset 214779 dc0eb1d286f084fbe68a88dfbf31049f5c2d4231
parent 214778 5bbb653cac5750830939cbd0d4fecab012d19f97
child 214780 58de0be65bc24a9206d3faa9e53bedbe87b1a704
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1031609
milestone33.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 1031609 - XUL node import shim (r=mconley)
toolkit/components/addoncompat/RemoteAddonsParent.jsm
--- a/toolkit/components/addoncompat/RemoteAddonsParent.jsm
+++ b/toolkit/components/addoncompat/RemoteAddonsParent.jsm
@@ -494,16 +494,36 @@ ComponentsUtilsInterposition.methods.eva
   function(addon, target, code, sandbox, ...rest) {
     if (sandbox && Cu.isCrossProcessWrapper(sandbox)) {
       return SandboxParent.evalInSandbox(code, sandbox, ...rest);
     } else {
       return Components.utils.evalInSandbox(code, sandbox, ...rest);
     }
   };
 
+// This interposition handles cases where an add-on tries to import a
+// chrome XUL node into a content document. It doesn't actually do the
+// import, which we can't support. It just avoids throwing an
+// exception.
+let ContentDocumentInterposition = new Interposition();
+
+ContentDocumentInterposition.methods.importNode =
+  function(addon, target, node, deep) {
+    if (!Cu.isCrossProcessWrapper(node)) {
+      // Trying to import a node from the parent process into the
+      // child process. We don't support this now. Video Download
+      // Helper does this in domhook-service.js to add a XUL
+      // popupmenu to content.
+      Cu.reportError("Calling contentDocument.importNode on a XUL node is not allowed.");
+      return node;
+    }
+
+    return target.importNode(node, deep);
+  };
+
 let RemoteAddonsParent = {
   init: function() {
     let mm = Cc["@mozilla.org/globalmessagemanager;1"].getService(Ci.nsIMessageListenerManager);
     mm.addMessageListener("Addons:RegisterGlobal", this);
 
     this.globalToBrowser = new WeakMap();
     this.browserToGlobal = new WeakMap();
   },
@@ -526,16 +546,17 @@ let RemoteAddonsParent = {
     let result = {};
 
     function register(tag, interp) {
       result[tag] = interp;
     }
 
     register("EventTarget", EventTargetInterposition);
     register("ContentDocShellTreeItem", ContentDocShellTreeItemInterposition);
+    register("ContentDocument", ContentDocumentInterposition);
 
     return result;
   },
 
   receiveMessage: function(msg) {
     switch (msg.name) {
     case "Addons:RegisterGlobal":
       this.browserToGlobal.set(msg.target, msg.objects.global);