Bug 1289129. When setting up an AutoJSAPI with a global, make sure to expose that global to active JS. r=mccr8

This commit is contained in:
Boris Zbarsky 2016-07-27 11:05:36 -04:00
Родитель 8617edc967
Коммит 3f84f0b441
2 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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.