Bug 1525673. Don't assume that same-compartment means same-realm in WrapNewBindingNonWrapperCache. r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D18863

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-02-11 13:33:23 +00:00
Родитель f888b4bd3d
Коммит afcd9842ec
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -1171,8 +1171,14 @@ inline bool WrapNewBindingNonWrapperCachedObject(
if (!JS_WrapObject(cx, &proto)) {
return false;
}
} else {
// cx and scope are same-compartment, but they might still be
// different-Realm. Enter the Realm of scope, since that's
// where we want to create our object.
ar.emplace(cx, scope);
}
MOZ_ASSERT_IF(proto, js::IsObjectInContextCompartment(proto, cx));
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
if (!value->WrapObject(cx, proto, &obj)) {
return false;
@ -1223,8 +1229,14 @@ inline bool WrapNewBindingNonWrapperCachedObject(
if (!JS_WrapObject(cx, &proto)) {
return false;
}
} else {
// cx and scope are same-compartment, but they might still be
// different-Realm. Enter the Realm of scope, since that's
// where we want to create our object.
ar.emplace(cx, scope);
}
MOZ_ASSERT_IF(proto, js::IsObjectInContextCompartment(proto, cx));
MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
if (!value->WrapObject(cx, proto, &obj)) {
return false;