| OLD | NEW |
| 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) { |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 .then(function(frame) { | 509 .then(function(frame) { |
| 510 assert_equals( | 510 assert_equals( |
| 511 frame.contentDocument.body.textContent, | 511 frame.contentDocument.body.textContent, |
| 512 'Fragment Found :' + fragment, | 512 'Fragment Found :' + fragment, |
| 513 'Service worker should expose URL fragments in request.'); | 513 'Service worker should expose URL fragments in request.'); |
| 514 frame.remove(); | 514 frame.remove(); |
| 515 return service_worker_unregister_and_done(t, scope); | 515 return service_worker_unregister_and_done(t, scope); |
| 516 }) | 516 }) |
| 517 .catch(unreached_rejection(t)); | 517 .catch(unreached_rejection(t)); |
| 518 }, 'Service Worker should expose FetchEvent URL fragments.'); | 518 }, 'Service Worker should expose FetchEvent URL fragments.'); |
| 519 |
| 519 async_test(function(t) { | 520 async_test(function(t) { |
| 520 var scope = 'resources/simple.html?cache'; | 521 var scope = 'resources/simple.html?cache'; |
| 521 var frame; | 522 var frame; |
| 522 var cacheTypes = [ | 523 var cacheTypes = [ |
| 523 undefined, 'default', 'no-store', 'reload', 'no-cache', 'force-cache', 'on
ly-if-cached' | 524 undefined, 'default', 'no-store', 'reload', 'no-cache', 'force-cache', 'on
ly-if-cached' |
| 524 ]; | 525 ]; |
| 525 service_worker_unregister_and_register(t, worker, scope) | 526 service_worker_unregister_and_register(t, worker, scope) |
| 526 .then(function(reg) { | 527 .then(function(reg) { |
| 527 return wait_for_state(t, reg.installing, 'activated'); | 528 return wait_for_state(t, reg.installing, 'activated'); |
| 528 }) | 529 }) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 542 .then(function(response) { return response.text(); }) | 543 .then(function(response) { return response.text(); }) |
| 543 .then(function(response_text) { | 544 .then(function(response_text) { |
| 544 var expected = (type === undefined) ? 'default' : type; | 545 var expected = (type === undefined) ? 'default' : type; |
| 545 assert_equals(response_text, expected, | 546 assert_equals(response_text, expected, |
| 546 'Service Worker should respond to fetch with
the correct type'); | 547 'Service Worker should respond to fetch with
the correct type'); |
| 547 }) | 548 }) |
| 548 .then(resolve) | 549 .then(resolve) |
| 549 .catch(reject); | 550 .catch(reject); |
| 550 }); | 551 }); |
| 551 }); | 552 }); |
| 553 return Promise.all(tests); |
| 552 }) | 554 }) |
| 553 .then(function() { | 555 .then(function() { |
| 554 return new Promise(function(resolve, reject) { | 556 return new Promise(function(resolve, reject) { |
| 555 frame.addEventListener('load', function onLoad() { | 557 frame.addEventListener('load', function onLoad() { |
| 556 frame.removeEventListener('load', onLoad); | 558 frame.removeEventListener('load', onLoad); |
| 557 try { | 559 try { |
| 558 assert_equals(frame.contentWindow.document.body.textContent, | 560 assert_equals(frame.contentWindow.document.body.textContent, |
| 559 'no-cache'); | 561 'no-cache'); |
| 560 resolve(); | 562 resolve(); |
| 561 } catch (e) { | 563 } catch (e) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 return wait_for_state(t, reg.installing, 'activated'); | 634 return wait_for_state(t, reg.installing, 'activated'); |
| 633 }) | 635 }) |
| 634 .then(function() { return with_iframe(scope); }) | 636 .then(function() { return with_iframe(scope); }) |
| 635 .then(function(f) { | 637 .then(function(f) { |
| 636 frame = f; | 638 frame = f; |
| 637 // A request has associated integrity metadata (a string). | 639 // A request has associated integrity metadata (a string). |
| 638 // Unless stated otherwise, it is the empty string. | 640 // Unless stated otherwise, it is the empty string. |
| 639 assert_equals( | 641 assert_equals( |
| 640 frame.contentDocument.body.textContent, ''); | 642 frame.contentDocument.body.textContent, ''); |
| 641 | 643 |
| 642 return new Promise(function(resolve, reject) { | 644 return frame.contentWindow.fetch(scope, {'integrity': integrity_metada
ta}); |
| 643 return frame.contentWindow.fetch(scope, | |
| 644 {'integrity': integrity_metadata}) | |
| 645 .then(function(response) { | |
| 646 return response.text(); | |
| 647 }) | |
| 648 .then(function(response_text) { | |
| 649 // Should get the same integrity metadata. | |
| 650 assert_equals(response_text, integrity_metadata, | |
| 651 'Service Worker should respond to fetch with t
he correct integrity'); | |
| 652 }) | |
| 653 .then(resolve()) | |
| 654 .catch(reject()); | |
| 655 }); | |
| 656 }) | 645 }) |
| 657 .then(function() { | 646 .then(response => { |
| 647 return response.text(); |
| 648 }) |
| 649 .then(response_text => { |
| 650 assert_equals(response_text, integrity_metadata, 'integrity'); |
| 658 frame.remove(); | 651 frame.remove(); |
| 659 return service_worker_unregister_and_done(t, scope); | 652 return service_worker_unregister_and_done(t, scope); |
| 660 }) | 653 }) |
| 661 .catch(unreached_rejection(t)); | 654 .catch(unreached_rejection(t)); |
| 662 }, 'Service Worker responds to fetch event with the correct integrity_metadata
'); | 655 }, 'Service Worker responds to fetch event with the correct integrity_metadata
'); |
| 663 | 656 |
| 664 </script> | 657 </script> |
| 665 </body> | 658 </body> |
| OLD | NEW |