summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/fetch-later/resources
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/fetch/fetch-later/resources
parentInitial commit. (diff)
downloadfirefox-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/fetch/fetch-later/resources')
-rw-r--r--testing/web-platform/tests/fetch/fetch-later/resources/fetch-later.html14
-rw-r--r--testing/web-platform/tests/fetch/fetch-later/resources/header-referrer-helper.js39
2 files changed, 53 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fetch/fetch-later/resources/fetch-later.html b/testing/web-platform/tests/fetch/fetch-later/resources/fetch-later.html
new file mode 100644
index 0000000000..b569e1a076
--- /dev/null
+++ b/testing/web-platform/tests/fetch/fetch-later/resources/fetch-later.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<head>
+</head>
+<body>
+ <script>
+ const PARAMS = new URL(location.href).searchParams;
+ const TARGET_URL= decodeURIComponent(PARAMS.get('url')) || '';
+
+ fetchLater(TARGET_URL, {activateAfter: 0});
+ if (window.opener) {
+ window.opener.postMessage("done", "*");
+ }
+ </script>
+</body>
diff --git a/testing/web-platform/tests/fetch/fetch-later/resources/header-referrer-helper.js b/testing/web-platform/tests/fetch/fetch-later/resources/header-referrer-helper.js
new file mode 100644
index 0000000000..374097614a
--- /dev/null
+++ b/testing/web-platform/tests/fetch/fetch-later/resources/header-referrer-helper.js
@@ -0,0 +1,39 @@
+'use strict';
+
+// https://w3c.github.io/webappsec-referrer-policy/#determine-requests-referrer
+const REFERRER_ORIGIN = self.location.origin + '/';
+const REFERRER_URL = self.location.href;
+
+function testReferrerHeader(id, host, expectedReferrer) {
+ const url = `${
+ host}/beacon/resources/inspect-header.py?header=referer&cmd=put&id=${id}`;
+
+ promise_test(t => {
+ fetchLater(url, {activateAfter: 0});
+ return pollResult(expectedReferrer, id).then(result => {
+ assert_equals(result, expectedReferrer, 'Correct referrer header result');
+ });
+ }, `Test referer header ${host}`);
+}
+
+function pollResult(expectedReferrer, id) {
+ const checkUrl =
+ `/beacon/resources/inspect-header.py?header=referer&cmd=get&id=${id}`;
+
+ return new Promise(resolve => {
+ function checkResult() {
+ fetch(checkUrl).then(response => {
+ assert_equals(
+ response.status, 200, 'Inspect header response\'s status is 200');
+ let result = response.headers.get('x-request-referer');
+
+ if (result != undefined) {
+ resolve(result);
+ } else {
+ step_timeout(checkResult.bind(this), 100);
+ }
+ });
+ }
+ checkResult();
+ });
+}