Bug 859503. Make unknown extended attributes into parse errors. r=khuey

This commit is contained in:
Boris Zbarsky 2013-04-10 13:49:06 -04:00
parent 8ad22459f8
commit 2d6c54904c
6 changed files with 81 additions and 5 deletions

View File

@ -894,6 +894,15 @@ class IDLInterface(IDLObjectWithScope):
elif not newMethod in self.namedConstructors:
raise WebIDLError("NamedConstructor conflicts with a NamedConstructor of a different interface",
[method.location, newMethod.location])
elif (identifier == "PrefControlled" or
identifier == "Pref" or
identifier == "NeedNewResolve" or
identifier == "JSImplementation"):
# Known attributes that we don't need to do anything with here
pass
else:
raise WebIDLError("Unknown extended attribute %s" % identifier,
[attr.location])
attrlist = attr.listValue()
self._extendedAttrDict[identifier] = attrlist if len(attrlist) else True
@ -2486,6 +2495,20 @@ class IDLAttribute(IDLInterfaceMember):
raise WebIDLError("[LenientFloat] used on an attribute with a "
"non-restricted-float type",
[attr.location, self.location])
elif (identifier == "Pref" or
identifier == "SetterThrows" or
identifier == "Pure" or
identifier == "Throws" or
identifier == "GetterThrows" or
identifier == "ChromeOnly" or
identifier == "Constant" or
identifier == "Func" or
identifier == "Creator"):
# Known attributes that we don't need to do anything with here
pass
else:
raise WebIDLError("Unknown extended attribute %s" % identifier,
[attr.location])
IDLInterfaceMember.handleExtendedAttribute(self, attr)
def resolve(self, parentScope):
@ -3019,6 +3042,17 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
raise WebIDLError("[LenientFloat] used on an operation with no "
"restricted float type arguments",
[attr.location, self.location])
elif (identifier == "Throws" or
identifier == "Creator" or
identifier == "ChromeOnly" or
identifier == "Pref" or
identifier == "Func" or
identifier == "WebGLHandlesContextLoss"):
# Known attributes that we don't need to do anything with here
pass
else:
raise WebIDLError("Unknown extended attribute %s" % identifier,
[attr.location])
IDLInterfaceMember.handleExtendedAttribute(self, attr)
def _getDependentObjects(self):

View File

@ -300,3 +300,16 @@ def WebIDLTest(parser, harness):
except Exception, x:
threw = True
harness.ok(threw, "Should not allow [SetterThrows] on readonly attributes")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface A {
[Throw] readonly attribute boolean foo;
};
""")
results = parser.finish()
except Exception, x:
threw = True
harness.ok(threw, "Should spell [Throws] correctly")

View File

@ -2,9 +2,9 @@ import WebIDL
def WebIDLTest(parser, harness):
parser.parse("""
[Flippety]
[NoInterfaceObject]
interface TestExtendedAttr {
[Foopy] attribute byte b;
[Unforgeable] readonly attribute byte b;
};
""")
@ -12,9 +12,9 @@ def WebIDLTest(parser, harness):
parser = parser.reset()
parser.parse("""
[Flippety="foo.bar",Floppety=flop]
[Pref="foo.bar",Pref=flop]
interface TestExtendedAttr {
[Foopy="foo.bar"] attribute byte b;
[Pref="foo.bar"] attribute byte b;
};
""")

View File

@ -317,3 +317,17 @@ def WebIDLTest(parser, harness):
"Should not allow a name collision between interface "
"and other object")
parser = parser.reset()
threw = False
try:
parser.parse("""
[SomeRandomAnnotation]
interface A {
readonly attribute boolean y;
};
""")
results = parser.finish()
except:
threw = True
harness.ok(threw,
"Should not allow unknown extended attributes on interfaces")

View File

@ -156,3 +156,16 @@ def WebIDLTest(parser, harness):
except Exception, x:
threw = True
harness.ok(threw, "Should not allow [SetterThrows] on methods")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface A {
[Throw] void foo();
};
""")
results = parser.finish()
except Exception, x:
threw = True
harness.ok(threw, "Should spell [Throws] correctly on methods")

View File

@ -11,7 +11,9 @@
* and create derivative works of this document.
*/
[Unforgeable] interface Location {
// No support for [Unforgeable] on interfaces yet
//[Unforgeable]
interface Location {
stringifier attribute DOMString href;
void assign(DOMString url);
void replace(DOMString url);