Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium.fetch-event-headers.html

Issue 2836233002: Upstream service worker `fetch` tests to WPT (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium.fetch-event-headers.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium.fetch-event-headers.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium.fetch-event-headers.html
new file mode 100644
index 0000000000000000000000000000000000000000..54bca8930f307df80b1ea8aed04e658230132fe2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/chromium.fetch-event-headers.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<!-- This test is prefixed with `chromium.` because it asserts a precise list
+ of expected header names, but but such precision is not mandated by the
+ relevant specifications. It should be maintained only to the extent that this
+ precision is relevant to Chromium internals; the Web Platform Tests project
+ includes a relaxed version which allows for additional headers. -->
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
+<body>
+<script>
+var worker = 'resources/fetch-event-test-worker.js';
+
+async_test(function(t) {
Marijn Kruisselbrink 2017/04/27 17:05:23 nit: promise_test?
mike3 2017/04/27 18:27:19 Acknowledged.
+ const scope = 'resources/simple.html?headers';
+ service_worker_unregister_and_register(t, worker, scope)
+ .then(function(reg) {
+ return wait_for_state(t, reg.installing, 'activated');
+ })
+ .then(function() { return with_iframe(scope); })
+ .then(function(frame) {
+ t.add_cleanup(function() { frame.remove(); });
+ // We have this test to prevent unexpected exposure of headers to a
+ // ServiceWorker. Feel free to rebaseline this expectation if it
+ // looks good.
+ const headers = JSON.parse(frame.contentDocument.body.textContent);
+ const header_names = [];
+ for (const [name, value] of headers) {
+ header_names.push(name);
+ }
+ header_names.sort();
+ assert_array_equals(
+ header_names,
+ ["accept", "upgrade-insecure-requests", "user-agent"],
+ 'event.request has the expected headers.');
+
+ return service_worker_unregister_and_done(t, scope);
+ })
+ .catch(unreached_rejection(t));
+ }, 'Service Worker headers in the request of a fetch event');
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698