dom/bindings/parser/tests/test_treatNonCallableAsNull.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         [TreatNonCallableAsNull] callback Function = any(any... arguments);
     7         interface TestTreatNonCallableAsNull1 {
     8           attribute Function? onfoo;
     9           attribute Function onbar;
    10         };
    11     """)
    13     results = parser.finish()
    15     iface = results[1]
    16     attr = iface.members[0]
    17     harness.check(attr.type.treatNonCallableAsNull(), True, "Got the expected value")
    18     attr = iface.members[1]
    19     harness.check(attr.type.treatNonCallableAsNull(), False, "Got the expected value")
    21     parser = parser.reset()
    23     threw = False
    24     try:
    25         parser.parse("""
    26             callback Function = any(any... arguments);
    28             interface TestTreatNonCallableAsNull2 {
    29               [TreatNonCallableAsNull] attribute Function onfoo;
    30             };
    31         """)
    33         results = parser.finish()
    34     except:
    35         threw = True
    37     harness.ok(threw, "Should have thrown.")
    39     parser = parser.reset()
    41     threw = False
    42     try:
    43         parser.parse("""
    44             callback Function = any(any... arguments);
    46             [TreatNonCallableAsNull]
    47             interface TestTreatNonCallableAsNull3 {
    48                attribute Function onfoo;
    49             };
    50         """)
    52         results = parser.finish()
    53     except:
    54         threw = True
    56     harness.ok(threw, "Should have thrown.")
    58     parser = parser.reset()
    60     threw = False
    61     try:
    62         parser.parse("""
    63             [TreatNonCallableAsNull, TreatNonObjectAsNull]
    64             callback Function = any(any... arguments);
    65         """)
    67         results = parser.finish()
    68     except:
    69         threw = True
    71     harness.ok(threw, "Should have thrown.")

mercurial