blob: 8c438f626b79b4e2f2fd5b0729b422af043f5cfb (
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" with { unknown: "foo" };
</script>
<script type="module" onerror="unreachable()">
// unknown attribute is reported before unknown type
import "./valid" with { unknown: "foo", type: "unknown" };
</script>
<script type="module" onerror="unreachable()">
// unknown attribute is reported before invalid specifier in subsequent import
import "./valid" with { unknown: "foo" };
import "INVALID";
</script>
|