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 var url_count = 0; | 8 var url_count = 0; |
9 var expected_results = {}; | 9 var expected_results = {}; |
10 | 10 |
11 function image_test(frame, url, cross_origin, | 11 function image_test(frame, url, cross_origin, |
12 expected_mode, expected_credentials) { | 12 expected_mode, expected_credentials) { |
13 var actual_url = url + (++url_count); | 13 var actual_url = url + (++url_count); |
14 expected_results[actual_url] = { | 14 expected_results[actual_url] = { |
| 15 cross_origin: cross_origin, |
15 mode: expected_mode, | 16 mode: expected_mode, |
16 credentials: expected_credentials, | 17 credentials: expected_credentials, |
17 redirect: 'follow', | 18 redirect: 'follow', |
18 message: 'Image load (url:' + | 19 message: 'Image load (url:' + |
19 actual_url + ' cross_origin:' + cross_origin + ')' | 20 actual_url + ' cross_origin:' + cross_origin + ')' |
20 }; | 21 }; |
21 return frame.contentWindow.load_image(actual_url, cross_origin); | 22 return frame.contentWindow.load_image(actual_url, cross_origin); |
22 } | 23 } |
23 | 24 |
24 function script_test(frame, url, cross_origin, | 25 function script_test(frame, url, cross_origin, |
25 expected_mode, expected_credentials) { | 26 expected_mode, expected_credentials) { |
26 var actual_url = url + (++url_count); | 27 var actual_url = url + (++url_count); |
27 expected_results[actual_url] = { | 28 expected_results[actual_url] = { |
| 29 cross_origin: cross_origin, |
28 mode: expected_mode, | 30 mode: expected_mode, |
29 credentials: expected_credentials, | 31 credentials: expected_credentials, |
30 redirect: 'follow', | 32 redirect: 'follow', |
31 message: 'Script load (url:' + | 33 message: 'Script load (url:' + |
32 actual_url + ' cross_origin:' + cross_origin + ')' | 34 actual_url + ' cross_origin:' + cross_origin + ')' |
33 }; | 35 }; |
34 return frame.contentWindow.load_script(actual_url, cross_origin); | 36 return frame.contentWindow.load_script(actual_url, cross_origin); |
35 } | 37 } |
36 | 38 |
37 function css_test(frame, url, cross_origin, | 39 function css_test(frame, url, cross_origin, |
38 expected_mode, expected_credentials) { | 40 expected_mode, expected_credentials) { |
39 var actual_url = url + (++url_count); | 41 var actual_url = url + (++url_count); |
40 expected_results[actual_url] = { | 42 expected_results[actual_url] = { |
| 43 cross_origin: cross_origin, |
41 mode: expected_mode, | 44 mode: expected_mode, |
42 credentials: expected_credentials, | 45 credentials: expected_credentials, |
43 redirect: 'follow', | 46 redirect: 'follow', |
44 message: 'CSS load (url:' + | 47 message: 'CSS load (url:' + |
45 actual_url + ' cross_origin:' + cross_origin + ')' | 48 actual_url + ' cross_origin:' + cross_origin + ')' |
46 }; | 49 }; |
47 return frame.contentWindow.load_css(actual_url, cross_origin); | 50 return frame.contentWindow.load_css(actual_url, cross_origin); |
48 } | 51 } |
49 | 52 |
50 function font_face_test(frame, url, expected_mode, | 53 function font_face_test(frame, url, expected_mode, |
(...skipping 28 matching lines...) Expand all Loading... |
79 expected_results[actual_url] = { | 82 expected_results[actual_url] = { |
80 url: actual_url, | 83 url: actual_url, |
81 mode: expected_mode, | 84 mode: expected_mode, |
82 credentials: expected_credentials, | 85 credentials: expected_credentials, |
83 redirect: 'follow', | 86 redirect: 'follow', |
84 message: 'CSSImageSet load (url:' + actual_url + ' type:' + type + ')' | 87 message: 'CSSImageSet load (url:' + actual_url + ' type:' + type + ')' |
85 }; | 88 }; |
86 return frame.contentWindow.load_css_image_set(actual_url, type); | 89 return frame.contentWindow.load_css_image_set(actual_url, type); |
87 } | 90 } |
88 | 91 |
89 function fetch_test(frame, url, mode, credentials, | |
90 expected_mode, expected_credentials) { | |
91 var actual_url = url + (++url_count); | |
92 expected_results[actual_url] = { | |
93 mode: expected_mode, | |
94 credentials: expected_credentials, | |
95 redirect: 'follow', | |
96 message: 'fetch (url:' + actual_url + ' mode:' + mode + ' credentials:' + | |
97 credentials + ')' | |
98 }; | |
99 return frame.contentWindow.fetch( | |
100 new Request(actual_url, {mode: mode, credentials: credentials})); | |
101 } | |
102 | |
103 function audio_test(frame, url, cross_origin, | |
104 expected_mode, expected_credentials) { | |
105 var actual_url = url + (++url_count); | |
106 expected_results[actual_url] = { | |
107 mode: expected_mode, | |
108 credentials: expected_credentials, | |
109 redirect: 'follow', | |
110 message: 'Audio load (url:' + actual_url + ' cross_origin:' + | |
111 cross_origin + ')' | |
112 }; | |
113 return frame.contentWindow.load_audio(actual_url, cross_origin); | |
114 } | |
115 | |
116 async_test(function(t) { | 92 async_test(function(t) { |
117 var SCOPE = 'resources/fetch-request-resources-iframe.html'; | 93 var SCOPE = 'resources/fetch-request-resources-iframe.html'; |
118 var SCRIPT = 'resources/fetch-request-resources-worker.js'; | 94 var SCRIPT = 'resources/fetch-request-resources-worker.js'; |
119 var host_info = get_host_info(); | 95 var host_info = get_host_info(); |
120 var LOCAL_URL = | 96 var LOCAL_URL = |
121 host_info['HTTP_ORIGIN'] + base_path() + 'resources/dummy?test'; | 97 host_info['HTTP_ORIGIN'] + base_path() + 'resources/dummy?test'; |
122 var REMOTE_URL = | 98 var REMOTE_URL = |
123 host_info['HTTP_REMOTE_ORIGIN'] + base_path() + 'resources/dummy?test'; | 99 host_info['HTTP_REMOTE_ORIGIN'] + base_path() + 'resources/dummy?test'; |
124 var worker; | 100 var worker; |
125 var frame; | 101 var frame; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 service_worker_unregister_and_done(t, SCOPE); | 136 service_worker_unregister_and_done(t, SCOPE); |
161 } | 137 } |
162 }); | 138 }); |
163 worker.postMessage( | 139 worker.postMessage( |
164 {port: channel.port2}, [channel.port2]); | 140 {port: channel.port2}, [channel.port2]); |
165 }); | 141 }); |
166 }) | 142 }) |
167 .then(function() { return with_iframe(SCOPE); }) | 143 .then(function() { return with_iframe(SCOPE); }) |
168 .then(function(f) { | 144 .then(function(f) { |
169 frame = f; | 145 frame = f; |
170 image_test(f, LOCAL_URL, '', 'no-cors', 'include'); | 146 image_test(f, LOCAL_URL, '', 'no-cors', 'same-origin'); |
171 image_test(f, LOCAL_URL, 'anonymous', 'cors', 'same-origin'); | 147 image_test(f, LOCAL_URL, 'anonymous', 'cors', 'same-origin'); |
172 image_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); | 148 image_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); |
173 image_test(f, REMOTE_URL, '', 'no-cors', 'include'); | 149 image_test(f, REMOTE_URL, '', 'no-cors', 'same-origin'); |
174 image_test(f, REMOTE_URL, 'anonymous', 'cors', 'same-origin'); | 150 image_test(f, REMOTE_URL, 'anonymous', 'cors', 'same-origin'); |
175 image_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); | 151 image_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); |
176 | 152 |
177 script_test(f, LOCAL_URL, '', 'no-cors', 'include'); | 153 script_test(f, LOCAL_URL, '', 'no-cors', 'same-origin'); |
178 script_test(f, LOCAL_URL, 'anonymous', 'cors', 'same-origin'); | 154 script_test(f, LOCAL_URL, 'anonymous', 'cors', 'same-origin'); |
179 script_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); | 155 script_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); |
180 script_test(f, REMOTE_URL, '', 'no-cors', 'include'); | 156 script_test(f, REMOTE_URL, '', 'no-cors', 'same-origin'); |
181 script_test(f, REMOTE_URL, 'anonymous', 'cors', 'same-origin'); | 157 script_test(f, REMOTE_URL, 'anonymous', 'cors', 'same-origin'); |
182 script_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); | 158 script_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); |
183 | 159 |
184 css_test(f, LOCAL_URL, '', 'no-cors', 'include'); | 160 css_test(f, LOCAL_URL, '', 'no-cors', 'same-origin'); |
185 css_test(f, LOCAL_URL, 'anonymous', 'cors', 'same-origin'); | 161 css_test(f, LOCAL_URL, 'anonymous', 'cors', 'same-origin'); |
186 css_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); | 162 css_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); |
187 css_test(f, REMOTE_URL, '', 'no-cors', 'include'); | 163 css_test(f, REMOTE_URL, '', 'no-cors', 'same-origin'); |
188 css_test(f, REMOTE_URL, 'anonymous', 'cors', 'same-origin'); | 164 css_test(f, REMOTE_URL, 'anonymous', 'cors', 'same-origin'); |
189 css_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); | 165 css_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); |
190 | 166 |
191 font_face_test(f, LOCAL_URL, 'cors', 'same-origin'); | 167 font_face_test(f, LOCAL_URL, 'cors', 'same-origin'); |
192 font_face_test(f, REMOTE_URL, 'cors', 'same-origin'); | 168 font_face_test(f, REMOTE_URL, 'cors', 'same-origin'); |
193 | 169 |
194 css_image_test(f, LOCAL_URL, 'backgroundImage', 'no-cors', 'include'); | 170 css_image_test(f, LOCAL_URL, 'backgroundImage', |
195 css_image_test(f, REMOTE_URL, 'backgroundImage', 'no-cors', 'include'); | 171 'no-cors', 'same-origin'); |
| 172 css_image_test(f, REMOTE_URL, 'backgroundImage', |
| 173 'no-cors', 'same-origin'); |
196 css_image_test(f, LOCAL_URL, 'shapeOutside', 'cors', 'same-origin'); | 174 css_image_test(f, LOCAL_URL, 'shapeOutside', 'cors', 'same-origin'); |
197 css_image_test(f, REMOTE_URL, 'shapeOutside', 'cors', 'same-origin'); | 175 css_image_test(f, REMOTE_URL, 'shapeOutside', 'cors', 'same-origin'); |
198 | 176 |
199 css_image_set_test(f, LOCAL_URL, 'backgroundImage', | 177 css_image_set_test(f, LOCAL_URL, 'backgroundImage', |
200 'no-cors', 'include'); | 178 'no-cors', 'same-origin'); |
201 css_image_set_test(f, REMOTE_URL, 'backgroundImage', | 179 css_image_set_test(f, REMOTE_URL, 'backgroundImage', |
202 'no-cors', 'include'); | 180 'no-cors', 'same-origin'); |
203 css_image_set_test(f, LOCAL_URL, 'shapeOutside', 'cors', 'same-origin'); | 181 css_image_set_test(f, LOCAL_URL, 'shapeOutside', 'cors', 'same-origin'); |
204 css_image_set_test(f, REMOTE_URL, 'shapeOutside', | 182 css_image_set_test(f, REMOTE_URL, 'shapeOutside', |
205 'cors', 'same-origin'); | 183 'cors', 'same-origin'); |
206 | 184 |
207 fetch_test(f, LOCAL_URL, 'same-origin', 'omit', 'same-origin', 'omit'); | |
208 fetch_test(f, LOCAL_URL, 'same-origin', 'same-origin', | |
209 'same-origin', 'same-origin'); | |
210 fetch_test(f, LOCAL_URL, 'same-origin', 'include', | |
211 'same-origin', 'include'); | |
212 fetch_test(f, LOCAL_URL, 'no-cors', 'omit', 'no-cors', 'omit'); | |
213 fetch_test(f, LOCAL_URL, 'no-cors', 'same-origin', | |
214 'no-cors', 'same-origin'); | |
215 fetch_test(f, LOCAL_URL, 'no-cors', 'include', 'no-cors', 'include'); | |
216 fetch_test(f, LOCAL_URL, 'cors', 'omit', 'cors', 'omit'); | |
217 fetch_test(f, LOCAL_URL, 'cors', 'same-origin', 'cors', 'same-origin'); | |
218 fetch_test(f, LOCAL_URL, 'cors', 'include', 'cors', 'include'); | |
219 fetch_test(f, REMOTE_URL, 'no-cors', 'omit', 'no-cors', 'omit'); | |
220 fetch_test(f, REMOTE_URL, 'no-cors', 'same-origin', | |
221 'no-cors', 'same-origin'); | |
222 fetch_test(f, REMOTE_URL, 'no-cors', 'include', 'no-cors', 'include'); | |
223 fetch_test(f, REMOTE_URL, 'cors', 'omit', 'cors', 'omit'); | |
224 fetch_test(f, REMOTE_URL, 'cors', 'same-origin', 'cors', 'same-origin'); | |
225 fetch_test(f, REMOTE_URL, 'cors', 'include', 'cors', 'include'); | |
226 | |
227 audio_test(f, LOCAL_URL, '', 'no-cors', 'include'); | |
228 audio_test(f, LOCAL_URL, 'anonymous', 'cors', 'same-origin'); | |
229 audio_test(f, LOCAL_URL, 'use-credentials', 'cors', 'include'); | |
230 audio_test(f, REMOTE_URL, '', 'no-cors', 'include'); | |
231 audio_test(f, REMOTE_URL, 'anonymous', 'cors', 'same-origin'); | |
232 audio_test(f, REMOTE_URL, 'use-credentials', 'cors', 'include'); | |
233 }) | 185 }) |
234 .catch(unreached_rejection(t)); | 186 .catch(unreached_rejection(t)); |
235 }, 'Verify FetchEvent for resources.'); | 187 }, 'Verify FetchEvent for resources.'); |
236 </script> | 188 </script> |
OLD | NEW |