mirror of
https://github.com/classilla/tenfourfox.git
synced 2025-08-11 09:25:47 +00:00
#410: M1363963
This commit is contained in:
@@ -965,7 +965,7 @@ XrayTraits::expandoObjectMatchesConsumer(JSContext* cx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
XrayTraits::getExpandoObjectInternal(JSContext* cx, HandleObject target,
|
XrayTraits::getExpandoObjectInternal(JSContext* cx, JSObject* expandoChain,
|
||||||
nsIPrincipal* origin,
|
nsIPrincipal* origin,
|
||||||
JSObject* exclusiveGlobalArg,
|
JSObject* exclusiveGlobalArg,
|
||||||
MutableHandleObject expandoObject)
|
MutableHandleObject expandoObject)
|
||||||
@@ -976,12 +976,12 @@ XrayTraits::getExpandoObjectInternal(JSContext* cx, HandleObject target,
|
|||||||
// The expando object lives in the compartment of the target, so all our
|
// The expando object lives in the compartment of the target, so all our
|
||||||
// work needs to happen there.
|
// work needs to happen there.
|
||||||
RootedObject exclusiveGlobal(cx, exclusiveGlobalArg);
|
RootedObject exclusiveGlobal(cx, exclusiveGlobalArg);
|
||||||
JSAutoCompartment ac(cx, target);
|
RootedObject head(cx, expandoChain);
|
||||||
|
JSAutoCompartment ac(cx, head);
|
||||||
if (!JS_WrapObject(cx, &exclusiveGlobal))
|
if (!JS_WrapObject(cx, &exclusiveGlobal))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Iterate through the chain, looking for a same-origin object.
|
// Iterate through the chain, looking for a same-origin object.
|
||||||
RootedObject head(cx, getExpandoChain(target));
|
|
||||||
while (head) {
|
while (head) {
|
||||||
if (expandoObjectMatchesConsumer(cx, head, origin, exclusiveGlobal)) {
|
if (expandoObjectMatchesConsumer(cx, head, origin, exclusiveGlobal)) {
|
||||||
expandoObject.set(head);
|
expandoObject.set(head);
|
||||||
@@ -998,9 +998,15 @@ bool
|
|||||||
XrayTraits::getExpandoObject(JSContext* cx, HandleObject target, HandleObject consumer,
|
XrayTraits::getExpandoObject(JSContext* cx, HandleObject target, HandleObject consumer,
|
||||||
MutableHandleObject expandoObject)
|
MutableHandleObject expandoObject)
|
||||||
{
|
{
|
||||||
|
// Return early if no expando object has ever been attached, which is
|
||||||
|
// usually the case.
|
||||||
|
JSObject* chain = getExpandoChain(target);
|
||||||
|
if (!chain)
|
||||||
|
return true;
|
||||||
|
|
||||||
JSObject* consumerGlobal = js::GetGlobalForObjectCrossCompartment(consumer);
|
JSObject* consumerGlobal = js::GetGlobalForObjectCrossCompartment(consumer);
|
||||||
bool isSandbox = !strcmp(js::GetObjectJSClass(consumerGlobal)->name, "Sandbox");
|
bool isSandbox = !strcmp(js::GetObjectJSClass(consumerGlobal)->name, "Sandbox");
|
||||||
return getExpandoObjectInternal(cx, target, ObjectPrincipal(consumer),
|
return getExpandoObjectInternal(cx, chain, ObjectPrincipal(consumer),
|
||||||
isSandbox ? consumerGlobal : nullptr,
|
isSandbox ? consumerGlobal : nullptr,
|
||||||
expandoObject);
|
expandoObject);
|
||||||
}
|
}
|
||||||
@@ -1016,11 +1022,14 @@ XrayTraits::attachExpandoObject(JSContext* cx, HandleObject target,
|
|||||||
// No duplicates allowed.
|
// No duplicates allowed.
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{
|
{
|
||||||
RootedObject existingExpandoObject(cx);
|
JSObject* chain = getExpandoChain(target);
|
||||||
if (getExpandoObjectInternal(cx, target, origin, exclusiveGlobal, &existingExpandoObject))
|
if (chain) {
|
||||||
MOZ_ASSERT(!existingExpandoObject);
|
RootedObject existingExpandoObject(cx);
|
||||||
else
|
if (getExpandoObjectInternal(cx, chain, origin, exclusiveGlobal, &existingExpandoObject))
|
||||||
JS_ClearPendingException(cx);
|
MOZ_ASSERT(!existingExpandoObject);
|
||||||
|
else
|
||||||
|
JS_ClearPendingException(cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -106,7 +106,7 @@ private:
|
|||||||
bool expandoObjectMatchesConsumer(JSContext* cx, JS::HandleObject expandoObject,
|
bool expandoObjectMatchesConsumer(JSContext* cx, JS::HandleObject expandoObject,
|
||||||
nsIPrincipal* consumerOrigin,
|
nsIPrincipal* consumerOrigin,
|
||||||
JS::HandleObject exclusiveGlobal);
|
JS::HandleObject exclusiveGlobal);
|
||||||
bool getExpandoObjectInternal(JSContext* cx, JS::HandleObject target,
|
bool getExpandoObjectInternal(JSContext* cx, JSObject* expandoChain,
|
||||||
nsIPrincipal* origin, JSObject* exclusiveGlobal,
|
nsIPrincipal* origin, JSObject* exclusiveGlobal,
|
||||||
JS::MutableHandleObject expandoObject);
|
JS::MutableHandleObject expandoObject);
|
||||||
JSObject* attachExpandoObject(JSContext* cx, JS::HandleObject target,
|
JSObject* attachExpandoObject(JSContext* cx, JS::HandleObject target,
|
||||||
|
Reference in New Issue
Block a user