Bug 1312690: Create content script sandboxes in same zone as content window. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Mon, 31 Oct 2016 12:46:39 -0700
changeset 432816 4e946e7685bcc7863a9aef8edb0d9bdd1cc296f5
parent 432815 79b8c08a8879f6ab0516222506e94f7bea4efe92
child 432817 0f1d3bad5005996f8e6edf3a27d1d214120b5976
push id34435
push usermaglione.k@gmail.com
push dateWed, 02 Nov 2016 20:58:46 +0000
reviewersaswan
bugs1312690
milestone52.0a1
Bug 1312690: Create content script sandboxes in same zone as content window. r?aswan MozReview-Commit-ID: K44jMuVfhz4
toolkit/components/extensions/ExtensionContent.jsm
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/extensions/ExtensionContent.jsm
@@ -320,31 +320,33 @@ class ExtensionContext extends BaseConte
         throw new Error("Invalid target window for this extension context");
       }
       // This is an iframe with content script API enabled and its principal should be the
       // contentWindow itself. (we create a sandbox with the contentWindow as principal and with X-rays disabled
       // because it enables us to create the APIs object in this sandbox object and then copying it
       // into the iframe's window, see Bug 1214658 for rationale)
       this.sandbox = Cu.Sandbox(contentWindow, {
         sandboxPrototype: contentWindow,
+        sameZoneAs: contentWindow,
         wantXrays: false,
         isWebExtensionContentScript: true,
       });
     } else {
       // This metadata is required by the Developer Tools, in order for
       // the content script to be associated with both the extension and
       // the tab holding the content page.
       let metadata = {
         "inner-window-id": this.innerWindowID,
         addonId: attrs.addonId,
       };
 
       this.sandbox = Cu.Sandbox(principal, {
         metadata,
         sandboxPrototype: contentWindow,
+        sameZoneAs: contentWindow,
         wantXrays: true,
         isWebExtensionContentScript: true,
         wantExportHelpers: true,
         wantGlobalProperties: ["XMLHttpRequest", "fetch"],
         originAttributes: attrs,
       });
 
       Cu.evalInSandbox(`