diff --git a/dom/base/ScriptSettings.cpp b/dom/base/ScriptSettings.cpp index fc16e21ab9d8..9dc20aca4f7d 100644 --- a/dom/base/ScriptSettings.cpp +++ b/dom/base/ScriptSettings.cpp @@ -357,6 +357,9 @@ AutoJSAPI::InitInternal(nsIGlobalObject* aGlobalObject, JSObject* aGlobal, // too. mAutoRequest.emplace(mCx); } + if (aGlobal) { + JS::ExposeObjectToActiveJS(aGlobal); + } mAutoNullableCompartment.emplace(mCx, aGlobal); ScriptSettingsStack::Push(this); diff --git a/dom/base/nsIGlobalObject.h b/dom/base/nsIGlobalObject.h index 1af3ad18a135..99ef97b05d4b 100644 --- a/dom/base/nsIGlobalObject.h +++ b/dom/base/nsIGlobalObject.h @@ -56,7 +56,8 @@ public: // GetGlobalJSObject may return a gray object. If this ever changes so that // it stops doing that, please simplify the code in FindAssociatedGlobal in // BindingUtils.h that does JS::ExposeObjectToActiveJS on the return value of - // GetGlobalJSObject. + // GetGlobalJSObject. Also, in that case the JS::ExposeObjectToActiveJS in + // AutoJSAPI::InitInternal can probably be removed. virtual JSObject* GetGlobalJSObject() = 0; // This method is not meant to be overridden.