dom/bindings/parser/tests/test_callback_interface.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         callback interface TestCallbackInterface {
     6           attribute boolean bool;
     7         };
     8     """)
    10     results = parser.finish()
    12     iface = results[0]
    14     harness.ok(iface.isCallback(), "Interface should be a callback")
    16     parser = parser.reset()
    17     threw = False
    18     try:
    19         parser.parse("""
    20             interface TestInterface {
    21             };
    22             callback interface TestCallbackInterface : TestInterface {
    23               attribute boolean bool;
    24             };
    25         """)
    26         results = parser.finish()
    27     except:
    28         threw = True
    30     harness.ok(threw, "Should not allow non-callback parent of callback interface")
    32     parser = parser.reset()
    33     threw = False
    34     try:
    35         parser.parse("""
    36             interface TestInterface : TestCallbackInterface {
    37             };
    38             callback interface TestCallbackInterface {
    39               attribute boolean bool;
    40             };
    41         """)
    42         results = parser.finish()
    43     except:
    44         threw = True
    46     harness.ok(threw, "Should not allow callback parent of non-callback interface")
    48     parser = parser.reset()
    49     parser.parse("""
    50         callback interface TestCallbackInterface1 {
    51           void foo();
    52         };
    53         callback interface TestCallbackInterface2 {
    54           void foo(DOMString arg);
    55           void foo(TestCallbackInterface1 arg);
    56         };
    57         callback interface TestCallbackInterface3 {
    58           void foo(DOMString arg);
    59           void foo(TestCallbackInterface1 arg);
    60           static void bar();
    61         };
    62         callback interface TestCallbackInterface4 {
    63           void foo(DOMString arg);
    64           void foo(TestCallbackInterface1 arg);
    65           static void bar();
    66           const long baz = 5;
    67         };
    68         callback interface TestCallbackInterface5 {
    69           static attribute boolean bool;
    70           void foo();
    71         };
    72         callback interface TestCallbackInterface6 {
    73           void foo(DOMString arg);
    74           void foo(TestCallbackInterface1 arg);
    75           void bar();
    76         };
    77         callback interface TestCallbackInterface7 {
    78           static attribute boolean bool;
    79         };
    80         callback interface TestCallbackInterface8 {
    81           attribute boolean bool;
    82         };
    83         callback interface TestCallbackInterface9 : TestCallbackInterface1 {
    84           void foo();
    85         };
    86         callback interface TestCallbackInterface10 : TestCallbackInterface1 {
    87           void bar();
    88         };
    89     """)
    90     results = parser.finish()
    91     for (i, iface) in enumerate(results):
    92       harness.check(iface.isSingleOperationInterface(), i < 4,
    93                     "Interface %s should be a single operation interface" %
    94                     iface.identifier.name)

mercurial