dom/bindings/parser/tests/test_callback.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/bindings/parser/tests/test_callback.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,34 @@
     1.4 +import WebIDL
     1.5 +
     1.6 +def WebIDLTest(parser, harness):
     1.7 +    parser.parse("""
     1.8 +        interface TestCallback {
     1.9 +          attribute CallbackType? listener;
    1.10 +        };
    1.11 +
    1.12 +        callback CallbackType = boolean (unsigned long arg);
    1.13 +    """)
    1.14 +
    1.15 +    results = parser.finish()
    1.16 +
    1.17 +    harness.ok(True, "TestCallback interface parsed without error.")
    1.18 +    harness.check(len(results), 2, "Should be two productions.")
    1.19 +    iface = results[0]
    1.20 +    harness.ok(isinstance(iface, WebIDL.IDLInterface),
    1.21 +               "Should be an IDLInterface")
    1.22 +    harness.check(iface.identifier.QName(), "::TestCallback", "Interface has the right QName")
    1.23 +    harness.check(iface.identifier.name, "TestCallback", "Interface has the right name")
    1.24 +    harness.check(len(iface.members), 1, "Expect %s members" % 1)
    1.25 +
    1.26 +    attr = iface.members[0]
    1.27 +    harness.ok(isinstance(attr, WebIDL.IDLAttribute),
    1.28 +               "Should be an IDLAttribute")
    1.29 +    harness.ok(attr.isAttr(), "Should be an attribute")
    1.30 +    harness.ok(not attr.isMethod(), "Attr is not an method")
    1.31 +    harness.ok(not attr.isConst(), "Attr is not a const")
    1.32 +    harness.check(attr.identifier.QName(), "::TestCallback::listener", "Attr has the right QName")
    1.33 +    harness.check(attr.identifier.name, "listener", "Attr has the right name")
    1.34 +    t = attr.type
    1.35 +    harness.ok(not isinstance(t, WebIDL.IDLWrapperType), "Attr has the right type")
    1.36 +    harness.ok(isinstance(t, WebIDL.IDLNullableType), "Attr has the right type")
    1.37 +    harness.ok(t.isCallback(), "Attr has the right type")

mercurial