Bug 1585684. Fix error message for permission failures when passing a union member. r=peterv

The new error message is still not great, but it's a lot better than having %s
as the description of what's going on.

Differential Revision: https://phabricator.services.mozilla.com/D47915

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-10-09 09:22:05 +00:00
Родитель babdf3507e
Коммит 9c62fd6061
1 изменённых файлов: 8 добавлений и 4 удалений

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

@ -10244,11 +10244,13 @@ def getUnionTypeTemplateVars(unionType, type, descriptorProvider,
"tryNext = true;\n"
"return true;\n" % (prefix, name))
sourceDescription = "member of %s" % unionType
conversionInfo = getJSToNativeConversionInfo(
type, descriptorProvider, failureCode=tryNextCode,
isDefinitelyObject=not type.isDictionary(),
isMember=("OwningUnion" if ownsMembers else None),
sourceDescription="member of %s" % unionType)
sourceDescription=sourceDescription)
if conversionInfo.holderType is not None:
assert not ownsMembers
@ -10279,13 +10281,15 @@ def getUnionTypeTemplateVars(unionType, type, descriptorProvider,
# It's a bit sketchy to do the security check after setting the value,
# but it keeps the code cleaner and lets us avoid rooting |obj| over the
# call to CallerSubsumes().
body = body + dedent("""
body = body + fill(
"""
if (passedToJSImpl && !CallerSubsumes(obj)) {
ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "${sourceDescription}");
return false;
}
return true;
""")
""",
sourceDescription=sourceDescription)
setter = ClassMethod("SetToObject", "bool",
[Argument("JSContext*", "cx"),