Bug 1107953 part 2. Change codegen to output an aCompartment argument on all callbacks that have an aExceptionHandling argument. r=peterv

This commit is contained in:
Boris Zbarsky 2015-01-15 17:39:02 -05:00
parent 318b2f3458
commit 3fe6ab7f53

View File

@ -13642,6 +13642,12 @@ class CGCallback(CGClass):
# CallSetup should re-throw exceptions on aRv.
args.append(Argument("ExceptionHandling", "aExceptionHandling",
"eReportExceptions"))
# And the argument for communicating when exceptions should really be
# rethrown. In particular, even when aExceptionHandling is
# eRethrowExceptions they won't get rethrown if aCompartment is provided
# and its principal doesn't subsume either the callback or the
# exception.
args.append(Argument("JSCompartment*", "aCompartment", "nullptr"))
# And now insert our template argument.
argsWithoutThis = list(args)
args.insert(0, Argument("const T&", "thisObjPtr"))
@ -13649,7 +13655,7 @@ class CGCallback(CGClass):
setupCall = fill(
"""
CallSetup s(this, aRv, aExceptionHandling);
CallSetup s(this, aRv, aExceptionHandling, aCompartment);
if (!s.GetContext()) {
aRv.Throw(NS_ERROR_UNEXPECTED);
return${errorReturn};
@ -13961,11 +13967,10 @@ class CallbackMember(CGNativeMember):
if not self.needThisHandling:
# Since we don't need this handling, we're the actual method that
# will be called, so we need an aRethrowExceptions argument.
if self.rethrowContentException:
args.append(Argument("JSCompartment*", "aCompartment", "nullptr"))
else:
if not self.rethrowContentException:
args.append(Argument("ExceptionHandling", "aExceptionHandling",
"eReportExceptions"))
args.append(Argument("JSCompartment*", "aCompartment", "nullptr"))
return args
# We want to allow the caller to pass in a "this" value, as
# well as a JSContext.
@ -13983,7 +13988,7 @@ class CallbackMember(CGNativeMember):
callSetup += ", eRethrowContentExceptions, aCompartment, /* aIsJSImplementedWebIDL = */ "
callSetup += toStringBool(isJSImplementedDescriptor(self.descriptorProvider))
else:
callSetup += ", aExceptionHandling"
callSetup += ", aExceptionHandling, aCompartment"
callSetup += ");\n"
return fill(
"""