| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: FetchEvent for resources</title> | 2 <title>Service Worker: FetchEvent for resources</title> |
| 3 <script src="../resources/testharness.js"></script> | 3 <script src="../resources/testharness.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="../resources/get-host-info.js?pipe=sub"></script> | 5 <script src="../resources/get-host-info.js?pipe=sub"></script> |
| 6 <script src="resources/test-helpers.js"></script> | 6 <script src="resources/test-helpers.js"></script> |
| 7 <script> | 7 <script> |
| 8 | 8 |
| 9 function assert_resolves(promise, description) { | 9 function assert_resolves(promise, description) { |
| 10 return promise.catch(function(reason) { | 10 return promise.catch(function(reason) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // We can't catch the network error on iframe. So we use the timer for | 26 // We can't catch the network error on iframe. So we use the timer for |
| 27 // failure detection. | 27 // failure detection. |
| 28 var timer = setTimeout(function() { | 28 var timer = setTimeout(function() { |
| 29 reject(new Error('iframe load timeout')); | 29 reject(new Error('iframe load timeout')); |
| 30 frame.remove(); | 30 frame.remove(); |
| 31 }, 1000); | 31 }, 1000); |
| 32 } | 32 } |
| 33 frame.onload = function() { | 33 frame.onload = function() { |
| 34 if (timeout_enabled) | 34 if (timeout_enabled) |
| 35 clearTimeout(timer); | 35 clearTimeout(timer); |
| 36 if (frame.contentDocument.body.textContent == 'Hello world\n') | 36 try { |
| 37 resolve(); | 37 if (frame.contentDocument.body.textContent == 'Hello world\n') |
| 38 else | 38 resolve(); |
| 39 reject(new Error('content mismatch')); | 39 else |
| 40 reject(new Error('content mismatch')); |
| 41 } catch (e) { |
| 42 reject(new Error(e)); |
| 43 } |
| 40 frame.remove(); | 44 frame.remove(); |
| 41 }; | 45 }; |
| 42 document.body.appendChild(frame); | 46 document.body.appendChild(frame); |
| 43 }); | 47 }); |
| 44 } | 48 } |
| 45 | 49 |
| 46 promise_test(function(t) { | 50 promise_test(function(t) { |
| 47 var SCOPE = 'resources/fetch-request-redirect-iframe.html'; | 51 var SCOPE = 'resources/fetch-request-redirect-iframe.html'; |
| 48 var SCRIPT = 'resources/fetch-rewrite-worker.js'; | 52 var SCRIPT = 'resources/fetch-rewrite-worker.js'; |
| 49 var host_info = get_host_info(); | 53 var host_info = get_host_info(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 'Redirected iframe loading with Request.redirect=manual should'+ | 174 'Redirected iframe loading with Request.redirect=manual should'+ |
| 171 ' succeed.'), | 175 ' succeed.'), |
| 172 ]); | 176 ]); |
| 173 }) | 177 }) |
| 174 .then(function() { | 178 .then(function() { |
| 175 frame.remove(); | 179 frame.remove(); |
| 176 service_worker_unregister_and_done(t, SCOPE); | 180 service_worker_unregister_and_done(t, SCOPE); |
| 177 }); | 181 }); |
| 178 }, 'Verify redirect mode of Fetch API and ServiceWorker FetchEvent.'); | 182 }, 'Verify redirect mode of Fetch API and ServiceWorker FetchEvent.'); |
| 179 </script> | 183 </script> |
| OLD | NEW |