diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/execorder.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/execorder.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/execorder.html | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/execorder.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/execorder.html new file mode 100644 index 0000000000..6a7513dc13 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/execorder.html @@ -0,0 +1,106 @@ +<!doctype html> +<html> +<head> + <title>html-script-module-execOrder</title> + <meta name=timeout content=long> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script> + + var execCounts = [ + 0, // test_parsedOrdered + 0, // test_dynamicOrdered + ]; + function assert_execCount(set, expected, description) + { + if (!execCounts[set]) + { + execCounts[set] = 0; + } + assert_equals(++execCounts[set], expected, description); + } + + function create_script(src, opts) + { + var element = document.createElement("script"); + element.src = src; + element.async = (opts.asyncOrdered ? false : true); + element.type = (opts.module ? "module" : "text/javascript"); + document.body.appendChild(element); + } + + </script> +</head> +<body> + <h1>html-script-module-execOrder</h1> + <script> + + ///// + // Start test_parsedUnordered* + ///// + var test_parsedUnordered1 = async_test("Unordered module script execution (parsed, unordered #1)"); + var test_parsedUnordered2 = async_test("Unordered module script execution (parsed, unordered #2)"); + </script> + <script type="module" src="execorder-parsedunordered1.js"></script> + <script type="module" src="execorder-parsedunordered2.js"></script> + <script> + ///// + // End test_parsedUnordered* + ///// + + ///// + // Start test_dynamicUnordered* + ///// + var test_dynamicUnordered1 = async_test("Unordered module script execution (dynamic, unordered #1)"); + var test_dynamicUnordered2 = async_test("Unordered module script execution (dynamic, unordered #2)"); + create_script("execorder-dynamicunordered1.js", { module: true }); + create_script("execorder-dynamicunordered2.js", { module: true }); + ///// + // End test_dynamicUnordered* + ///// + + ///// + // Begin test_parsedOrdered + ///// + var test_parsedOrdered = async_test("Interlaced module/non-module script execution (parsed, async-ordered)"); + window.addEventListener("load", test_parsedOrdered.step_func(function() { + assert_execCount(0, 5, "onload should have fired fifth"); + test_parsedOrdered.done(); + })); + </script> + <script src="execorder-parsedordered2.js" defer></script> + <script type="module"> + test_parsedOrdered.step(function() { + assert_execCount(0, 3, "Inline module-typed script element should have fired third"); + }); + </script> + <script src="execorder-parsedordered4.js" defer></script> + <script> + test_parsedOrdered.step(function() { + assert_execCount(0, 1, "Inline untyped script element should have fired first"); + }); + ///// + // End test_parsedOrdered + ///// + + ///// + // Start test_dynamicOrdered + ///// + var test_dynamicOrdered = async_test("Interlaced module/non-module script execution (dynamic, async-ordered)"); + window.addEventListener("load", test_dynamicOrdered.step_func(function() { + assert_execCount(1, 5, "onload should have fired fifth (last)"); + test_dynamicOrdered.done(); + })); + create_script("execorder-dynamicordered2.js", { asyncOrdered: true, module: false }); + create_script("execorder-dynamicordered3.js", { asyncOrdered: true, module: true }); + create_script("execorder-dynamicordered4.js", { asyncOrdered: true, module: false }); + test_dynamicOrdered.step(function() { + assert_execCount(1, 1, "Inline untyped script element should have fired first"); + }); + ///// + // End test_dynamicOrdered + ///// + + </script> +</body> +</html> |