Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_callback.py
blob407644a6a8dbd69d075b03cddc51c69c7d31e485
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser.parse(
6 """
7 interface TestCallback {
8 attribute CallbackType? listener;
9 };
11 callback CallbackType = boolean (unsigned long arg);
12 """
15 results = parser.finish()
17 harness.ok(True, "TestCallback interface parsed without error.")
18 harness.check(len(results), 2, "Should be two productions.")
19 iface = results[0]
20 harness.ok(isinstance(iface, WebIDL.IDLInterface), "Should be an IDLInterface")
21 harness.check(
22 iface.identifier.QName(), "::TestCallback", "Interface has the right QName"
24 harness.check(iface.identifier.name, "TestCallback", "Interface has the right name")
25 harness.check(len(iface.members), 1, "Expect %s members" % 1)
27 attr = iface.members[0]
28 harness.ok(isinstance(attr, WebIDL.IDLAttribute), "Should be an IDLAttribute")
29 harness.ok(attr.isAttr(), "Should be an attribute")
30 harness.ok(not attr.isMethod(), "Attr is not an method")
31 harness.ok(not attr.isConst(), "Attr is not a const")
32 harness.check(
33 attr.identifier.QName(), "::TestCallback::listener", "Attr has the right QName"
35 harness.check(attr.identifier.name, "listener", "Attr has the right name")
36 t = attr.type
37 harness.ok(not isinstance(t, WebIDL.IDLWrapperType), "Attr has the right type")
38 harness.ok(isinstance(t, WebIDL.IDLNullableType), "Attr has the right type")
39 harness.ok(t.isCallback(), "Attr has the right type")
41 callback = results[1]
42 harness.ok(not callback.isConstructor(), "callback is not constructor")