mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 15:02:11 +00:00
Bug 986757: Defer firing OnNewGlobalObject until after the __URI__ property is set for JS Modules. r=bholley
This commit is contained in:
parent
880d646549
commit
980780332d
@ -646,6 +646,7 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
|
||||
nsCOMPtr<nsIXPConnect> xpc =
|
||||
do_GetService(kXPConnectServiceContractID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
bool createdNewGlobal = false;
|
||||
|
||||
if (!mLoaderGlobal) {
|
||||
nsRefPtr<BackstagePass> backstagePass;
|
||||
@ -655,13 +656,17 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
|
||||
CompartmentOptions options;
|
||||
options.setZone(SystemZone)
|
||||
.setVersion(JSVERSION_LATEST);
|
||||
// Defer firing OnNewGlobalObject until after the __URI__ property has
|
||||
// been defined so the JS debugger can tell what module the global is
|
||||
// for
|
||||
rv = xpc->InitClassesWithNewWrappedGlobal(aCx,
|
||||
static_cast<nsIGlobalObject *>(backstagePass),
|
||||
mSystemPrincipal,
|
||||
0,
|
||||
nsIXPConnect::DONT_FIRE_ONNEWGLOBALHOOK,
|
||||
options,
|
||||
getter_AddRefs(holder));
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
createdNewGlobal = true;
|
||||
|
||||
RootedObject global(aCx, holder->GetJSObject());
|
||||
NS_ENSURE_TRUE(global, nullptr);
|
||||
@ -734,6 +739,11 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (createdNewGlobal) {
|
||||
RootedObject global(aCx, holder->GetJSObject());
|
||||
JS_FireOnNewGlobalObject(aCx, global);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user