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

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: Use const 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 const 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 const headers = JSON.parse(frame.contentDocument.body.textContent);
21 const header_names = [];
22 for (const [name, value] of headers) {
23 header_names.push(name);
24 }
25 header_names.sort();
26 assert_array_equals(
27 header_names,
28 ["accept", "upgrade-insecure-requests", "user-agent"],
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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698