Bug 1197507 - [webext] Alias browser.* and chrome.* (r=gabor)
authorBill McCloskey <billm@mozilla.com>
Sat, 22 Aug 2015 10:31:42 -0700
changeset 259331 faa9493e9372ad925256eebaf01096a055b3a2e4
parent 259330 49dbd2c38b9e96f9b3e24a2da8a0aa4bb5184e20
child 259332 1706813276e7b1c1c1858eda8ae0f40402e9b237
push id64205
push userwmccloskey@mozilla.com
push dateTue, 25 Aug 2015 22:14:26 +0000
treeherdermozilla-inbound@91e5acc46643 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs1197507
milestone43.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 1197507 - [webext] Alias browser.* and chrome.* (r=gabor)
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/ExtensionContent.jsm
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -254,17 +254,18 @@ let GlobalManager = {
   },
 
   injectInDocShell(docShell, extension, context) {
     this.docShells.set(docShell, {extension, context});
   },
 
   observe(contentWindow, topic, data) {
     function inject(extension, context) {
-      let chromeObj = Cu.createObjectIn(contentWindow, {defineAs: "chrome"});
+      let chromeObj = Cu.createObjectIn(contentWindow, {defineAs: "browser"});
+      contentWindow.wrappedJSObject.chrome = contentWindow.wrappedJSObject.browser;
       let api = Management.generateAPIs(extension, context);
       injectAPI(api, chromeObj);
     }
 
     let docShell = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                                 .getInterface(Ci.nsIWebNavigation)
                                 .QueryInterface(Ci.nsIDocShellTreeItem)
                                 .sameTypeRootTreeItem
--- a/toolkit/components/extensions/ExtensionContent.jsm
+++ b/toolkit/components/extensions/ExtensionContent.jsm
@@ -216,17 +216,18 @@ function ExtensionContext(extensionId, c
     }
   };
 
   let url = contentWindow.location.href;
   let broker = ExtensionContent.getBroker(mm);
   this.messenger = new Messenger(this, broker, {id: extensionId, frameId, url},
                                  {id: extensionId, frameId}, delegate);
 
-  let chromeObj = Cu.createObjectIn(this.sandbox, {defineAs: "chrome"});
+  let chromeObj = Cu.createObjectIn(this.sandbox, {defineAs: "browser"});
+  this.sandbox.wrappedJSObject.chrome = this.sandbox.wrappedJSObject.browser;
   injectAPI(api(this), chromeObj);
 
   this.onClose = new Set();
 }
 
 ExtensionContext.prototype = {
   get cloneScope() {
     return this.sandbox;