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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/fetch-event.https.html

Issue 2836233002: Upstream service worker `fetch` tests to WPT (Closed)
Patch Set: Created 3 years, 7 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="/common/get-host-info.sub.js"></script> 4 <script src="/common/get-host-info.sub.js"></script>
5 <script src="resources/test-helpers.sub.js"></script> 5 <script src="resources/test-helpers.sub.js"></script>
6 <body> 6 <body>
7 <script> 7 <script>
8 var worker = 'resources/fetch-event-test-worker.js'; 8 var worker = 'resources/fetch-event-test-worker.js';
9 9
10 async_test(function(t) { 10 async_test(function(t) {
Marijn Kruisselbrink 2017/04/27 17:05:23 nit: I suppose this whole file predates the existe
mike3 2017/04/27 18:27:19 Agreed. I'm trying to avoid changes that are not s
11 const scope = 'resources/simple.html?headers';
12 service_worker_unregister_and_register(t, worker, scope)
13 .then(function(reg) {
14 return wait_for_state(t, reg.installing, 'activated');
15 })
16 .then(function() { return with_iframe(scope); })
17 .then(function(frame) {
18 t.add_cleanup(function() { frame.remove(); });
19 const headers = JSON.parse(frame.contentDocument.body.textContent);
20 const header_names = {};
21 for (const [name, value] of headers) {
22 header_names[name] = true;
23 }
24
25 assert_true(
26 header_names.hasOwnProperty('accept'),
27 'request includes "Accept" header as inserted by Fetch'
28 );
29 assert_true(
30 header_names.hasOwnProperty('upgrade-insecure-requests'),
31 'request specifies "Upgrade-Insecure Requests header as inserted by Fetch'
32 );
33
34 return service_worker_unregister_and_done(t, scope);
35 })
36 .catch(unreached_rejection(t));
37 }, 'Service Worker headers in the request of a fetch event');
38
39 async_test(function(t) {
11 var scope = 'resources/simple.html?string'; 40 var scope = 'resources/simple.html?string';
12 service_worker_unregister_and_register(t, worker, scope) 41 service_worker_unregister_and_register(t, worker, scope)
13 .then(function(reg) { 42 .then(function(reg) {
14 return wait_for_state(t, reg.installing, 'activated'); 43 return wait_for_state(t, reg.installing, 'activated');
15 }) 44 })
16 .then(function() { return with_iframe(scope); }) 45 .then(function() { return with_iframe(scope); })
17 .then(function(frame) { 46 .then(function(frame) {
18 assert_equals( 47 assert_equals(
19 frame.contentDocument.body.textContent, 48 frame.contentDocument.body.textContent,
20 'Test string', 49 'Test string',
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return frame.contentWindow.fetch(http_url, 312 return frame.contentWindow.fetch(http_url,
284 {referrerPolicy: "strict-origin-when- cross-origin", referrer: referrer}); 313 {referrerPolicy: "strict-origin-when- cross-origin", referrer: referrer});
285 }) 314 })
286 .then(function(response) { return response.text(); }) 315 .then(function(response) { return response.text(); })
287 .then(function(response_text) { 316 .then(function(response_text) {
288 assert_equals( 317 assert_equals(
289 response_text, 318 response_text,
290 'Referrer: \n' + 319 'Referrer: \n' +
291 'ReferrerPolicy: strict-origin-when-cross-origin', 320 'ReferrerPolicy: strict-origin-when-cross-origin',
292 'Service Worker should respond to fetch with no referrer with "stric t-origin-when-cross-origin" and a HTTP request'); 321 'Service Worker should respond to fetch with no referrer with "stric t-origin-when-cross-origin" and a HTTP request');
293 }); 322 });
Marijn Kruisselbrink 2017/04/27 17:05:23 and it seems this one test is a great example of w
mike3 2017/04/27 18:27:19 The result of this particularly lengthy promise ch
294 } 323 }
295 324
296 async_test(function(t) { 325 async_test(function(t) {
297 var scope = 'resources/simple.html?referrerPolicy'; 326 var scope = 'resources/simple.html?referrerPolicy';
298 var frame; 327 var frame;
299 service_worker_unregister_and_register(t, worker, scope) 328 service_worker_unregister_and_register(t, worker, scope)
300 .then(function(reg) { 329 .then(function(reg) {
301 return wait_for_state(t, reg.installing, 'activated'); 330 return wait_for_state(t, reg.installing, 'activated');
302 }) 331 })
303 .then(function() { return with_iframe(scope); }) 332 .then(function() { return with_iframe(scope); })
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 .then(response_text => { 678 .then(response_text => {
650 assert_equals(response_text, integrity_metadata, 'integrity'); 679 assert_equals(response_text, integrity_metadata, 'integrity');
651 frame.remove(); 680 frame.remove();
652 return service_worker_unregister_and_done(t, scope); 681 return service_worker_unregister_and_done(t, scope);
653 }) 682 })
654 .catch(unreached_rejection(t)); 683 .catch(unreached_rejection(t));
655 }, 'Service Worker responds to fetch event with the correct integrity_metadata '); 684 }, 'Service Worker responds to fetch event with the correct integrity_metadata ');
656 685
657 </script> 686 </script>
658 </body> 687 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698