From 7865060cb5f2cf19d6baf01fba2a693b6f5b2877 Mon Sep 17 00:00:00 2001 From: Mike West Date: Wed, 10 Mar 2021 21:12:20 +0000 Subject: [PATCH] Bug 1695941 [wpt PR 27857] - WPT: `Sec-Fetch-*` headers aren't accessible in service workers., a=testonly Automatic update from web-platform-tests WPT: `Sec-Fetch-*` headers aren't accessible in service workers. As requested in https://github.com/whatwg/fetch/pull/993. Change-Id: Ie6096154ad9f6af73e2c26e0bb0c8f72a2a7a99a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2727263 Reviewed-by: Matt Falkenhagen Commit-Queue: Mike West Cr-Commit-Position: refs/heads/master@{#859345} -- wpt-commits: df6a144d964283f2929eeb937af2806d9aafec62 wpt-pr: 27857 --- .../serviceworker-accessors-frame.html | 3 ++ .../resources/serviceworker-accessors.sw.js | 14 +++++ .../serviceworker-accessors.https.sub.html | 51 +++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 testing/web-platform/tests/fetch/metadata/resources/serviceworker-accessors-frame.html create mode 100644 testing/web-platform/tests/fetch/metadata/resources/serviceworker-accessors.sw.js create mode 100644 testing/web-platform/tests/fetch/metadata/serviceworker-accessors.https.sub.html diff --git a/testing/web-platform/tests/fetch/metadata/resources/serviceworker-accessors-frame.html b/testing/web-platform/tests/fetch/metadata/resources/serviceworker-accessors-frame.html new file mode 100644 index 0000000000000..9879802500549 --- /dev/null +++ b/testing/web-platform/tests/fetch/metadata/resources/serviceworker-accessors-frame.html @@ -0,0 +1,3 @@ + + +Page Title diff --git a/testing/web-platform/tests/fetch/metadata/resources/serviceworker-accessors.sw.js b/testing/web-platform/tests/fetch/metadata/resources/serviceworker-accessors.sw.js new file mode 100644 index 0000000000000..36c55a778600f --- /dev/null +++ b/testing/web-platform/tests/fetch/metadata/resources/serviceworker-accessors.sw.js @@ -0,0 +1,14 @@ +addEventListener("fetch", event => { + event.waitUntil(async function () { + if (!event.clientId) return; + const client = await clients.get(event.clientId); + if (!client) return; + + client.postMessage({ + "dest": event.request.headers.get("sec-fetch-dest"), + "mode": event.request.headers.get("sec-fetch-mode"), + "site": event.request.headers.get("sec-fetch-site"), + "user": event.request.headers.get("sec-fetch-user") + }); + }()); +}); diff --git a/testing/web-platform/tests/fetch/metadata/serviceworker-accessors.https.sub.html b/testing/web-platform/tests/fetch/metadata/serviceworker-accessors.https.sub.html new file mode 100644 index 0000000000000..03a8321d4cab5 --- /dev/null +++ b/testing/web-platform/tests/fetch/metadata/serviceworker-accessors.https.sub.html @@ -0,0 +1,51 @@ + + + + + + + + +