4 def WebIDLTest(parser
, harness
):
7 interface TestCallbackConstructor {
8 attribute CallbackConstructorType? constructorAttribute;
11 callback constructor CallbackConstructorType = TestCallbackConstructor (unsigned long arg);
15 results
= parser
.finish()
17 harness
.ok(True, "TestCallbackConstructor interface parsed without error.")
18 harness
.check(len(results
), 2, "Should be two productions.")
20 harness
.ok(isinstance(iface
, WebIDL
.IDLInterface
), "Should be an IDLInterface")
22 iface
.identifier
.QName(),
23 "::TestCallbackConstructor",
24 "Interface has the right QName",
27 iface
.identifier
.name
, "TestCallbackConstructor", "Interface has the right name"
29 harness
.check(len(iface
.members
), 1, "Expect %s members" % 1)
31 attr
= iface
.members
[0]
32 harness
.ok(isinstance(attr
, WebIDL
.IDLAttribute
), "Should be an IDLAttribute")
33 harness
.ok(attr
.isAttr(), "Should be an attribute")
34 harness
.ok(not attr
.isMethod(), "Attr is not an method")
35 harness
.ok(not attr
.isConst(), "Attr is not a const")
37 attr
.identifier
.QName(),
38 "::TestCallbackConstructor::constructorAttribute",
39 "Attr has the right QName",
42 attr
.identifier
.name
, "constructorAttribute", "Attr has the right name"
45 harness
.ok(not isinstance(t
, WebIDL
.IDLWrapperType
), "Attr has the right type")
46 harness
.ok(isinstance(t
, WebIDL
.IDLNullableType
), "Attr has the right type")
47 harness
.ok(t
.isCallback(), "Attr has the right type")
50 harness
.ok(callback
.isConstructor(), "Callback is constructor")
57 [LegacyTreatNonObjectAsNull]
58 callback constructor CallbackConstructorType = object ();
61 results
= parser
.finish()
62 except WebIDL
.WebIDLError
:
66 threw
, "Should throw on LegacyTreatNonObjectAsNull callback constructors"
74 [MOZ_CAN_RUN_SCRIPT_BOUNDARY]
75 callback constructor CallbackConstructorType = object ();
78 results
= parser
.finish()
79 except WebIDL
.WebIDLError
:
83 threw
, "Should not permit MOZ_CAN_RUN_SCRIPT_BOUNDARY callback constructors"