dom/bindings/parser/tests/test_callback.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial