dom/bindings/parser/tests/test_treatNonCallableAsNull.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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