inline-module-order.html (1233B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>Execution order of non-parser created inline module scripts</title> 4 <script src=/resources/testharness.js></script> 5 <script src=/resources/testharnessreport.js></script> 6 7 <!-- Ensure imported module is already in the module map --> 8 <script type="module" src="./support/empty_module.js"></script> 9 10 <div id="parent"></div> 11 12 <script> 13 let result = []; 14 15 function createInlineModuleScript(source) { 16 let parent = document.getElementById("parent"); 17 let script = document.createElement("script"); 18 script.type = "module"; 19 script.textContent = source; 20 parent.appendChild(script); 21 } 22 23 promise_test(async test => { 24 await new Promise(resolve => window.onload = resolve); 25 26 createInlineModuleScript(` 27 import {} from "./support/empty_module.js"; 28 result.push(1); 29 `); 30 31 createInlineModuleScript(` 32 result.push(2); 33 `); 34 35 await test.step_wait(() => result.length == 2, "Wait for both scripts to be executed", 1000); 36 test.step(() => assert_array_equals(result, [1, 2], 37 "Check expected execution order")); 38 test.done(); 39 }, "Execution order of non-parser created inline module scripts"); 40 </script>