Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_record.py
blobbee5c83953d6877794e3fc61ad2b5525f79e9e17
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser.parse(
6 """
7 dictionary Dict {};
8 interface RecordArg {
9 undefined foo(record<DOMString, Dict> arg);
11 """
14 results = parser.finish()
16 harness.check(len(results), 2, "Should know about two things")
17 harness.ok(
18 isinstance(results[1], WebIDL.IDLInterface), "Should have an interface here"
20 members = results[1].members
21 harness.check(len(members), 1, "Should have one member")
22 harness.ok(members[0].isMethod(), "Should have method")
23 signature = members[0].signatures()[0]
24 args = signature[1]
25 harness.check(len(args), 1, "Should have one arg")
26 harness.ok(args[0].type.isRecord(), "Should have a record type here")
27 harness.ok(args[0].type.inner.isDictionary(), "Should have a dictionary inner type")
29 parser = parser.reset()
30 threw = False
31 try:
32 parser.parse(
33 """
34 interface RecordUndefinedArg {
35 undefined foo(record<DOMString, undefined> arg);
37 """
40 results = parser.finish()
41 except WebIDL.WebIDLError:
42 threw = True
43 harness.ok(
44 threw, "Should have thrown because record can't have undefined as value type."
47 parser = parser.reset()
48 threw = False
49 try:
50 parser.parse(
51 """
52 dictionary Dict {
53 record<DOMString, Dict> val;
55 """
58 results = parser.finish()
59 except WebIDL.WebIDLError:
60 threw = True
61 harness.ok(threw, "Should have thrown on dictionary containing itself via record.")