Bug 1270349 part 1. Add IDL parser support for [LegacyUnenumerableNamedProperties]. r=peterv

This commit is contained in:
Boris Zbarsky 2016-05-09 22:25:40 -04:00
Родитель 5029f3d16a
Коммит eb97fe75ff
2 изменённых файлов: 82 добавлений и 0 удалений

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

@ -1078,6 +1078,23 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
specialMembersSeen[memberType] = member
if self.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
# Check that we have a named getter.
if "named getters" not in specialMembersSeen:
raise WebIDLError(
"Interface with [LegacyUnenumerableNamedProperties] does "
"not have a named getter",
[self.location])
ancestor = self.parent
while ancestor:
if ancestor.getExtendedAttribute("LegacyUnenumerableNamedProperties"):
raise WebIDLError(
"Interface with [LegacyUnenumerableNamedProperties] "
"inherits from another interface with "
"[LegacyUnenumerableNamedProperties]",
[self.location, ancestor.location])
ancestor = ancestor.parent
if self._isOnGlobalProtoChain:
# Make sure we have no named setters, creators, or deleters
for memberType in ["setter", "creator", "deleter"]:
@ -1465,6 +1482,7 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
identifier == "UnsafeInPrerendering" or
identifier == "LegacyEventInit" or
identifier == "ProbablyShortLivingObject" or
identifier == "LegacyUnenumerableNamedProperties" or
identifier == "NonOrdinaryGetPrototypeOf"):
# Known extended attributes that do not take values
if not attr.noArguments():

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

@ -0,0 +1,64 @@
def WebIDLTest(parser, harness):
parser.parse(
"""
interface Foo {};
[LegacyUnenumerableNamedProperties]
interface Bar : Foo {
getter long(DOMString name);
};
interface Baz : Bar {
getter long(DOMString name);
};
""");
results = parser.finish();
harness.check(len(results), 3, "Should have three interfaces")
parser = parser.reset()
threw = False
try:
parser.parse("""
[LegacyUnenumerableNamedProperties]
interface NoNamedGetter {
};
""")
results = parser.finish()
except Exception, x:
threw = True
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""
[LegacyUnenumerableNamedProperties=Foo]
interface ShouldNotHaveArg {
getter long(DOMString name);
};
""")
results = parser.finish()
except Exception, x:
threw = True
harness.ok(threw, "Should have thrown.")
parser = parser.reset()
threw = False
try:
parser.parse("""
[LegacyUnenumerableNamedProperties]
interface Foo {
getter long(DOMString name);
};
interface Bar : Foo {};
[LegacyUnenumerableNamedProperties]
interface Baz : Bar {
getter long(DOMString name);
};
""")
results = parser.finish()
except Exception, x:
threw = True
harness.ok(threw, "Should have thrown.")