Bug 1514261. Skip messing around with compartments in FunctionForwarder if the forwarder is already same-compartment with the underlying callee. r=bholley

This commit is contained in:
Boris Zbarsky
2018-12-16 00:13:53 -05:00
parent 848ce2f777
commit e14a575f16

View File

@@ -296,16 +296,20 @@ static bool FunctionForwarder(JSContext* cx, unsigned argc, Value* vp) {
// here, because certain function wrappers (notably content->nsEP) are
// not callable.
JSAutoRealm ar(cx, unwrappedFun);
if (!CheckSameOriginArg(cx, options, thisVal) ||
!JS_WrapValue(cx, &thisVal)) {
return false;
}
for (size_t n = 0; n < args.length(); ++n) {
if (!CheckSameOriginArg(cx, options, args[n]) ||
!JS_WrapValue(cx, args[n])) {
bool crossCompartment = js::GetObjectCompartment(unwrappedFun) !=
js::GetObjectCompartment(&args.callee());
if (crossCompartment) {
if (!CheckSameOriginArg(cx, options, thisVal) ||
!JS_WrapValue(cx, &thisVal)) {
return false;
}
for (size_t n = 0; n < args.length(); ++n) {
if (!CheckSameOriginArg(cx, options, args[n]) ||
!JS_WrapValue(cx, args[n])) {
return false;
}
}
}
RootedValue fval(cx, ObjectValue(*unwrappedFun));