servo/third_party/WebIDL/tests/test_cereactions.py
Ngo Iok Ui (Wu Yu Wei) 8eed3b442b
Update WebIDL.py (#32495)
* Update WebIDL.py

* Update WebIDL.py

* Add builtin-array.patch

* Fix CodegenRust.py and Configuration.py

* Fix missing downcasts

* mach fmt

* Update check and comment to explain why we need this check

* Update Global of DissimilarOriginWindow.webidl
2024-06-15 04:22:42 +00:00

160 lines
3.5 KiB
Python

import WebIDL
def WebIDLTest(parser, harness):
threw = False
try:
parser.parse(
"""
interface Foo {
[CEReactions(DOMString a)] undefined foo(boolean arg2);
};
"""
)
parser.finish()
except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] with an argument")
parser = parser.reset()
threw = False
try:
parser.parse(
"""
interface Foo {
[CEReactions(DOMString b)] readonly attribute boolean bar;
};
"""
)
parser.finish()
except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] with an argument")
parser = parser.reset()
threw = False
try:
parser.parse(
"""
interface Foo {
[CEReactions] attribute boolean bar;
};
"""
)
parser.finish()
except Exception as e:
harness.ok(
False,
"Shouldn't have thrown for [CEReactions] used on writable attribute. %s"
% e,
)
threw = True
parser = parser.reset()
threw = False
try:
parser.parse(
"""
interface Foo {
[CEReactions] undefined foo(boolean arg2);
};
"""
)
parser.finish()
except Exception as e:
harness.ok(
False,
"Shouldn't have thrown for [CEReactions] used on regular operations. %s"
% e,
)
threw = True
parser = parser.reset()
threw = False
try:
parser.parse(
"""
interface Foo {
[CEReactions] readonly attribute boolean A;
};
"""
)
parser.finish()
except WebIDL.WebIDLError:
threw = True
harness.ok(
threw, "Should have thrown for [CEReactions] used on a readonly attribute"
)
parser = parser.reset()
threw = False
try:
parser.parse(
"""
[CEReactions]
interface Foo {
}
"""
)
parser.finish()
except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] used on a interface")
parser = parser.reset()
threw = False
try:
parser.parse(
"""
interface Foo {
[CEReactions] getter any(DOMString name);
};
"""
)
parser.finish()
except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] used on a named getter")
parser = parser.reset()
threw = False
try:
parser.parse(
"""
interface Foo {
[CEReactions] legacycaller double compute(double x);
};
"""
)
parser.finish()
except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] used on a legacycaller")
parser = parser.reset()
threw = False
try:
parser.parse(
"""
interface Foo {
[CEReactions] stringifier DOMString ();
};
"""
)
parser.finish()
except WebIDL.WebIDLError:
threw = True
harness.ok(threw, "Should have thrown for [CEReactions] used on a stringifier")