mirror of
https://github.com/servo/servo
synced 2026-04-28 18:37:39 +02:00
Update WebIDL
This commit is contained in:
@@ -1,31 +1,35 @@
|
||||
import WebIDL
|
||||
|
||||
def WebIDLTest(parser, harness):
|
||||
testData = [("::TestAttr%s::b", "b", "Byte%s", False),
|
||||
("::TestAttr%s::rb", "rb", "Byte%s", True),
|
||||
("::TestAttr%s::o", "o", "Octet%s", False),
|
||||
("::TestAttr%s::ro", "ro", "Octet%s", True),
|
||||
("::TestAttr%s::s", "s", "Short%s", False),
|
||||
("::TestAttr%s::rs", "rs", "Short%s", True),
|
||||
("::TestAttr%s::us", "us", "UnsignedShort%s", False),
|
||||
("::TestAttr%s::rus", "rus", "UnsignedShort%s", True),
|
||||
("::TestAttr%s::l", "l", "Long%s", False),
|
||||
("::TestAttr%s::rl", "rl", "Long%s", True),
|
||||
("::TestAttr%s::ul", "ul", "UnsignedLong%s", False),
|
||||
("::TestAttr%s::rul", "rul", "UnsignedLong%s", True),
|
||||
("::TestAttr%s::ll", "ll", "LongLong%s", False),
|
||||
("::TestAttr%s::rll", "rll", "LongLong%s", True),
|
||||
("::TestAttr%s::ull", "ull", "UnsignedLongLong%s", False),
|
||||
("::TestAttr%s::rull", "rull", "UnsignedLongLong%s", True),
|
||||
("::TestAttr%s::str", "str", "String%s", False),
|
||||
("::TestAttr%s::rstr", "rstr", "String%s", True),
|
||||
("::TestAttr%s::obj", "obj", "Object%s", False),
|
||||
("::TestAttr%s::robj", "robj", "Object%s", True),
|
||||
("::TestAttr%s::object", "object", "Object%s", False),
|
||||
("::TestAttr%s::f", "f", "Float%s", False),
|
||||
("::TestAttr%s::rf", "rf", "Float%s", True)]
|
||||
|
||||
parser.parse("""
|
||||
def WebIDLTest(parser, harness):
|
||||
testData = [
|
||||
("::TestAttr%s::b", "b", "Byte%s", False),
|
||||
("::TestAttr%s::rb", "rb", "Byte%s", True),
|
||||
("::TestAttr%s::o", "o", "Octet%s", False),
|
||||
("::TestAttr%s::ro", "ro", "Octet%s", True),
|
||||
("::TestAttr%s::s", "s", "Short%s", False),
|
||||
("::TestAttr%s::rs", "rs", "Short%s", True),
|
||||
("::TestAttr%s::us", "us", "UnsignedShort%s", False),
|
||||
("::TestAttr%s::rus", "rus", "UnsignedShort%s", True),
|
||||
("::TestAttr%s::l", "l", "Long%s", False),
|
||||
("::TestAttr%s::rl", "rl", "Long%s", True),
|
||||
("::TestAttr%s::ul", "ul", "UnsignedLong%s", False),
|
||||
("::TestAttr%s::rul", "rul", "UnsignedLong%s", True),
|
||||
("::TestAttr%s::ll", "ll", "LongLong%s", False),
|
||||
("::TestAttr%s::rll", "rll", "LongLong%s", True),
|
||||
("::TestAttr%s::ull", "ull", "UnsignedLongLong%s", False),
|
||||
("::TestAttr%s::rull", "rull", "UnsignedLongLong%s", True),
|
||||
("::TestAttr%s::str", "str", "String%s", False),
|
||||
("::TestAttr%s::rstr", "rstr", "String%s", True),
|
||||
("::TestAttr%s::obj", "obj", "Object%s", False),
|
||||
("::TestAttr%s::robj", "robj", "Object%s", True),
|
||||
("::TestAttr%s::object", "object", "Object%s", False),
|
||||
("::TestAttr%s::f", "f", "Float%s", False),
|
||||
("::TestAttr%s::rf", "rf", "Float%s", True),
|
||||
]
|
||||
|
||||
parser.parse(
|
||||
"""
|
||||
interface TestAttr {
|
||||
attribute byte b;
|
||||
readonly attribute byte rb;
|
||||
@@ -77,13 +81,13 @@ def WebIDLTest(parser, harness):
|
||||
attribute float? f;
|
||||
readonly attribute float? rf;
|
||||
};
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
results = parser.finish()
|
||||
|
||||
def checkAttr(attr, QName, name, type, readonly):
|
||||
harness.ok(isinstance(attr, WebIDL.IDLAttribute),
|
||||
"Should be an IDLAttribute")
|
||||
harness.ok(isinstance(attr, WebIDL.IDLAttribute), "Should be an IDLAttribute")
|
||||
harness.ok(attr.isAttr(), "Attr is an Attr")
|
||||
harness.ok(not attr.isMethod(), "Attr is not an method")
|
||||
harness.ok(not attr.isConst(), "Attr is not a const")
|
||||
@@ -95,11 +99,14 @@ def WebIDLTest(parser, harness):
|
||||
harness.ok(True, "TestAttr interface parsed without error.")
|
||||
harness.check(len(results), 2, "Should be two productions.")
|
||||
iface = results[0]
|
||||
harness.ok(isinstance(iface, WebIDL.IDLInterface),
|
||||
"Should be an IDLInterface")
|
||||
harness.check(iface.identifier.QName(), "::TestAttr", "Interface has the right QName")
|
||||
harness.ok(isinstance(iface, WebIDL.IDLInterface), "Should be an IDLInterface")
|
||||
harness.check(
|
||||
iface.identifier.QName(), "::TestAttr", "Interface has the right QName"
|
||||
)
|
||||
harness.check(iface.identifier.name, "TestAttr", "Interface has the right name")
|
||||
harness.check(len(iface.members), len(testData), "Expect %s members" % len(testData))
|
||||
harness.check(
|
||||
len(iface.members), len(testData), "Expect %s members" % len(testData)
|
||||
)
|
||||
|
||||
attrs = iface.members
|
||||
|
||||
@@ -110,11 +117,16 @@ def WebIDLTest(parser, harness):
|
||||
checkAttr(attr, QName % "", name, type % "", readonly)
|
||||
|
||||
iface = results[1]
|
||||
harness.ok(isinstance(iface, WebIDL.IDLInterface),
|
||||
"Should be an IDLInterface")
|
||||
harness.check(iface.identifier.QName(), "::TestAttrNullable", "Interface has the right QName")
|
||||
harness.check(iface.identifier.name, "TestAttrNullable", "Interface has the right name")
|
||||
harness.check(len(iface.members), len(testData), "Expect %s members" % len(testData))
|
||||
harness.ok(isinstance(iface, WebIDL.IDLInterface), "Should be an IDLInterface")
|
||||
harness.check(
|
||||
iface.identifier.QName(), "::TestAttrNullable", "Interface has the right QName"
|
||||
)
|
||||
harness.check(
|
||||
iface.identifier.name, "TestAttrNullable", "Interface has the right name"
|
||||
)
|
||||
harness.check(
|
||||
len(iface.members), len(testData), "Expect %s members" % len(testData)
|
||||
)
|
||||
|
||||
attrs = iface.members
|
||||
|
||||
@@ -127,11 +139,13 @@ def WebIDLTest(parser, harness):
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
parser.parse(
|
||||
"""
|
||||
interface A {
|
||||
[SetterThrows] readonly attribute boolean foo;
|
||||
};
|
||||
""")
|
||||
"""
|
||||
)
|
||||
results = parser.finish()
|
||||
except Exception as x:
|
||||
threw = True
|
||||
@@ -140,11 +154,13 @@ def WebIDLTest(parser, harness):
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
parser.parse(
|
||||
"""
|
||||
interface A {
|
||||
[Throw] readonly attribute boolean foo;
|
||||
};
|
||||
""")
|
||||
"""
|
||||
)
|
||||
results = parser.finish()
|
||||
except Exception as x:
|
||||
threw = True
|
||||
@@ -153,24 +169,30 @@ def WebIDLTest(parser, harness):
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
parser.parse(
|
||||
"""
|
||||
interface A {
|
||||
[SameObject] readonly attribute boolean foo;
|
||||
};
|
||||
""")
|
||||
"""
|
||||
)
|
||||
results = parser.finish()
|
||||
except Exception as x:
|
||||
threw = True
|
||||
harness.ok(threw, "Should not allow [SameObject] on attributes not of interface type")
|
||||
harness.ok(
|
||||
threw, "Should not allow [SameObject] on attributes not of interface type"
|
||||
)
|
||||
|
||||
parser = parser.reset()
|
||||
threw = False
|
||||
try:
|
||||
parser.parse("""
|
||||
parser.parse(
|
||||
"""
|
||||
interface A {
|
||||
[SameObject] readonly attribute A foo;
|
||||
};
|
||||
""")
|
||||
"""
|
||||
)
|
||||
results = parser.finish()
|
||||
except Exception as x:
|
||||
threw = True
|
||||
|
||||
Reference in New Issue
Block a user