Bug 1070696 - Implement a JSObject* override to AutoJSAPI::Init(). r=smaug

This commit is contained in:
Bobby Holley 2014-09-21 21:31:53 +02:00
parent e3eca2660e
commit be9e0c4e41
3 changed files with 11 additions and 1 deletions

View File

@ -302,6 +302,12 @@ AutoJSAPI::Init(nsIGlobalObject* aGlobalObject)
return Init(aGlobalObject, nsContentUtils::GetDefaultJSContextForThread());
}
bool
AutoJSAPI::Init(JSObject* aObject)
{
return Init(xpc::NativeGlobal(aObject));
}
bool
AutoJSAPI::InitWithLegacyErrorReporting(nsIGlobalObject* aGlobalObject)
{

View File

@ -214,6 +214,10 @@ public:
// false and use of cx() will cause an assertion.
bool Init(nsIGlobalObject* aGlobalObject);
// This is a helper that grabs the native global associated with aObject and
// invokes the above Init() with that.
bool Init(JSObject* aObject);
// Unsurprisingly, this uses aCx and enters the compartment of aGlobalObject.
// If aGlobalObject or its associated JS global are null then it returns
// false and use of cx() will cause an assertion.

View File

@ -1524,7 +1524,7 @@ SetAddonInterposition(const nsACString &addonIdStr, nsIAddonInterposition *inter
// We enter the junk scope just to allocate a string, which actually will go
// in the system zone.
AutoJSAPI jsapi;
jsapi.Init(xpc::NativeGlobal(xpc::PrivilegedJunkScope()));
jsapi.Init(xpc::PrivilegedJunkScope());
addonId = NewAddonId(jsapi.cx(), addonIdStr);
if (!addonId)
return false;