| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Service Worker: Fetch for the frame loading.</title> | 2 <title>Service Worker: Fetch for the frame loading.</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/test-helpers.js"></script> | 5 <script src="resources/test-helpers.js"></script> |
| 6 <body> | 6 <body> |
| 7 <script> | 7 <script> |
| 8 var worker = 'resources/fetch-rewrite-worker.js'; | 8 var worker = 'resources/fetch-rewrite-worker.js'; |
| 9 var path = base_path() + 'resources/fetch-access-control.php'; | 9 var path = base_path() + 'resources/fetch-access-control.php'; |
| 10 var host_info = get_host_info(); | 10 var host_info = get_host_info(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 .catch(unreached_rejection(t)); | 35 .catch(unreached_rejection(t)); |
| 36 }, 'Basic type response could be loaded in the iframe.'); | 36 }, 'Basic type response could be loaded in the iframe.'); |
| 37 | 37 |
| 38 async_test(function(t) { | 38 async_test(function(t) { |
| 39 var scope = 'resources/fetch-frame-resource/frame-cors'; | 39 var scope = 'resources/fetch-frame-resource/frame-cors'; |
| 40 service_worker_unregister_and_register(t, worker, scope) | 40 service_worker_unregister_and_register(t, worker, scope) |
| 41 .then(function(reg) { | 41 .then(function(reg) { |
| 42 return wait_for_state(t, reg.installing, 'activated'); | 42 return wait_for_state(t, reg.installing, 'activated'); |
| 43 }) | 43 }) |
| 44 .then(function() { | 44 .then(function() { |
| 45 return with_iframe( | 45 var frame = document.createElement('iframe'); |
| 46 frame.src = |
| 46 scope + '?mode=cors&url=' + | 47 scope + '?mode=cors&url=' + |
| 47 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + | 48 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + |
| 48 '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); | 49 '?ACAOrigin=' + host_info['HTTP_ORIGIN']); |
| 50 document.body.appendChild(frame); |
| 51 // We can't catch the network error on iframe. So we use the timer. |
| 52 return new Promise(function(resolve) { |
| 53 setTimeout(function() { resolve(frame); }, 1000); |
| 54 }); |
| 49 }) | 55 }) |
| 50 .then(function(frame) { | 56 .then(function(frame) { |
| 51 assert_not_equals( | 57 assert_equals( |
| 52 frame.contentDocument.body.textContent, | 58 frame.contentDocument.body.textContent, |
| 53 '', | 59 '', |
| 54 'CORS type response could be loaded in the iframe.'); | 60 'CORS type response could not be loaded in the iframe.'); |
| 55 frame.remove(); | 61 frame.remove(); |
| 56 return service_worker_unregister_and_done(t, scope); | 62 return service_worker_unregister_and_done(t, scope); |
| 57 }) | 63 }) |
| 58 .catch(unreached_rejection(t)); | 64 .catch(unreached_rejection(t)); |
| 59 }, 'CORS type response could be loaded in the iframe.'); | 65 }, 'CORS type response could not be loaded in the iframe.'); |
| 60 | 66 |
| 61 async_test(function(t) { | 67 async_test(function(t) { |
| 62 var scope = 'resources/fetch-frame-resource/frame-opaque'; | 68 var scope = 'resources/fetch-frame-resource/frame-opaque'; |
| 63 service_worker_unregister_and_register(t, worker, scope) | 69 service_worker_unregister_and_register(t, worker, scope) |
| 64 .then(function(reg) { | 70 .then(function(reg) { |
| 65 return wait_for_state(t, reg.installing, 'activated'); | 71 return wait_for_state(t, reg.installing, 'activated'); |
| 66 }) | 72 }) |
| 67 .then(function() { | 73 .then(function() { |
| 68 var frame = document.createElement('iframe'); | 74 var frame = document.createElement('iframe'); |
| 69 frame.src = | 75 frame.src = |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 .catch(unreached_rejection(t)); | 117 .catch(unreached_rejection(t)); |
| 112 }, 'Basic type response could be loaded in the new window.'); | 118 }, 'Basic type response could be loaded in the new window.'); |
| 113 | 119 |
| 114 async_test(function(t) { | 120 async_test(function(t) { |
| 115 var scope = 'resources/fetch-frame-resource/window-cors'; | 121 var scope = 'resources/fetch-frame-resource/window-cors'; |
| 116 service_worker_unregister_and_register(t, worker, scope) | 122 service_worker_unregister_and_register(t, worker, scope) |
| 117 .then(function(reg) { | 123 .then(function(reg) { |
| 118 return wait_for_state(t, reg.installing, 'activated'); | 124 return wait_for_state(t, reg.installing, 'activated'); |
| 119 }) | 125 }) |
| 120 .then(function() { | 126 .then(function() { |
| 127 var win = window.open( |
| 128 scope + '?mode=cors&url=' + |
| 129 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + |
| 130 '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); |
| 131 // We can't catch the network error on window. So we use the timer. |
| 121 return new Promise(function(resolve) { | 132 return new Promise(function(resolve) { |
| 122 var win = window.open( | 133 setTimeout(function() { resolve(win); }, 1000); |
| 123 scope + '?mode=cors&url=' + | |
| 124 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + | |
| 125 '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); | |
| 126 win.onload = function() { resolve(win); }; | |
| 127 }); | 134 }); |
| 128 }) | 135 }) |
| 129 .then(function(win) { | 136 .then(function(win) { |
| 130 assert_not_equals( | 137 assert_equals( |
| 131 win.document.body.textContent, | 138 win.document.body.textContent, |
| 132 '', | 139 '', |
| 133 'CORS type response could be loaded in the new window.'); | 140 'CORS type response could not be loaded in the new window.'); |
| 134 win.close(); | 141 win.close(); |
| 135 return service_worker_unregister_and_done(t, scope); | 142 return service_worker_unregister_and_done(t, scope); |
| 136 }) | 143 }) |
| 137 .catch(unreached_rejection(t)); | 144 .catch(unreached_rejection(t)); |
| 138 }, 'CORS type response could be loaded in the new window.'); | 145 }, 'CORS type response could not be loaded in the new window.'); |
| 139 | 146 |
| 140 async_test(function(t) { | 147 async_test(function(t) { |
| 141 var scope = 'resources/fetch-frame-resource/window-opaque'; | 148 var scope = 'resources/fetch-frame-resource/window-opaque'; |
| 142 service_worker_unregister_and_register(t, worker, scope) | 149 service_worker_unregister_and_register(t, worker, scope) |
| 143 .then(function(reg) { | 150 .then(function(reg) { |
| 144 return wait_for_state(t, reg.installing, 'activated'); | 151 return wait_for_state(t, reg.installing, 'activated'); |
| 145 }) | 152 }) |
| 146 .then(function() { | 153 .then(function() { |
| 147 var win = window.open( | 154 var win = window.open( |
| 148 scope + '?mode=no-cors&url=' + | 155 scope + '?mode=no-cors&url=' + |
| 149 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path)); | 156 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path)); |
| 150 // We can't catch the network error on window. So we use the timer. | 157 // We can't catch the network error on window. So we use the timer. |
| 151 return new Promise(function(resolve) { | 158 return new Promise(function(resolve) { |
| 152 setTimeout(function() { resolve(win); }, 1000); | 159 setTimeout(function() { resolve(win); }, 1000); |
| 153 }); | 160 }); |
| 154 }) | 161 }) |
| 155 .then(function(win) { | 162 .then(function(win) { |
| 156 assert_equals( | 163 assert_equals( |
| 157 win.document.body.textContent, | 164 win.document.body.textContent, |
| 158 '', | 165 '', |
| 159 'CORS type response could not be loaded in the new window.'); | 166 'Opaque type response could not be loaded in the new window.'); |
| 160 win.close(); | 167 win.close(); |
| 161 return service_worker_unregister_and_done(t, scope); | 168 return service_worker_unregister_and_done(t, scope); |
| 162 }) | 169 }) |
| 163 .catch(unreached_rejection(t)); | 170 .catch(unreached_rejection(t)); |
| 164 }, 'Opaque type response could not be loaded in the new window.'); | 171 }, 'Opaque type response could not be loaded in the new window.'); |
| 165 </script> | 172 </script> |
| 166 </body> | 173 </body> |
| OLD | NEW |