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,6 +296,9 @@ static bool FunctionForwarder(JSContext* cx, unsigned argc, Value* vp) {
// here, because certain function wrappers (notably content->nsEP) are // here, because certain function wrappers (notably content->nsEP) are
// not callable. // not callable.
JSAutoRealm ar(cx, unwrappedFun); JSAutoRealm ar(cx, unwrappedFun);
bool crossCompartment = js::GetObjectCompartment(unwrappedFun) !=
js::GetObjectCompartment(&args.callee());
if (crossCompartment) {
if (!CheckSameOriginArg(cx, options, thisVal) || if (!CheckSameOriginArg(cx, options, thisVal) ||
!JS_WrapValue(cx, &thisVal)) { !JS_WrapValue(cx, &thisVal)) {
return false; return false;
@@ -307,6 +310,7 @@ static bool FunctionForwarder(JSContext* cx, unsigned argc, Value* vp) {
return false; return false;
} }
} }
}
RootedValue fval(cx, ObjectValue(*unwrappedFun)); RootedValue fval(cx, ObjectValue(*unwrappedFun));
if (args.isConstructing()) { if (args.isConstructing()) {