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/dynamic-import/string-compilation-base-url-external-module.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/dynamic-import/string-compilation-base-url-external-module.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-base-url-external-module.html | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-base-url-external-module.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-base-url-external-module.html new file mode 100644 index 0000000000..d90af9c96a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-base-url-external-module.html @@ -0,0 +1,64 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>import() inside compiled strings uses the script base URL inside a module script that is loaded from a file</title> +<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<div id="dummy"></div> + +<base href="scripts/foo/"> +<script type="module"> +// Tweak the base URL of the document here to distinguish: +// - document URL +// - document base URL = ../ +// - External scripts' base URL = ./scripts/eval.js etc. +// - This inline script's base URL = ./scripts/foo/ +document.querySelector("base").remove(); +const base = document.createElement("base"); +base.setAttribute("href", "../"); +document.body.appendChild(base); + +function load(scriptSrc) { + const el = document.createElement("script"); + el.type = "module"; + el.src = scriptSrc; + document.body.appendChild(el); +} + +function createTestPromise() { + return new Promise((resolve, reject) => { + window.dummyDiv.removeAttribute("onclick"); + delete window.evaluated_imports_a; + delete window.label; + + window.continueTest = resolve; + window.errorTest = reject; + }); +} + +window.dummyDiv = document.querySelector("#dummy"); + +const evaluators = [ + "setTimeout", + "eval", + "Function", + "reflected-inline-event-handlers", + "inline-event-handlers-UA-code" +]; + +for (const label of evaluators) { + promise_test(() => { + const promise = createTestPromise(); + + window.label = label; + load(`dynamic-import/scripts/${label}.js`); + + return promise.then(module => { + assert_true(window.evaluated_imports_a, "The module must have been evaluated"); + assert_equals(module.A.from, "imports-a.js", "The module namespace object must be correct"); + }); + }, label + " should successfully import"); +}; +</script> |