Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_arraybuffer.py
blobb762d06ac2934788bd5aedf270b5d78db8cf3197
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser.parse(
6 """
7 interface TestArrayBuffer {
8 attribute ArrayBuffer bufferAttr;
9 undefined bufferMethod(ArrayBuffer arg1, ArrayBuffer? arg2, sequence<ArrayBuffer> arg3);
11 attribute ArrayBufferView viewAttr;
12 undefined viewMethod(ArrayBufferView arg1, ArrayBufferView? arg2, sequence<ArrayBufferView> arg3);
14 attribute Int8Array int8ArrayAttr;
15 undefined int8ArrayMethod(Int8Array arg1, Int8Array? arg2, sequence<Int8Array> arg3);
17 attribute Uint8Array uint8ArrayAttr;
18 undefined uint8ArrayMethod(Uint8Array arg1, Uint8Array? arg2, sequence<Uint8Array> arg3);
20 attribute Uint8ClampedArray uint8ClampedArrayAttr;
21 undefined uint8ClampedArrayMethod(Uint8ClampedArray arg1, Uint8ClampedArray? arg2, sequence<Uint8ClampedArray> arg3);
23 attribute Int16Array int16ArrayAttr;
24 undefined int16ArrayMethod(Int16Array arg1, Int16Array? arg2, sequence<Int16Array> arg3);
26 attribute Uint16Array uint16ArrayAttr;
27 undefined uint16ArrayMethod(Uint16Array arg1, Uint16Array? arg2, sequence<Uint16Array> arg3);
29 attribute Int32Array int32ArrayAttr;
30 undefined int32ArrayMethod(Int32Array arg1, Int32Array? arg2, sequence<Int32Array> arg3);
32 attribute Uint32Array uint32ArrayAttr;
33 undefined uint32ArrayMethod(Uint32Array arg1, Uint32Array? arg2, sequence<Uint32Array> arg3);
35 attribute Float32Array float32ArrayAttr;
36 undefined float32ArrayMethod(Float32Array arg1, Float32Array? arg2, sequence<Float32Array> arg3);
38 attribute Float64Array float64ArrayAttr;
39 undefined float64ArrayMethod(Float64Array arg1, Float64Array? arg2, sequence<Float64Array> arg3);
41 """
44 results = parser.finish()
46 iface = results[0]
48 harness.ok(True, "TestArrayBuffer interface parsed without error")
49 harness.check(len(iface.members), 22, "Interface should have twenty two members")
51 members = iface.members
53 def checkStuff(attr, method, t):
54 harness.ok(isinstance(attr, WebIDL.IDLAttribute), "Expect an IDLAttribute")
55 harness.ok(isinstance(method, WebIDL.IDLMethod), "Expect an IDLMethod")
57 harness.check(str(attr.type), t, "Expect an ArrayBuffer type")
58 harness.ok(attr.type.isSpiderMonkeyInterface(), "Should test as a js interface")
60 (retType, arguments) = method.signatures()[0]
61 harness.ok(retType.isUndefined(), "Should have an undefined return type")
62 harness.check(len(arguments), 3, "Expect 3 arguments")
64 harness.check(str(arguments[0].type), t, "Expect an ArrayBuffer type")
65 harness.ok(
66 arguments[0].type.isSpiderMonkeyInterface(), "Should test as a js interface"
69 harness.check(
70 str(arguments[1].type), t + "OrNull", "Expect an ArrayBuffer type"
72 harness.ok(
73 arguments[1].type.inner.isSpiderMonkeyInterface(),
74 "Should test as a js interface",
77 harness.check(
78 str(arguments[2].type), t + "Sequence", "Expect an ArrayBuffer type"
80 harness.ok(
81 arguments[2].type.inner.isSpiderMonkeyInterface(),
82 "Should test as a js interface",
85 checkStuff(members[0], members[1], "ArrayBuffer")
86 checkStuff(members[2], members[3], "ArrayBufferView")
87 checkStuff(members[4], members[5], "Int8Array")
88 checkStuff(members[6], members[7], "Uint8Array")
89 checkStuff(members[8], members[9], "Uint8ClampedArray")
90 checkStuff(members[10], members[11], "Int16Array")
91 checkStuff(members[12], members[13], "Uint16Array")
92 checkStuff(members[14], members[15], "Int32Array")
93 checkStuff(members[16], members[17], "Uint32Array")
94 checkStuff(members[18], members[19], "Float32Array")
95 checkStuff(members[20], members[21], "Float64Array")