summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/import-assertions/invalid-import-errors-order.html
blob: 17c95faea0f80ae089e2fb84d075e174ae954450 (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
<!DOCTYPE html>
<title>Handling of invalid module type import attributes</title>

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
    setup({allow_uncaught_exception: true});

    var log = [];
    window.addEventListener("error", ev => log.push(ev.error));

    const test_load = async_test(
        "Test that the errors order for invalid import declarations is" +
        " specifier, then attribute key, and then type attribute value.");
    window.addEventListener("load", test_load.step_func_done(ev => {
      assert_equals(log.length, 3);
      assert_equals(log[0].constructor, SyntaxError);
      assert_equals(log[1].constructor, SyntaxError);
      assert_equals(log[2].constructor, SyntaxError);
    }));

    function unreachable() { log.push("unexpected"); }
</script>
<script type="module" onerror="unreachable()">
  // unknown attribute is reported before invalid specifier
  import "INVALID" assert { unknown: "foo" };
</script>
<script type="module" onerror="unreachable()">
  // unknown attribute is reported before unknown type
  import "./valid" assert { unknown: "foo", type: "unknown" };
</script>
<script type="module" onerror="unreachable()">
  // unknown attribute is reported before invalid specifier in subsequent import
  import "./valid" assert { unknown: "foo" };
  import "INVALID";
</script>