1
0
Fork 0
firefox/testing/web-platform/tests/import-maps/not-overridden/external-script-bare-descendent.html
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

52 lines
1.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script type="importmap">
{
"imports": {
"a": "../resources/log.sub.js?name=A",
"foo/bar": "../resources/log.sub.js?name=FOOBAR"
}
}
</script>
<script type="module" src="../resources/importer.sub.js?name=a"></script>
<script type="module" src="../resources/importer.sub.js?name=foo/bar"></script>
<script>
const log = [];
// Try to redefine the descendent with an import map
</script>
<script type="importmap">
{
"imports": {
"a": "../resources/log.sub.js?name=B",
"foo/bar": "../resources/log.sub.js?name=OtherFoobar",
"foo/": "../resources/log.sub.js?name=OtherFoo",
"foo": "../resources/log.sub.js?name=foo"
}
}
</script>
<script type="module">
// Testing that the resolution is correct using `resolve`, as you can't import
// the same module twice.
test(() => {
assert_true(import.meta.resolve("a").endsWith("/resources/log.sub.js?name=A"));
}, "Resolution after import map should not be redefined");
test(() => {
assert_true(import.meta.resolve("foo/bar").endsWith("/resources/log.sub.js?name=FOOBAR"));
}, "Resolution after import map should not be redefined for bare prefixes or exact matches");
test(() => {
assert_true(import.meta.resolve("foo").endsWith("/resources/log.sub.js?name=foo"));
}, "Resolution after import map should be redefined for non-prefixes");
</script>
</body>
</html>