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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-event.html

Issue 1816473002: Add layout tests to check that a FetchEvent includes the right headers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODO Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script> 4 <script src="resources/test-helpers.js"></script>
5 <body> 5 <body>
6 <script> 6 <script>
7 var worker = 'resources/fetch-event-test-worker.js'; 7 var worker = 'resources/fetch-event-test-worker.js';
8 8
9 async_test(function(t) { 9 async_test(function(t) {
10 var scope = 'resources/simple.html?headers';
11 service_worker_unregister_and_register(t, worker, scope)
12 .then(function(reg) {
13 return wait_for_state(t, reg.installing, 'activated');
14 })
15 .then(function() { return with_iframe(scope); })
16 .then(function(frame) {
17 // We have this test to prevent unexpected exposure of headers to a
18 // ServiceWorker. Feel free to rebaseline this expectation if it
19 // looks good.
20 var headers = JSON.parse(frame.contentDocument.body.textContent);
21 var header_names = [];
22 for (var i in headers) {
yhirano 2016/07/19 07:28:40 Can we use the destructuring syntax? for (const [
tyoshino (SeeGerritForStatus) 2016/07/19 08:50:31 Done.
23 header_names.push(headers[i][0]);
24 }
25 header_names.sort();
26 assert_array_equals(
27 header_names,
28 ["accept", "upgrade-insecure-requests", "user-agent"],
Mike West 2016/07/19 07:22:13 This is a navigational request, right? If so, LGTM
tyoshino (SeeGerritForStatus) 2016/07/19 07:26:08 Right. It's listing what the request for loading t
29 'event.request has the expected headers.');
30
31 frame.remove();
32 return service_worker_unregister_and_done(t, scope);
33 })
34 .catch(unreached_rejection(t));
35 }, 'Service Worker headers in the request of a fetch event');
36
37 async_test(function(t) {
10 var scope = 'resources/simple.html?string'; 38 var scope = 'resources/simple.html?string';
11 service_worker_unregister_and_register(t, worker, scope) 39 service_worker_unregister_and_register(t, worker, scope)
12 .then(function(reg) { 40 .then(function(reg) {
13 return wait_for_state(t, reg.installing, 'activated'); 41 return wait_for_state(t, reg.installing, 'activated');
14 }) 42 })
15 .then(function() { return with_iframe(scope); }) 43 .then(function() { return with_iframe(scope); })
16 .then(function(frame) { 44 .then(function(frame) {
17 assert_equals( 45 assert_equals(
18 frame.contentDocument.body.textContent, 46 frame.contentDocument.body.textContent,
19 'Test string', 47 'Test string',
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 'event.respondWith must set the used flag.'); 276 'event.respondWith must set the used flag.');
249 first_frame.remove(); 277 first_frame.remove();
250 frame.remove(); 278 frame.remove();
251 return service_worker_unregister_and_done(t, scope); 279 return service_worker_unregister_and_done(t, scope);
252 }) 280 })
253 .catch(unreached_rejection(t)); 281 .catch(unreached_rejection(t));
254 }, 'Service Worker event.respondWith must set the used flag'); 282 }, 'Service Worker event.respondWith must set the used flag');
255 283
256 </script> 284 </script>
257 </body> 285 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698