tor-browser

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

test_putForwards.py (3098B)


      1 import WebIDL
      2 
      3 
      4 def WebIDLTest(parser, harness):
      5    threw = False
      6    try:
      7        parser.parse(
      8            """
      9            interface I {
     10              [PutForwards=B] readonly attribute long A;
     11            };
     12        """
     13        )
     14 
     15        parser.finish()
     16    except WebIDL.WebIDLError:
     17        threw = True
     18 
     19    harness.ok(threw, "Should have thrown.")
     20 
     21    parser = parser.reset()
     22    threw = False
     23    try:
     24        parser.parse(
     25            """
     26            interface I {
     27              [PutForwards=B] readonly attribute J A;
     28            };
     29            interface J {
     30            };
     31        """
     32        )
     33 
     34        parser.finish()
     35    except WebIDL.WebIDLError:
     36        threw = True
     37 
     38    harness.ok(threw, "Should have thrown.")
     39 
     40    parser = parser.reset()
     41    threw = False
     42    try:
     43        parser.parse(
     44            """
     45            interface I {
     46              [PutForwards=B] attribute J A;
     47            };
     48            interface J {
     49              attribute long B;
     50            };
     51        """
     52        )
     53 
     54        parser.finish()
     55    except WebIDL.WebIDLError:
     56        threw = True
     57 
     58    harness.ok(threw, "Should have thrown.")
     59 
     60    parser = parser.reset()
     61    threw = False
     62    try:
     63        parser.parse(
     64            """
     65            interface I {
     66              [PutForwards=B] static readonly attribute J A;
     67            };
     68            interface J {
     69              attribute long B;
     70            };
     71        """
     72        )
     73 
     74        parser.finish()
     75    except WebIDL.WebIDLError:
     76        threw = True
     77 
     78    harness.ok(threw, "Should have thrown.")
     79 
     80    parser = parser.reset()
     81    threw = False
     82    try:
     83        parser.parse(
     84            """
     85            callback interface I {
     86              [PutForwards=B] readonly attribute J A;
     87            };
     88            interface J {
     89              attribute long B;
     90            };
     91        """
     92        )
     93 
     94        parser.finish()
     95    except WebIDL.WebIDLError:
     96        threw = True
     97 
     98    harness.ok(threw, "Should have thrown.")
     99 
    100    parser = parser.reset()
    101    threw = False
    102    try:
    103        parser.parse(
    104            """
    105            interface I {
    106              [PutForwards=C] readonly attribute J A;
    107              [PutForwards=C] readonly attribute J B;
    108            };
    109            interface J {
    110              [PutForwards=D] readonly attribute K C;
    111            };
    112            interface K {
    113              [PutForwards=A] readonly attribute I D;
    114            };
    115        """
    116        )
    117 
    118        parser.finish()
    119    except WebIDL.WebIDLError:
    120        threw = True
    121 
    122    harness.ok(threw, "Should have thrown.")
    123 
    124    parser = parser.reset()
    125    threw = False
    126    try:
    127        parser.parse(
    128            """
    129            interface I {
    130              [PutForwards=B] readonly attribute K A;
    131            };
    132            interface J {
    133              readonly attribute long B;
    134            };
    135            interface K : J {
    136            };
    137        """
    138        )
    139 
    140        parser.finish()
    141    except WebIDL.WebIDLError:
    142        threw = True
    143 
    144    harness.ok(
    145        not threw,
    146        "PutForwards should be able to forward to an attribute on an "
    147        "inherited interface.",
    148    )