Bug 1472973 part 6 - Use JS::GetNonCCWObjectGlobal in subscript loader. r=bz

This commit is contained in:
Jan de Mooij
2018-07-06 18:16:24 +02:00
parent 70858719f4
commit 26b05ba65d

View File

@@ -186,6 +186,8 @@ EvalScript(JSContext* cx,
bool preloadCache,
MutableHandleScript script)
{
MOZ_ASSERT(!js::IsWrapper(targetObj));
if (JS_IsGlobalObject(targetObj)) {
if (!JS::CloneAndExecuteScript(cx, script, retval)) {
return false;
@@ -209,7 +211,7 @@ EvalScript(JSContext* cx,
// determine which JSM the target belongs to and have to assume it
// is in our JSM.
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
JSObject* targetGlobal = js::GetGlobalForObjectCrossCompartment(targetObj);
JSObject* targetGlobal = JS::GetNonCCWObjectGlobal(targetObj);
MOZ_DIAGNOSTIC_ASSERT(!mozJSComponentLoader::Get()->IsLoaderGlobal(targetGlobal),
"Don't load subscript into target in a shared-global JSM");
#endif
@@ -616,6 +618,9 @@ mozJSSubScriptLoader::DoLoadSubScriptWithOptions(const nsAString& url,
if (!targetObj || !loadScope)
return NS_ERROR_FAILURE;
MOZ_ASSERT(!js::IsWrapper(targetObj),
"JS_FindCompilationScope must unwrap");
if (js::GetObjectCompartment(loadScope) != js::GetObjectCompartment(targetObj))
loadScope = nullptr;