mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 768190. Don't allow [TreatNullAs] or [TreatUndefinedAs] on dictionary members. r=jlebar
This commit is contained in:
parent
7f6400efa5
commit
7d734037c4
@ -1859,7 +1859,7 @@ class IDLAttribute(IDLInterfaceMember):
|
||||
IDLObjectWithIdentifier.resolve(self, parentScope)
|
||||
|
||||
class IDLArgument(IDLObjectWithIdentifier):
|
||||
def __init__(self, location, identifier, type, optional=False, defaultValue=None, variadic=False):
|
||||
def __init__(self, location, identifier, type, optional=False, defaultValue=None, variadic=False, dictionaryMember=False):
|
||||
IDLObjectWithIdentifier.__init__(self, location, None, identifier)
|
||||
|
||||
assert isinstance(type, IDLType)
|
||||
@ -1872,10 +1872,21 @@ class IDLArgument(IDLObjectWithIdentifier):
|
||||
self.optional = optional
|
||||
self.defaultValue = defaultValue
|
||||
self.variadic = variadic
|
||||
self.dictionaryMember = dictionaryMember
|
||||
|
||||
assert not variadic or optional
|
||||
|
||||
def addExtendedAttributes(self, attrs):
|
||||
if self.dictionaryMember:
|
||||
for (attr, value) in attrs:
|
||||
if attr == "TreatUndefinedAs":
|
||||
raise WebIDLError("[TreatUndefinedAs] is not allowed for "
|
||||
"dictionary members", [self.location])
|
||||
elif attr == "TreatNullAs":
|
||||
raise WebIDLError("[TreatNullAs] is not allowed for "
|
||||
"dictionary members", [self.location])
|
||||
|
||||
# But actually, we can't handle this at all, so far.
|
||||
assert len(attrs) == 0
|
||||
|
||||
class IDLCallbackType(IDLType, IDLObjectWithScope):
|
||||
@ -2535,7 +2546,8 @@ class Parser(Tokenizer):
|
||||
defaultValue = p[3]
|
||||
|
||||
p[0] = IDLArgument(self.getLocation(p, 2), identifier, t, optional=True,
|
||||
defaultValue=defaultValue, variadic=False)
|
||||
defaultValue=defaultValue, variadic=False,
|
||||
dictionaryMember=True)
|
||||
|
||||
def p_DefaultValue(self, p):
|
||||
"""
|
||||
|
@ -93,3 +93,31 @@ def WebIDLTest(parser, harness):
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should not allow cycles in dictionary inheritance chains")
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
dictionary A {
|
||||
[TreatNullAs=EmptyString] DOMString foo;
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should not allow [TreatNullAs] on dictionary members");
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
dictionary A {
|
||||
[TreatUndefinedAs=EmptyString] DOMString foo;
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should not allow [TreatUndefinedAs] on dictionary members");
|
||||
|
Loading…
Reference in New Issue
Block a user