Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | import WebIDL |
michael@0 | 2 | |
michael@0 | 3 | def WebIDLTest(parser, harness): |
michael@0 | 4 | parser.parse(""" |
michael@0 | 5 | interface TestArrayBuffer { |
michael@0 | 6 | attribute ArrayBuffer bufferAttr; |
michael@0 | 7 | void bufferMethod(ArrayBuffer arg1, ArrayBuffer? arg2, ArrayBuffer[] arg3, sequence<ArrayBuffer> arg4); |
michael@0 | 8 | |
michael@0 | 9 | attribute ArrayBufferView viewAttr; |
michael@0 | 10 | void viewMethod(ArrayBufferView arg1, ArrayBufferView? arg2, ArrayBufferView[] arg3, sequence<ArrayBufferView> arg4); |
michael@0 | 11 | |
michael@0 | 12 | attribute Int8Array int8ArrayAttr; |
michael@0 | 13 | void int8ArrayMethod(Int8Array arg1, Int8Array? arg2, Int8Array[] arg3, sequence<Int8Array> arg4); |
michael@0 | 14 | |
michael@0 | 15 | attribute Uint8Array uint8ArrayAttr; |
michael@0 | 16 | void uint8ArrayMethod(Uint8Array arg1, Uint8Array? arg2, Uint8Array[] arg3, sequence<Uint8Array> arg4); |
michael@0 | 17 | |
michael@0 | 18 | attribute Uint8ClampedArray uint8ClampedArrayAttr; |
michael@0 | 19 | void uint8ClampedArrayMethod(Uint8ClampedArray arg1, Uint8ClampedArray? arg2, Uint8ClampedArray[] arg3, sequence<Uint8ClampedArray> arg4); |
michael@0 | 20 | |
michael@0 | 21 | attribute Int16Array int16ArrayAttr; |
michael@0 | 22 | void int16ArrayMethod(Int16Array arg1, Int16Array? arg2, Int16Array[] arg3, sequence<Int16Array> arg4); |
michael@0 | 23 | |
michael@0 | 24 | attribute Uint16Array uint16ArrayAttr; |
michael@0 | 25 | void uint16ArrayMethod(Uint16Array arg1, Uint16Array? arg2, Uint16Array[] arg3, sequence<Uint16Array> arg4); |
michael@0 | 26 | |
michael@0 | 27 | attribute Int32Array int32ArrayAttr; |
michael@0 | 28 | void int32ArrayMethod(Int32Array arg1, Int32Array? arg2, Int32Array[] arg3, sequence<Int32Array> arg4); |
michael@0 | 29 | |
michael@0 | 30 | attribute Uint32Array uint32ArrayAttr; |
michael@0 | 31 | void uint32ArrayMethod(Uint32Array arg1, Uint32Array? arg2, Uint32Array[] arg3, sequence<Uint32Array> arg4); |
michael@0 | 32 | |
michael@0 | 33 | attribute Float32Array float32ArrayAttr; |
michael@0 | 34 | void float32ArrayMethod(Float32Array arg1, Float32Array? arg2, Float32Array[] arg3, sequence<Float32Array> arg4); |
michael@0 | 35 | |
michael@0 | 36 | attribute Float64Array float64ArrayAttr; |
michael@0 | 37 | void float64ArrayMethod(Float64Array arg1, Float64Array? arg2, Float64Array[] arg3, sequence<Float64Array> arg4); |
michael@0 | 38 | }; |
michael@0 | 39 | """) |
michael@0 | 40 | |
michael@0 | 41 | results = parser.finish() |
michael@0 | 42 | |
michael@0 | 43 | iface = results[0] |
michael@0 | 44 | |
michael@0 | 45 | harness.ok(True, "TestArrayBuffer interface parsed without error") |
michael@0 | 46 | harness.check(len(iface.members), 22, "Interface should have twenty two members") |
michael@0 | 47 | |
michael@0 | 48 | members = iface.members |
michael@0 | 49 | |
michael@0 | 50 | def checkStuff(attr, method, t): |
michael@0 | 51 | harness.ok(isinstance(attr, WebIDL.IDLAttribute), "Expect an IDLAttribute") |
michael@0 | 52 | harness.ok(isinstance(method, WebIDL.IDLMethod), "Expect an IDLMethod") |
michael@0 | 53 | |
michael@0 | 54 | harness.check(str(attr.type), t, "Expect an ArrayBuffer type") |
michael@0 | 55 | harness.ok(attr.type.isSpiderMonkeyInterface(), "Should test as a js interface") |
michael@0 | 56 | |
michael@0 | 57 | (retType, arguments) = method.signatures()[0] |
michael@0 | 58 | harness.ok(retType.isVoid(), "Should have a void return type") |
michael@0 | 59 | harness.check(len(arguments), 4, "Expect 4 arguments") |
michael@0 | 60 | |
michael@0 | 61 | harness.check(str(arguments[0].type), t, "Expect an ArrayBuffer type") |
michael@0 | 62 | harness.ok(arguments[0].type.isSpiderMonkeyInterface(), "Should test as a js interface") |
michael@0 | 63 | |
michael@0 | 64 | harness.check(str(arguments[1].type), t + "OrNull", "Expect an ArrayBuffer type") |
michael@0 | 65 | harness.ok(arguments[1].type.inner.isSpiderMonkeyInterface(), "Should test as a js interface") |
michael@0 | 66 | |
michael@0 | 67 | harness.check(str(arguments[2].type), t + "Array", "Expect an ArrayBuffer type") |
michael@0 | 68 | harness.ok(arguments[2].type.inner.isSpiderMonkeyInterface(), "Should test as a js interface") |
michael@0 | 69 | |
michael@0 | 70 | harness.check(str(arguments[3].type), t + "Sequence", "Expect an ArrayBuffer type") |
michael@0 | 71 | harness.ok(arguments[3].type.inner.isSpiderMonkeyInterface(), "Should test as a js interface") |
michael@0 | 72 | |
michael@0 | 73 | |
michael@0 | 74 | checkStuff(members[0], members[1], "ArrayBuffer") |
michael@0 | 75 | checkStuff(members[2], members[3], "ArrayBufferView") |
michael@0 | 76 | checkStuff(members[4], members[5], "Int8Array") |
michael@0 | 77 | checkStuff(members[6], members[7], "Uint8Array") |
michael@0 | 78 | checkStuff(members[8], members[9], "Uint8ClampedArray") |
michael@0 | 79 | checkStuff(members[10], members[11], "Int16Array") |
michael@0 | 80 | checkStuff(members[12], members[13], "Uint16Array") |
michael@0 | 81 | checkStuff(members[14], members[15], "Int32Array") |
michael@0 | 82 | checkStuff(members[16], members[17], "Uint32Array") |
michael@0 | 83 | checkStuff(members[18], members[19], "Float32Array") |
michael@0 | 84 | checkStuff(members[20], members[21], "Float64Array") |