mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 23:12:21 +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 =
|
nsCOMPtr<nsIXPConnect> xpc =
|
||||||
do_GetService(kXPConnectServiceContractID, &rv);
|
do_GetService(kXPConnectServiceContractID, &rv);
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
|
bool createdNewGlobal = false;
|
||||||
|
|
||||||
if (!mLoaderGlobal) {
|
if (!mLoaderGlobal) {
|
||||||
nsRefPtr<BackstagePass> backstagePass;
|
nsRefPtr<BackstagePass> backstagePass;
|
||||||
@ -655,13 +656,17 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
|
|||||||
CompartmentOptions options;
|
CompartmentOptions options;
|
||||||
options.setZone(SystemZone)
|
options.setZone(SystemZone)
|
||||||
.setVersion(JSVERSION_LATEST);
|
.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,
|
rv = xpc->InitClassesWithNewWrappedGlobal(aCx,
|
||||||
static_cast<nsIGlobalObject *>(backstagePass),
|
static_cast<nsIGlobalObject *>(backstagePass),
|
||||||
mSystemPrincipal,
|
mSystemPrincipal,
|
||||||
0,
|
nsIXPConnect::DONT_FIRE_ONNEWGLOBALHOOK,
|
||||||
options,
|
options,
|
||||||
getter_AddRefs(holder));
|
getter_AddRefs(holder));
|
||||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||||
|
createdNewGlobal = true;
|
||||||
|
|
||||||
RootedObject global(aCx, holder->GetJSObject());
|
RootedObject global(aCx, holder->GetJSObject());
|
||||||
NS_ENSURE_TRUE(global, nullptr);
|
NS_ENSURE_TRUE(global, nullptr);
|
||||||
@ -734,6 +739,11 @@ mozJSComponentLoader::PrepareObjectForLocation(JSCLContextHelper& aCx,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (createdNewGlobal) {
|
||||||
|
RootedObject global(aCx, holder->GetJSObject());
|
||||||
|
JS_FireOnNewGlobalObject(aCx, global);
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user