summaryrefslogtreecommitdiffstats
path: root/dom/bindings/parser/tests/test_promise.py
blob: 55bc07680921260429f2120a3659de235ba193a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def WebIDLTest(parser, harness):
    threw = False
    try:
        parser.parse("""
            interface _Promise {};
            interface A {
              legacycaller Promise<any> foo();
            };
        """)
        results = parser.finish()

    except:
        threw = True
    harness.ok(threw,
               "Should not allow Promise return values for legacycaller.")

    parser = parser.reset()
    threw = False
    try:
        parser.parse("""
            interface _Promise {};
            interface A {
              Promise<any> foo();
              long foo(long arg);
            };
        """)
        results = parser.finish();
    except:
        threw = True
    harness.ok(threw,
               "Should not allow overloads which have both Promise and "
               "non-Promise return types.")

    parser = parser.reset()
    threw = False
    try:
        parser.parse("""
            interface _Promise {};
            interface A {
              long foo(long arg);
              Promise<any> foo();
            };
        """)
        results = parser.finish();
    except:
        threw = True
    harness.ok(threw,
               "Should not allow overloads which have both Promise and "
               "non-Promise return types.")

    parser = parser.reset()
    parser.parse("""
        interface _Promise {};
        interface A {
          Promise<any> foo();
          Promise<any> foo(long arg);
        };
    """)
    results = parser.finish();

    harness.ok(True,
               "Should allow overloads which only have Promise and return "
               "types.")