summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html')
-rw-r--r--testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html39
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html
new file mode 100644
index 0000000000..d2e0f185e0
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/module/import-meta/import-meta-resolve-multiple-scripts.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<iframe src="resources/store-import-meta.html"></iframe>
+
+<script type="module">
+import * as otherImportMeta from "./resources/export-import-meta.mjs";
+setup({ explicit_done: true });
+
+window.onload = () => {
+ test(() => {
+ assert_not_equals(frames[0].importMetaURL, import.meta.url,
+ "Precondition check: we've set things up so that the other script has a different import.meta.url");
+
+ const expected = (new URL("resources/x", location.href)).href;
+ assert_equals(frames[0].importMetaResolve("./x"), expected);
+ }, "import.meta.resolve resolves URLs relative to the import.meta.url, not relative to the active script when it is called: another global's inline script");
+
+ test(() => {
+ const otherFrameImportMetaResolve = frames[0].importMetaResolve;
+
+ document.querySelector("iframe").remove();
+
+ const expected = (new URL("resources/x", location.href)).href;
+ assert_equals(otherFrameImportMetaResolve("./x"), expected);
+ }, "import.meta.resolve still works if its global has been destroyed (by detaching the iframe)");
+
+ test(() => {
+ assert_not_equals(otherImportMeta.url, import.meta.url,
+ "Precondition check: we've set things up so that the other script has a different import.meta.url");
+
+ const expected = (new URL("resources/x", location.href)).href;
+ assert_equals(otherImportMeta.resolve("./x"), expected);
+ }, "import.meta.resolve resolves URLs relative to the import.meta.url, not relative to the active script when it is called: another module script");
+
+ done();
+};
+</script>