tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_special_method_signature_mismatch.py (5531B)


      1 import WebIDL
      2 
      3 
      4 def WebIDLTest(parser, harness):
      5    threw = False
      6    try:
      7        parser.parse(
      8            """
      9            interface SpecialMethodSignatureMismatch1 {
     10              getter long long foo(long index);
     11            };
     12        """
     13        )
     14 
     15        parser.finish()
     16    except WebIDL.WebIDLError:
     17        threw = True
     18 
     19    harness.ok(threw, "Should have thrown.")
     20 
     21    threw = False
     22    try:
     23        parser.parse(
     24            """
     25            interface SpecialMethodSignatureMismatch2 {
     26              getter undefined foo(unsigned long index);
     27            };
     28        """
     29        )
     30 
     31        parser.finish()
     32    except WebIDL.WebIDLError:
     33        threw = True
     34 
     35    harness.ok(threw, "Should have thrown.")
     36 
     37    threw = False
     38    try:
     39        parser.parse(
     40            """
     41            interface SpecialMethodSignatureMismatch3 {
     42              getter boolean foo(unsigned long index, boolean extraArg);
     43            };
     44        """
     45        )
     46 
     47        parser.finish()
     48    except WebIDL.WebIDLError:
     49        threw = True
     50 
     51    harness.ok(threw, "Should have thrown.")
     52 
     53    threw = False
     54    try:
     55        parser.parse(
     56            """
     57            interface SpecialMethodSignatureMismatch4 {
     58              getter boolean foo(unsigned long... index);
     59            };
     60        """
     61        )
     62 
     63        parser.finish()
     64    except WebIDL.WebIDLError:
     65        threw = True
     66 
     67    harness.ok(threw, "Should have thrown.")
     68 
     69    threw = False
     70    try:
     71        parser.parse(
     72            """
     73            interface SpecialMethodSignatureMismatch5 {
     74              getter boolean foo(optional unsigned long index);
     75            };
     76        """
     77        )
     78 
     79        parser.finish()
     80    except WebIDL.WebIDLError:
     81        threw = True
     82 
     83    harness.ok(threw, "Should have thrown.")
     84 
     85    threw = False
     86    try:
     87        parser.parse(
     88            """
     89            interface SpecialMethodSignatureMismatch6 {
     90              getter boolean foo();
     91            };
     92        """
     93        )
     94 
     95        parser.finish()
     96    except WebIDL.WebIDLError:
     97        threw = True
     98 
     99    harness.ok(threw, "Should have thrown.")
    100 
    101    threw = False
    102    try:
    103        parser.parse(
    104            """
    105            interface SpecialMethodSignatureMismatch7 {
    106              deleter long long foo(long index);
    107            };
    108        """
    109        )
    110 
    111        parser.finish()
    112    except WebIDL.WebIDLError:
    113        threw = True
    114 
    115    harness.ok(threw, "Should have thrown.")
    116 
    117    threw = False
    118    try:
    119        parser.parse(
    120            """
    121            interface SpecialMethodSignatureMismatch9 {
    122              deleter boolean foo(unsigned long index, boolean extraArg);
    123            };
    124        """
    125        )
    126 
    127        parser.finish()
    128    except WebIDL.WebIDLError:
    129        threw = True
    130 
    131    harness.ok(threw, "Should have thrown.")
    132 
    133    threw = False
    134    try:
    135        parser.parse(
    136            """
    137            interface SpecialMethodSignatureMismatch10 {
    138              deleter boolean foo(unsigned long... index);
    139            };
    140        """
    141        )
    142 
    143        parser.finish()
    144    except WebIDL.WebIDLError:
    145        threw = True
    146 
    147    harness.ok(threw, "Should have thrown.")
    148 
    149    threw = False
    150    try:
    151        parser.parse(
    152            """
    153            interface SpecialMethodSignatureMismatch11 {
    154              deleter boolean foo(optional unsigned long index);
    155            };
    156        """
    157        )
    158 
    159        parser.finish()
    160    except WebIDL.WebIDLError:
    161        threw = True
    162 
    163    harness.ok(threw, "Should have thrown.")
    164 
    165    threw = False
    166    try:
    167        parser.parse(
    168            """
    169            interface SpecialMethodSignatureMismatch12 {
    170              deleter boolean foo();
    171            };
    172        """
    173        )
    174 
    175        parser.finish()
    176    except WebIDL.WebIDLError:
    177        threw = True
    178 
    179    harness.ok(threw, "Should have thrown.")
    180 
    181    threw = False
    182    try:
    183        parser.parse(
    184            """
    185            interface SpecialMethodSignatureMismatch13 {
    186              setter long long foo(long index, long long value);
    187            };
    188        """
    189        )
    190 
    191        parser.finish()
    192    except WebIDL.WebIDLError:
    193        threw = True
    194 
    195    harness.ok(threw, "Should have thrown.")
    196 
    197    threw = False
    198    try:
    199        parser.parse(
    200            """
    201            interface SpecialMethodSignatureMismatch15 {
    202              setter boolean foo(unsigned long index, boolean value, long long extraArg);
    203            };
    204        """
    205        )
    206 
    207        parser.finish()
    208    except WebIDL.WebIDLError:
    209        threw = True
    210 
    211    harness.ok(threw, "Should have thrown.")
    212 
    213    threw = False
    214    try:
    215        parser.parse(
    216            """
    217            interface SpecialMethodSignatureMismatch16 {
    218              setter boolean foo(unsigned long index, boolean... value);
    219            };
    220        """
    221        )
    222 
    223        parser.finish()
    224    except WebIDL.WebIDLError:
    225        threw = True
    226 
    227    harness.ok(threw, "Should have thrown.")
    228 
    229    threw = False
    230    try:
    231        parser.parse(
    232            """
    233            interface SpecialMethodSignatureMismatch17 {
    234              setter boolean foo(unsigned long index, optional boolean value);
    235            };
    236        """
    237        )
    238 
    239        parser.finish()
    240    except WebIDL.WebIDLError:
    241        threw = True
    242 
    243    harness.ok(threw, "Should have thrown.")
    244 
    245    threw = False
    246    try:
    247        parser.parse(
    248            """
    249            interface SpecialMethodSignatureMismatch18 {
    250              setter boolean foo();
    251            };
    252        """
    253        )
    254 
    255        parser.finish()
    256    except WebIDL.WebIDLError:
    257        threw = True
    258 
    259    harness.ok(threw, "Should have thrown.")