Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_replaceable.py
blob3b0a6fea3607434dc1af918f2114bfeb39d70325
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import WebIDL
8 def should_throw(parser, harness, message, code):
9 parser = parser.reset()
10 threw = False
11 try:
12 parser.parse(code)
13 parser.finish()
14 except WebIDL.WebIDLError:
15 threw = True
17 harness.ok(threw, "Should have thrown: %s" % message)
20 def WebIDLTest(parser, harness):
21 # The [Replaceable] extended attribute MUST take no arguments.
22 should_throw(
23 parser,
24 harness,
25 "no arguments",
26 """
27 interface I {
28 [Replaceable=X] readonly attribute long A;
30 """,
33 # An attribute with the [Replaceable] extended attribute MUST NOT also be
34 # declared with the [PutForwards] extended attribute.
35 should_throw(
36 parser,
37 harness,
38 "PutForwards",
39 """
40 interface I {
41 [PutForwards=B, Replaceable] readonly attribute J A;
43 interface J {
44 attribute long B;
46 """,
49 # The [Replaceable] extended attribute MUST NOT be used on an attribute
50 # that is not read only.
51 should_throw(
52 parser,
53 harness,
54 "writable attribute",
55 """
56 interface I {
57 [Replaceable] attribute long A;
59 """,
62 # The [Replaceable] extended attribute MUST NOT be used on a static
63 # attribute.
64 should_throw(
65 parser,
66 harness,
67 "static attribute",
68 """
69 interface I {
70 [Replaceable] static readonly attribute long A;
72 """,
75 # The [Replaceable] extended attribute MUST NOT be used on an attribute
76 # declared on a callback interface.
77 should_throw(
78 parser,
79 harness,
80 "callback interface",
81 """
82 callback interface I {
83 [Replaceable] readonly attribute long A;
85 """,