Skip to content

Commit 111bef1

Browse files
nicolo-ribaudomoz-wptsync-bot
authored andcommitted
Bug 1837625 [wpt PR 40474] - Add test for referrer in module imports, a=testonly
Automatic update from web-platform-tests Add test for referrer in module imports Follows whatwg/html#9407. -- wpt-commits: 66166fa9af2d53656da3f04a0f5e114e740a00c7 wpt-pr: 40474
1 parent b5be2e2 commit 111bef1

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Referrer for module imports</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script>setup({ explicit_done: true })</script>
8+
</head>
9+
<body>
10+
<script type="module">
11+
12+
import { referrerExternalStatic, referrerExternalDynamic } from "./module-import-referrer.js";
13+
14+
// "name" parameter is necessary for bypassing the module map.
15+
import { referrer as referrerInlineStatic } from "./resources/referrer-checker.py?name=internal-static"
16+
const { referrer: referrerInlineDynamic } = await import("./resources/referrer-checker.py?name=internal-dynamic");
17+
18+
const scriptURL = new URL("module-import-referrer.js", location.href)
19+
20+
test(t => {
21+
assert_equals(
22+
referrerInlineStatic, location.href,
23+
"Referrer should be the document URL");
24+
}, "Static imports from inline modules in the HTML document");
25+
26+
test(t => {
27+
assert_equals(
28+
referrerInlineDynamic, location.href,
29+
"Referrer should be the document URL");
30+
}, "Dynamic imports from inline modules in the HTML document");
31+
32+
test(t => {
33+
assert_equals(
34+
referrerExternalStatic, scriptURL.href,
35+
"Referrer should be the importer module URL");
36+
}, "Static imports from external modules");
37+
38+
test(t => {
39+
assert_equals(
40+
referrerExternalDynamic, scriptURL.href,
41+
"Referrer should be the document URL");
42+
}, "Dynamic imports from external modules");
43+
44+
done();
45+
46+
</script>
47+
</body>
48+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { referrer as referrerExternalStatic } from "./resources/referrer-checker.py?name=external-static"
2+
export const { referrer: referrerExternalDynamic } = await import("./resources/referrer-checker.py?name=external-dynamic");

0 commit comments

Comments
 (0)