Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / serviceworker / fetch-event-respond-with-argument.html
blobba69cc76b5e5282efff70e71971e458f75b7b4a4
1 <!DOCTYPE html>
2 <title>Service Worker: FetchEvent.respondWith() argument type test.</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharness-helpers.js"></script>
5 <script src="../resources/testharnessreport.js"></script>
6 <script src="resources/test-helpers.js"></script>
7 <script>
8 var resolve_test_done;
10 var test_done_promise = new Promise(function(resolve) {
11 resolve_test_done = resolve;
12 });
14 // Called by the child frame.
15 function notify_test_done(result) {
16 resolve_test_done(result);
19 promise_test(function(t) {
20 var scope = 'resources/fetch-event-respond-with-argument-iframe.html';
21 var script = 'resources/fetch-event-respond-with-argument-worker.js';
22 var frame;
24 return service_worker_unregister_and_register(t, script, scope)
25 .then(function(registration) {
26 return wait_for_state(t, registration.installing, 'activated');
28 .then(function() {
29 return with_iframe(scope);
31 .then(function(f) {
32 frame = f;
33 return test_done_promise;
35 .then(function(result) {
36 frame.remove();
37 assert_equals(result, 'PASS');
38 return service_worker_unregister_and_done(t, scope);
39 });
40 }, 'respondWith() takes either a Response or a promise that resolves ' +
41 'with a Response. Other values should raise a network error.');
42 </script>