Bug 1477989 part 2 - Use JS::GetNonCCWObjectGlobal in nsXBLBinding::DoInitJSClass. r=bz

This commit is contained in:
Jan de Mooij 2018-07-26 10:52:41 +02:00
Родитель b1f2f847f1
Коммит 99c47ba5c5
2 изменённых файлов: 5 добавлений и 1 удалений

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

@ -958,7 +958,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx,
// and defining it as a property on the XBL scope's global. This works fine, // and defining it as a property on the XBL scope's global. This works fine,
// but we need to make sure never to assume that the the reflector and // but we need to make sure never to assume that the the reflector and
// prototype are same-compartment with the bound document. // prototype are same-compartment with the bound document.
JS::Rooted<JSObject*> global(cx, js::GetGlobalForObjectCrossCompartment(obj)); JS::Rooted<JSObject*> global(cx, JS::GetNonCCWObjectGlobal(obj));
// We never store class objects in add-on scopes. // We never store class objects in add-on scopes.
JS::Rooted<JSObject*> xblScope(cx, xpc::GetXBLScopeOrGlobal(cx, global)); JS::Rooted<JSObject*> xblScope(cx, xpc::GetXBLScopeOrGlobal(cx, global));

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

@ -218,6 +218,10 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
JS::Rooted<JSObject*> value(cx, &v.toObject()); JS::Rooted<JSObject*> value(cx, &v.toObject());
JSAutoRealm ar2(cx, value); JSAutoRealm ar2(cx, value);
// We passed aAllowWrapping = false to nsContentUtils::WrapNative so we
// should not have a wrapper.
MOZ_ASSERT(!js::IsWrapper(value));
// All of the above code was just obtaining the bound element's script object and its immediate // All of the above code was just obtaining the bound element's script object and its immediate
// concrete base class. We need to alter the object so that our concrete class is interposed // concrete base class. We need to alter the object so that our concrete class is interposed
// between the object and its base class. We become the new base class of the object, and the // between the object and its base class. We become the new base class of the object, and the