Skip to content

Commit 343bf53

Browse files
Script: Add execution timing test for no-import module script
Both Chrome and Safari agree that module scripts with no imports run asynchronously, per the semi-ambiguous language in the HTML Standard discussed in whatwg/html#3746, despite the script being "ready" immediately. Firefox seems to implement the spec correctly, regarding the "readiness" being synchronous, however with 2/3 implementations *not* implementing the spec in this regard, and an open spec issue in this area, I find it unlikely that Chromium's will change its behavior (for compat). I'll recommend on the spec issue that we change the spec to match Safari and Chrome, and land this test asserting the majority behavior. [email protected] Bug: N/A Change-Id: Ibeac277ab357b62e7d0a5e4afb5f95818a2d4005
1 parent d2b96f3 commit 343bf53

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Module scripts with no imports always execute asynchronously</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<link rel="help" href="https://github.com/whatwg/html/issues/3746">
8+
</head>
9+
<body>
10+
<script>
11+
async_test(t => {
12+
window.results = [];
13+
window.logExecution = msg => window.results.push(msg);
14+
15+
const script = document.createElement('script');
16+
script.type = 'module';
17+
script.textContent = "window.logExecution('module')";
18+
document.body.append(script);
19+
window.logExecution('classic');
20+
21+
window.onload = t.step_func_done(e => {
22+
assert_array_equals(window.results, ['classic', 'module']);
23+
});
24+
}, document.title);
25+
</script>
26+
</body>
27+
</html>

0 commit comments

Comments
 (0)