Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/scripting-1/the-script-element/inline-module-order.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset=utf-8>
<title>Execution order of non-parser created inline module scripts</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<!-- Ensure imported module is already in the module map -->
<script type="module" src="./support/empty_module.js"></script>
<div id="parent"></div>
<script>
let result = [];
function createInlineModuleScript(source) {
let parent = document.getElementById("parent");
let script = document.createElement("script");
script.type = "module";
script.textContent = source;
parent.appendChild(script);
}
promise_test(async test => {
await new Promise(resolve => window.onload = resolve);
createInlineModuleScript(`
import {} from "./support/empty_module.js";
result.push(1);
`);
createInlineModuleScript(`
result.push(2);
`);
await test.step_wait(() => result.length == 2, "Wait for both scripts to be executed", 1000);
test.step(() => assert_array_equals(result, [2, 1],
"Check expected execution order"));
test.done();
}, "Execution order of non-parser created inline module scripts");
</script>