Bug 1512417 - Pass |this| as second argument to Cu.import calls in Promise-backend.js to fix an issue with same-compartment realms. r=kmag
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 06 Dec 2018 21:59:09 +0000
changeset 508838 52d8651b683dfcf944e72114a8a41878ce7d6c15
parent 508837 ae37561c3bf7cc9b83c4f5aad5cf4e28ed2e332c
child 508839 2f5d2cc76b6b3f1c882c0211c95291e487953e29
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1512417
milestone65.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 1512417 - Pass |this| as second argument to Cu.import calls in Promise-backend.js to fix an issue with same-compartment realms. r=kmag With same-compartment-realms, the Cu.import native is a cross-realm function so we switch to its realm and ended up defining things on the wrong global. Differential Revision: https://phabricator.services.mozilla.com/D13905
toolkit/modules/Promise-backend.js
--- a/toolkit/modules/Promise-backend.js
+++ b/toolkit/modules/Promise-backend.js
@@ -55,18 +55,18 @@ var Ci = this.require ? require("chrome"
 // parent stack trace; see scheduleWalkerLoop.  However, as it might
 // not be available (see above), users of this must check it first.
 var Components_ = this.require ? require("chrome").components : Components;
 
 // If Cu is defined, use it to lazily define the FinalizationWitnessService.
 if (Cu) {
   // If we're in a devtools module environment, ChromeUtils won't exist.
   /* eslint "mozilla/use-chromeutils-import": ["error", {allowCu: true}] */
-  Cu.import("resource://gre/modules/Services.jsm");
-  Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+  Cu.import("resource://gre/modules/Services.jsm", this);
+  Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 
   XPCOMUtils.defineLazyServiceGetter(this, "FinalizationWitnessService",
                                      "@mozilla.org/toolkit/finalizationwitness;1",
                                      "nsIFinalizationWitnessService");
 
   // For now, we're worried about add-ons using Promises with CPOWs, so we'll
   // permit them in this scope, but this support will go away soon.
   Cu.permitCPOWsInScope(this);