Backed out changeset 713114c0331a (bug 1938707) by developer request CLOSED TREE
[gecko.git] / dom / bindings / parser / tests / test_newobject.py
blobb30e9c5816016b4b22552f8803c0b46e1db7e138
1 import WebIDL
4 # Import the WebIDL module, so we can do isinstance checks and whatnot
5 def WebIDLTest(parser, harness):
6 # Basic functionality
7 parser.parse(
8 """
9 interface Iface {
10 [NewObject] readonly attribute Iface attr;
11 [NewObject] Iface method();
13 """
15 results = parser.finish()
16 harness.ok(results, "Should not have thrown on basic [NewObject] usage")
18 parser = parser.reset()
19 threw = False
20 try:
21 parser.parse(
22 """
23 interface Iface {
24 [Pure, NewObject] readonly attribute Iface attr;
26 """
28 parser.finish()
29 except WebIDL.WebIDLError:
30 threw = True
31 harness.ok(threw, "[NewObject] attributes must depend on something")
33 parser = parser.reset()
34 threw = False
35 try:
36 parser.parse(
37 """
38 interface Iface {
39 [Pure, NewObject] Iface method();
41 """
43 parser.finish()
44 except WebIDL.WebIDLError:
45 threw = True
46 harness.ok(threw, "[NewObject] methods must depend on something")
48 parser = parser.reset()
49 threw = False
50 try:
51 parser.parse(
52 """
53 interface Iface {
54 [Cached, NewObject, Affects=Nothing] readonly attribute Iface attr;
56 """
58 parser.finish()
59 except WebIDL.WebIDLError:
60 threw = True
61 harness.ok(threw, "[NewObject] attributes must not be [Cached]")
63 parser = parser.reset()
64 threw = False
65 try:
66 parser.parse(
67 """
68 interface Iface {
69 [StoreInSlot, NewObject, Affects=Nothing] readonly attribute Iface attr;
71 """
73 parser.finish()
74 except WebIDL.WebIDLError:
75 threw = True
76 harness.ok(threw, "[NewObject] attributes must not be [StoreInSlot]")