Bug 986757: Defer firing OnNewGlobalObject until after the __URI__ property is set for JS Modules. r=bholley

This commit is contained in:
Dave Townsend 2014-03-25 16:33:06 -07:00
parent 880d646549
commit 980780332d

View File

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