mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #9396 - psdh:fixwebidltests, r=Ms2ger
update tests for WebIDL.py from mozilla-central Fixes #9388 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9396) <!-- Reviewable:end -->
This commit is contained in:
commit
262974cb11
8 changed files with 156 additions and 29 deletions
|
@ -293,10 +293,49 @@ def WebIDLTest(parser, harness):
|
|||
try:
|
||||
parser.parse("""
|
||||
interface A {
|
||||
[SetterInfallible] readonly attribute boolean foo;
|
||||
[SetterThrows] readonly attribute boolean foo;
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
except Exception, x:
|
||||
threw = True
|
||||
harness.ok(threw, "Should not allow [SetterInfallible] on readonly attributes")
|
||||
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")
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
interface A {
|
||||
[SameObject] readonly attribute boolean foo;
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
except Exception, x:
|
||||
threw = True
|
||||
harness.ok(threw, "Should not allow [SameObject] on attributes not of interface type")
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
interface A {
|
||||
[SameObject] readonly attribute A foo;
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
except Exception, x:
|
||||
threw = True
|
||||
harness.ok(not threw, "Should allow [SameObject] on attributes of interface type")
|
||||
|
|
|
@ -11,8 +11,9 @@ def WebIDLTest(parser, harness):
|
|||
harness.check(argument.variadic, variadic, "Argument has the right variadic value")
|
||||
|
||||
def checkMethod(method, QName, name, signatures,
|
||||
static=False, getter=False, setter=False, creator=False,
|
||||
deleter=False, legacycaller=False, stringifier=False):
|
||||
static=True, getter=False, setter=False, creator=False,
|
||||
deleter=False, legacycaller=False, stringifier=False,
|
||||
chromeOnly=False):
|
||||
harness.ok(isinstance(method, WebIDL.IDLMethod),
|
||||
"Should be an IDLMethod")
|
||||
harness.ok(method.isMethod(), "Method is a method")
|
||||
|
@ -27,6 +28,7 @@ def WebIDLTest(parser, harness):
|
|||
harness.check(method.isDeleter(), deleter, "Method has the correct deleter value")
|
||||
harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value")
|
||||
harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value")
|
||||
harness.check(method.getExtendedAttribute("ChromeOnly") is not None, chromeOnly, "Method has the correct value for ChromeOnly")
|
||||
harness.check(len(method.signatures()), len(signatures), "Method has the correct number of signatures")
|
||||
|
||||
sigpairs = zip(method.signatures(), signatures)
|
||||
|
@ -55,11 +57,13 @@ def WebIDLTest(parser, harness):
|
|||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
harness.check(len(results), 3, "Should be two productions")
|
||||
harness.check(len(results), 3, "Should be three productions")
|
||||
harness.ok(isinstance(results[0], WebIDL.IDLInterface),
|
||||
"Should be an IDLInterface")
|
||||
harness.ok(isinstance(results[1], WebIDL.IDLInterface),
|
||||
"Should be an IDLInterface")
|
||||
harness.ok(isinstance(results[2], WebIDL.IDLInterface),
|
||||
"Should be an IDLInterface")
|
||||
|
||||
checkMethod(results[0].ctor(), "::TestConstructorNoArgs::constructor",
|
||||
"constructor", [("TestConstructorNoArgs (Wrapper)", [])])
|
||||
|
@ -73,3 +77,33 @@ def WebIDLTest(parser, harness):
|
|||
[("::TestConstructorOverloads::constructor::foo", "foo", "Object", False, False)]),
|
||||
("TestConstructorOverloads (Wrapper)",
|
||||
[("::TestConstructorOverloads::constructor::bar", "bar", "Boolean", False, False)])])
|
||||
|
||||
parser = parser.reset()
|
||||
parser.parse("""
|
||||
[ChromeConstructor()]
|
||||
interface TestChromeConstructor {
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
harness.check(len(results), 1, "Should be one production")
|
||||
harness.ok(isinstance(results[0], WebIDL.IDLInterface),
|
||||
"Should be an IDLInterface")
|
||||
|
||||
checkMethod(results[0].ctor(), "::TestChromeConstructor::constructor",
|
||||
"constructor", [("TestChromeConstructor (Wrapper)", [])],
|
||||
chromeOnly=True)
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
[Constructor(),
|
||||
ChromeConstructor(DOMString a)]
|
||||
interface TestChromeConstructor {
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Can't have both a Constructor and a ChromeConstructor")
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
""")
|
||||
|
||||
|
|
|
@ -39,28 +39,27 @@ def WebIDLTest(parser, harness):
|
|||
attribute DOMString? b;
|
||||
};
|
||||
|
||||
/* Not implemented. */
|
||||
/*interface TestNullableEquivalency8 {
|
||||
interface TestNullableEquivalency8 {
|
||||
attribute float a;
|
||||
attribute float? b;
|
||||
};*/
|
||||
};
|
||||
|
||||
interface TestNullableEquivalency8 {
|
||||
interface TestNullableEquivalency9 {
|
||||
attribute double a;
|
||||
attribute double? b;
|
||||
};
|
||||
|
||||
interface TestNullableEquivalency9 {
|
||||
interface TestNullableEquivalency10 {
|
||||
attribute object a;
|
||||
attribute object? b;
|
||||
};
|
||||
|
||||
interface TestNullableEquivalency10 {
|
||||
interface TestNullableEquivalency11 {
|
||||
attribute double[] a;
|
||||
attribute double[]? b;
|
||||
};
|
||||
|
||||
interface TestNullableEquivalency11 {
|
||||
interface TestNullableEquivalency12 {
|
||||
attribute TestNullableEquivalency9[] a;
|
||||
attribute TestNullableEquivalency9[]? b;
|
||||
};
|
||||
|
@ -91,7 +90,7 @@ def checkEquivalent(iface, harness):
|
|||
for attr in dir(type1):
|
||||
if attr.startswith('_') or \
|
||||
attr in ['nullable', 'builtin', 'filename', 'location',
|
||||
'inner', 'QName'] or \
|
||||
'inner', 'QName', 'getDeps', 'name'] or \
|
||||
(hasattr(type(type1), attr) and not callable(getattr(type1, attr))):
|
||||
continue
|
||||
|
||||
|
|
|
@ -11,4 +11,20 @@ def WebIDLTest(parser, harness):
|
|||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should have thrown.")
|
||||
harness.ok(not threw,
|
||||
"Should not have thrown on non-optional argument following "
|
||||
"optional argument.")
|
||||
|
||||
parser = parser.reset()
|
||||
parser.parse("""
|
||||
interface OptionalConstraints2 {
|
||||
void foo(optional byte arg1 = 1, optional byte arg2 = 2,
|
||||
optional byte arg3, optional byte arg4 = 4,
|
||||
optional byte arg5, optional byte arg6 = 9);
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
args = results[0].members[0].signatures()[0][1]
|
||||
harness.check(len(args), 6, "Should have 6 arguments")
|
||||
harness.check(args[5].defaultValue.value, 9,
|
||||
"Should have correct default value")
|
||||
|
|
|
@ -2,11 +2,11 @@ import WebIDL
|
|||
|
||||
def WebIDLTest(parser, harness):
|
||||
parser.parse("""
|
||||
callback Function = any(any... arguments);
|
||||
[TreatNonCallableAsNull] callback Function = any(any... arguments);
|
||||
|
||||
interface TestTreatNonCallableAsNull1 {
|
||||
[TreatNonCallableAsNull] attribute Function? onfoo;
|
||||
attribute Function? onbar;
|
||||
attribute Function? onfoo;
|
||||
attribute Function onbar;
|
||||
};
|
||||
""")
|
||||
|
||||
|
@ -54,3 +54,18 @@ def WebIDLTest(parser, harness):
|
|||
threw = True
|
||||
|
||||
harness.ok(threw, "Should have thrown.")
|
||||
|
||||
parser = parser.reset()
|
||||
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
[TreatNonCallableAsNull, TreatNonObjectAsNull]
|
||||
callback Function = any(any... arguments);
|
||||
""")
|
||||
|
||||
results = parser.finish()
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should have thrown.")
|
||||
|
|
|
@ -12,7 +12,7 @@ def WebIDLTest(parser, harness):
|
|||
|
||||
results = parser.finish()
|
||||
|
||||
harness.check(results[2].members[1].type.name, "Long",
|
||||
harness.check(results[2].members[1].type.name, "LongOrNull",
|
||||
"Should expand typedefs")
|
||||
|
||||
parser = parser.reset()
|
||||
|
|
|
@ -1,39 +1,63 @@
|
|||
def WebIDLTest(parser, harness):
|
||||
threw = False
|
||||
try:
|
||||
results = parser.parse("""
|
||||
parser.parse("""
|
||||
interface VariadicConstraints1 {
|
||||
void foo(byte... arg1, byte arg2);
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should have thrown.")
|
||||
harness.ok(threw,
|
||||
"Should have thrown on variadic argument followed by required "
|
||||
"argument.")
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
results = parser.parse("""
|
||||
parser.parse("""
|
||||
interface VariadicConstraints2 {
|
||||
void foo(byte... arg1, optional byte arg2);
|
||||
};
|
||||
""")
|
||||
|
||||
results = parser.finish();
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should have thrown.")
|
||||
harness.ok(threw,
|
||||
"Should have thrown on variadic argument followed by optional "
|
||||
"argument.")
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
results = parser.parse("""
|
||||
parser.parse("""
|
||||
interface VariadicConstraints3 {
|
||||
void foo(optional byte... arg1);
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should have thrown.")
|
||||
harness.ok(threw,
|
||||
"Should have thrown on variadic argument explicitly flagged as "
|
||||
"optional.")
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
interface VariadicConstraints4 {
|
||||
void foo(byte... arg1 = 0);
|
||||
};
|
||||
""")
|
||||
results = parser.finish()
|
||||
except:
|
||||
threw = True
|
||||
|
||||
harness.ok(threw, "Should have thrown on variadic argument with default value.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue