зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1270349
part 1. Add IDL parser support for [LegacyUnenumerableNamedProperties]. r=peterv
This commit is contained in:
Родитель
5029f3d16a
Коммит
eb97fe75ff
|
@ -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.")
|
Загрузка…
Ссылка в новой задаче