Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_conditional_dictionary_member.py
blob2aef8ebe8ff3a6d61bc5a14da63156d017ee0c81
1 def WebIDLTest(parser, harness):
2 parser.parse(
3 """
4 dictionary Dict {
5 any foo;
6 [ChromeOnly] any bar;
7 };
8 """
10 results = parser.finish()
11 harness.check(len(results), 1, "Should have a dictionary")
12 members = results[0].members
13 harness.check(len(members), 2, "Should have two members")
14 # Note that members are ordered lexicographically, so "bar" comes
15 # before "foo".
16 harness.ok(
17 members[0].getExtendedAttribute("ChromeOnly"), "First member is not ChromeOnly"
19 harness.ok(
20 not members[1].getExtendedAttribute("ChromeOnly"), "Second member is ChromeOnly"
23 parser = parser.reset()
24 parser.parse(
25 """
26 dictionary Dict {
27 any foo;
28 any bar;
31 interface Iface {
32 [Constant, Cached] readonly attribute Dict dict;
34 """
36 results = parser.finish()
37 harness.check(len(results), 2, "Should have a dictionary and an interface")
39 parser = parser.reset()
40 exception = None
41 try:
42 parser.parse(
43 """
44 dictionary Dict {
45 any foo;
46 [ChromeOnly] any bar;
49 interface Iface {
50 [Constant, Cached] readonly attribute Dict dict;
52 """
54 results = parser.finish()
55 except Exception as e:
56 exception = e
58 harness.ok(exception, "Should have thrown.")
59 harness.check(
60 exception.message,
61 "[Cached] and [StoreInSlot] must not be used on an attribute "
62 "whose type contains a [ChromeOnly] dictionary member",
63 "Should have thrown the right exception",
66 parser = parser.reset()
67 exception = None
68 try:
69 parser.parse(
70 """
71 dictionary ParentDict {
72 [ChromeOnly] any bar;
75 dictionary Dict : ParentDict {
76 any foo;
79 interface Iface {
80 [Constant, Cached] readonly attribute Dict dict;
82 """
84 results = parser.finish()
85 except Exception as e:
86 exception = e
88 harness.ok(exception, "Should have thrown (2).")
89 harness.check(
90 exception.message,
91 "[Cached] and [StoreInSlot] must not be used on an attribute "
92 "whose type contains a [ChromeOnly] dictionary member",
93 "Should have thrown the right exception (2)",
96 parser = parser.reset()
97 exception = None
98 try:
99 parser.parse(
101 dictionary GrandParentDict {
102 [ChromeOnly] any baz;
105 dictionary ParentDict : GrandParentDict {
106 any bar;
109 dictionary Dict : ParentDict {
110 any foo;
113 interface Iface {
114 [Constant, Cached] readonly attribute Dict dict;
118 results = parser.finish()
119 except Exception as e:
120 exception = e
122 harness.ok(exception, "Should have thrown (3).")
123 harness.check(
124 exception.message,
125 "[Cached] and [StoreInSlot] must not be used on an attribute "
126 "whose type contains a [ChromeOnly] dictionary member",
127 "Should have thrown the right exception (3)",