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 TestCallback { |
michael@0 | 6 | attribute CallbackType? listener; |
michael@0 | 7 | }; |
michael@0 | 8 | |
michael@0 | 9 | callback CallbackType = boolean (unsigned long arg); |
michael@0 | 10 | """) |
michael@0 | 11 | |
michael@0 | 12 | results = parser.finish() |
michael@0 | 13 | |
michael@0 | 14 | harness.ok(True, "TestCallback interface parsed without error.") |
michael@0 | 15 | harness.check(len(results), 2, "Should be two productions.") |
michael@0 | 16 | iface = results[0] |
michael@0 | 17 | harness.ok(isinstance(iface, WebIDL.IDLInterface), |
michael@0 | 18 | "Should be an IDLInterface") |
michael@0 | 19 | harness.check(iface.identifier.QName(), "::TestCallback", "Interface has the right QName") |
michael@0 | 20 | harness.check(iface.identifier.name, "TestCallback", "Interface has the right name") |
michael@0 | 21 | harness.check(len(iface.members), 1, "Expect %s members" % 1) |
michael@0 | 22 | |
michael@0 | 23 | attr = iface.members[0] |
michael@0 | 24 | harness.ok(isinstance(attr, WebIDL.IDLAttribute), |
michael@0 | 25 | "Should be an IDLAttribute") |
michael@0 | 26 | harness.ok(attr.isAttr(), "Should be an attribute") |
michael@0 | 27 | harness.ok(not attr.isMethod(), "Attr is not an method") |
michael@0 | 28 | harness.ok(not attr.isConst(), "Attr is not a const") |
michael@0 | 29 | harness.check(attr.identifier.QName(), "::TestCallback::listener", "Attr has the right QName") |
michael@0 | 30 | harness.check(attr.identifier.name, "listener", "Attr has the right name") |
michael@0 | 31 | t = attr.type |
michael@0 | 32 | harness.ok(not isinstance(t, WebIDL.IDLWrapperType), "Attr has the right type") |
michael@0 | 33 | harness.ok(isinstance(t, WebIDL.IDLNullableType), "Attr has the right type") |
michael@0 | 34 | harness.ok(t.isCallback(), "Attr has the right type") |