diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-importmap.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
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/import-meta/import-meta-resolve-importmap.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-importmap.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-importmap.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-importmap.html new file mode 100644 index 0000000000..214b9bb59c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-importmap.html @@ -0,0 +1,57 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<!-- + More extensive tests of import maps and import.meta.resolve() will be + located in the import maps test suite. This contains some basic tests plus + tests some tricky parts of the import.meta.resolve() algorithm around string + conversion which are only testable with import maps. +--> + +<script type="importmap"> +{ + "imports": { + "bare": "https://example.com/", + "https://example.com/rewrite": "https://example.com/rewritten", + + "1": "https://example.com/PASS-1", + "null": "https://example.com/PASS-null", + "undefined": "https://example.com/PASS-undefined", + "[object Object]": "https://example.com/PASS-object", + + "./start": "./resources/export-1.mjs", + "./resources/export-1.mjs": "./resources/export-2.mjs" + } +} +</script> + +<script type="module"> +test(() => { + assert_equals(import.meta.resolve("bare"), "https://example.com/"); +}, "import.meta.resolve() given an import mapped bare specifier"); + +test(() => { + assert_equals(import.meta.resolve("https://example.com/rewrite"), "https://example.com/rewritten"); +}, "import.meta.resolve() given an import mapped URL-like specifier"); + +test(() => { + assert_equals(import.meta.resolve(), "https://example.com/PASS-undefined", "no-arg case"); + + assert_equals(import.meta.resolve(1), "https://example.com/PASS-1"); + assert_equals(import.meta.resolve(null), "https://example.com/PASS-null"); + assert_equals(import.meta.resolve(undefined), "https://example.com/PASS-undefined"); + + // Only toString() methods are consulted by ToString, not valueOf() ones. + // So this becomes "[object Object]". + assert_equals(import.meta.resolve({ valueOf() { return "./x"; } }), "https://example.com/PASS-object"); +}, "Testing the ToString() step of import.meta.resolve() via import maps"); + +promise_test(async () => { + const one = (await import("./start")).default; + assert_equals(one, 1); + + const two = (await import(import.meta.resolve("./start"))).default; + assert_equals(two, 2); +}, "import(import.meta.resolve(x)) can be different from import(x)"); +</script> |