Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: LayoutTests/http/tests/fetch/script-tests/fetch-access-control-cors.js

Issue 921673003: [Fetch] Split layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 if (self.importScripts) { 1 if (self.importScripts) {
2 importScripts('../resources/fetch-test-helpers.js'); 2 importScripts('../resources/fetch-test-helpers.js');
3 importScripts('/serviceworker/resources/fetch-access-control-util.js'); 3 importScripts('/serviceworker/resources/fetch-access-control-util.js');
4 } 4 }
5 5
6 // Tests for CORS check and CORS filtered response.
7
6 var TEST_TARGETS = [ 8 var TEST_TARGETS = [
7 // CORS test 9 // CORS test
8 [OTHER_BASE_URL + 'method=GET&headers=CUSTOM',
9 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque],
10 onlyOnServiceWorkerProxiedTest([methodIsGET, noCustomHeader, authCheck2])],
11 [OTHER_BASE_URL + 'method=POST&headers=CUSTOM',
12 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque],
13 onlyOnServiceWorkerProxiedTest([methodIsPOST, noCustomHeader])],
14 [OTHER_BASE_URL + 'method=PUT&headers=CUSTOM',
15 [fetchError]],
16 [OTHER_BASE_URL + 'method=XXX&headers=CUSTOM',
17 [fetchError]],
18 10
19 [OTHER_BASE_URL + 'mode=same-origin&method=GET', [fetchRejected]], 11 [OTHER_BASE_URL + 'mode=same-origin&method=GET', [fetchRejected]],
20 [OTHER_BASE_URL + 'mode=same-origin&method=POST', [fetchRejected]], 12 [OTHER_BASE_URL + 'mode=same-origin&method=POST', [fetchRejected]],
21 [OTHER_BASE_URL + 'mode=same-origin&method=PUT', [fetchRejected]], 13 [OTHER_BASE_URL + 'mode=same-origin&method=PUT', [fetchRejected]],
22 [OTHER_BASE_URL + 'mode=same-origin&method=XXX', [fetchRejected]], 14 [OTHER_BASE_URL + 'mode=same-origin&method=XXX', [fetchRejected]],
23 15
24 [OTHER_BASE_URL + 'mode=no-cors&method=GET&headers=CUSTOM',
25 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque],
26 onlyOnServiceWorkerProxiedTest([methodIsGET, noCustomHeader, authCheck2])],
27 [OTHER_BASE_URL + 'mode=no-cors&method=POST&headers=CUSTOM',
28 [fetchResolved, noContentLength, noServerHeader, noBody, typeOpaque],
29 onlyOnServiceWorkerProxiedTest([methodIsPOST, noCustomHeader])],
30 [OTHER_BASE_URL + 'mode=no-cors&method=PUT&headers=CUSTOM',
31 [fetchError]],
32 [OTHER_BASE_URL + 'mode=no-cors&method=XXX&headers=CUSTOM',
33 [fetchError]],
34
35 // method=GET 16 // method=GET
36 17
37 // CORS check 18 // CORS check
38 // https://fetch.spec.whatwg.org/#concept-cors-check 19 // https://fetch.spec.whatwg.org/#concept-cors-check
39 // Tests for Access-Control-Allow-Origin header. 20 // Tests for Access-Control-Allow-Origin header.
40 [OTHER_BASE_URL + 'mode=cors&method=GET', 21 [OTHER_BASE_URL + 'mode=cors&method=GET',
41 [fetchRejected]], 22 [fetchRejected]],
42 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*', 23 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*',
43 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], 24 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
44 [methodIsGET, authCheckNone]], 25 [methodIsGET, authCheckNone]],
(...skipping 17 matching lines...) Expand all
62 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors], 43 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors],
63 [methodIsGET]], 44 [methodIsGET]],
64 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader', 45 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=*&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
65 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors], 46 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
66 [methodIsGET]], 47 [methodIsGET]],
67 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=' + BASE_ORIGIN + 48 [OTHER_BASE_URL + 'mode=cors&method=GET&ACAOrigin=' + BASE_ORIGIN +
68 '&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader', 49 '&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
69 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors], 50 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
70 [methodIsGET]], 51 [methodIsGET]],
71 52
72 // CORS preflight fetch
73 // https://fetch.spec.whatwg.org/#cors-preflight-fetch
74 // Tests for Access-Control-Allow-Headers header.
75 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM',
76 [fetchRejected]],
77 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*',
78 [fetchRejected]],
79 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=' +
80 BASE_ORIGIN,
81 [fetchRejected]],
82 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&ACAHeaders= x-serviceworker-test',
83 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
84 [methodIsGET, hasCustomHeader]],
85 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=' +
86 BASE_ORIGIN + '&ACAHeaders=x-serviceworker-test',
87 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
88 [methodIsGET, hasCustomHeader]],
89 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&ACAHeaders= x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
90 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
91 [methodIsGET, hasCustomHeader]],
92 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=' +
93 BASE_ORIGIN +
94 '&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker- ServerHeader',
95 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
96 [methodIsGET, hasCustomHeader]],
97
98 // Test that Access-Control-Allow-Headers is checked in CORS preflight fetch.
99 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAHeaders=x-serviceworker-test&PreflightTest=200',
100 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
101 [methodIsGET, hasCustomHeader]],
102 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&ACAHeaders=x-serviceworker-test&PreflightTest=200',
103 [fetchRejected]],
104
105 // Test that CORS check is done in both preflight and main fetch.
106 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&PACAHeaders =x-serviceworker-test&PreflightTest=200',
107 [fetchRejected]],
108 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&PACAOrigin=*&PACAHeader s=x-serviceworker-test&PreflightTest=200',
109 [fetchRejected]],
110
111 // Test that Access-Control-Expose-Headers of CORS preflight is ignored.
112 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAHeaders=x-serviceworker-test&PACEHeaders=Content-Length, X-ServiceWorker-S erverHeader&PreflightTest=200',
113 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
114 [methodIsGET, hasCustomHeader]],
115
116 // Test that CORS preflight with Status 2XX succeeds.
117 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAHeaders=x-serviceworker-test&PreflightTest=201',
118 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
119 [methodIsGET, hasCustomHeader]],
120
121 // Test that CORS preflight with Status other than 2XX fails.
122 // https://crbug.com/452394
123 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAHeaders=x-serviceworker-test&PreflightTest=301',
124 [fetchRejected]],
125 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAHeaders=x-serviceworker-test&PreflightTest=401',
126 [fetchRejected]],
127 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAHeaders=x-serviceworker-test&PreflightTest=500',
128 [fetchRejected]],
129
130 // Test CORS preflight with multiple request headers.
131 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM2&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicewOrker-test, x-sE rviceworker-s, x-sErviceworker-v&PreflightTest=200',
132 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
133 [methodIsGET, hasCustomHeader2]],
134 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM2&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-servicewOrker-test&PreflightTest=200',
135 [fetchRejected]],
136
137 // Test request headers sent in CORS preflight requests.
138 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAHeaders=x-serviceworker-test&PreflightTest=200&PACRMethod=GET&PACRHeaders= x-serviceworker-test',
139 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
140 [methodIsGET, hasCustomHeader]],
141 // Test Access-Control-Request-Headers is sorted https://crbug.com/452391
142 [OTHER_BASE_URL + 'mode=cors&method=GET&headers=CUSTOM2&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicewOrker-test, x-sE rviceworker-s, x-sErviceworker-v&PreflightTest=200&PACRMethod=GET&PACRHeaders=x- serviceworker-s, x-serviceworker-test, x-serviceworker-u, x-serviceworker-ua, x- serviceworker-v',
143 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
144 [methodIsGET, hasCustomHeader2]],
145
146 // method=POST 53 // method=POST
147 54
148 // CORS check 55 // CORS check
149 // https://fetch.spec.whatwg.org/#concept-cors-check 56 // https://fetch.spec.whatwg.org/#concept-cors-check
150 // Tests for Access-Control-Allow-Origin header. 57 // Tests for Access-Control-Allow-Origin header.
151 [OTHER_BASE_URL + 'mode=cors&method=POST', 58 [OTHER_BASE_URL + 'mode=cors&method=POST',
152 [fetchRejected]], 59 [fetchRejected]],
153 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*', 60 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*',
154 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], 61 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
155 [methodIsPOST]], 62 [methodIsPOST]],
(...skipping 16 matching lines...) Expand all
172 '&ACEHeaders=X-ServiceWorker-ServerHeader', 79 '&ACEHeaders=X-ServiceWorker-ServerHeader',
173 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors], 80 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors],
174 [methodIsPOST]], 81 [methodIsPOST]],
175 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*&ACEHeaders=Content-Length , X-ServiceWorker-ServerHeader', 82 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=*&ACEHeaders=Content-Length , X-ServiceWorker-ServerHeader',
176 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors], 83 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
177 [methodIsPOST]], 84 [methodIsPOST]],
178 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=' + BASE_ORIGIN + 85 [OTHER_BASE_URL + 'mode=cors&method=POST&ACAOrigin=' + BASE_ORIGIN +
179 '&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader', 86 '&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
180 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors], 87 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
181 [methodIsPOST]], 88 [methodIsPOST]],
182
183 // CORS preflight fetch
184 // https://fetch.spec.whatwg.org/#cors-preflight-fetch
185 // Tests for Access-Control-Allow-Headers header.
186 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM',
187 [fetchRejected]],
188 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*',
189 [fetchRejected]],
190 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&ACAHeaders =x-serviceworker-test',
191 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
192 [methodIsPOST, hasCustomHeader]],
193 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&ACAHeaders =x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader',
194 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
195 [methodIsPOST, hasCustomHeader]],
196 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=' +
197 BASE_ORIGIN,
198 [fetchRejected]],
199 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=' +
200 BASE_ORIGIN + '&ACAHeaders=x-serviceworker-test',
201 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
202 [methodIsPOST, hasCustomHeader]],
203 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=' +
204 BASE_ORIGIN +
205 '&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker- ServerHeader',
206 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
207 [methodIsPOST, hasCustomHeader]],
208
209 // Test that Access-Control-Allow-Headers is checked in CORS preflight fetch.
210 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-serviceworker-test&PreflightTest=200',
211 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
212 [methodIsPOST, hasCustomHeader]],
213 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&PACAOrigin =*&ACAHeaders=x-serviceworker-test&PreflightTest=200',
214 [fetchRejected]],
215
216 // Test that CORS check is done in both preflight and main fetch.
217 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&PACAHeader s=x-serviceworker-test&PreflightTest=200',
218 [fetchRejected]],
219 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&PACAOrigin=*&PACAHeade rs=x-serviceworker-test&PreflightTest=200',
220 [fetchRejected]],
221
222 // Test that Access-Control-Expose-Headers of CORS preflight is ignored.
223 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-serviceworker-test&PACEHeaders=Content-Length, X-ServiceWorker- ServerHeader&PreflightTest=200',
224 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
225 [methodIsPOST, hasCustomHeader]],
226
227 // Test that CORS preflight with Status 2XX succeeds.
228 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-serviceworker-test&PreflightTest=201',
229 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
230 [methodIsPOST, hasCustomHeader]],
231
232 // Test that CORS preflight with Status other than 2XX fails.
233 // https://crbug.com/452394
234 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-serviceworker-test&PreflightTest=301',
235 [fetchRejected]],
236 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-serviceworker-test&PreflightTest=401',
237 [fetchRejected]],
238 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-serviceworker-test&PreflightTest=500',
239 [fetchRejected]],
240
241 // Test CORS preflight with multiple request headers.
242 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM2&ACAOrigin=*&PACAOrigi n=*&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicewOrker-test, x-s Erviceworker-s, x-sErviceworker-v&PreflightTest=200',
243 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
244 [methodIsPOST, hasCustomHeader2]],
245 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM2&ACAOrigin=*&PACAOrigi n=*&PACAHeaders=x-servicewOrker-test&PreflightTest=200',
246 [fetchRejected]],
247
248 // Test request headers sent in CORS preflight requests.
249 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM&ACAOrigin=*&PACAOrigin =*&PACAHeaders=x-serviceworker-test&PreflightTest=200&PACRMethod=POST&PACRHeader s=x-serviceworker-test',
250 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
251 [methodIsPOST, hasCustomHeader]],
252 // Test Access-Control-Request-Headers is sorted https://crbug.com/452391
253 [OTHER_BASE_URL + 'mode=cors&method=POST&headers=CUSTOM2&ACAOrigin=*&PACAOrigi n=*&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicewOrker-test, x-s Erviceworker-s, x-sErviceworker-v&PreflightTest=200&PACRMethod=POST&PACRHeaders= x-serviceworker-s, x-serviceworker-test, x-serviceworker-u, x-serviceworker-ua, x-serviceworker-v',
254 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
255 [methodIsPOST, hasCustomHeader2]],
256
257 // method=PUT
258
259 // CORS check
260 // https://fetch.spec.whatwg.org/#concept-cors-check
261 // Tests for Access-Control-Allow-Origin header.
262 // CORS preflight fetch
263 // https://fetch.spec.whatwg.org/#cors-preflight-fetch
264 // Tests for Access-Control-Allow-Methods header.
265 // Tests for Access-Control-Allow-Headers header.
266 [OTHER_BASE_URL + 'mode=cors&method=PUT',
267 [fetchRejected]],
268 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAMethods=PUT',
269 [fetchRejected]],
270 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*',
271 [fetchRejected]],
272 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&ACAMethods=PUT',
273 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
274 [methodIsPUT]],
275 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods= PUT',
276 [fetchRejected]],
277 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods= PUT&ACAHeaders=x-serviceworker-test',
278 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
279 [methodIsPUT, hasCustomHeader]],
280 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods= PUT&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-S erverHeader',
281 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
282 [methodIsPUT, hasCustomHeader]],
283 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods= PUT, XXX',
284 [fetchRejected]],
285 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods= PUT, XXX&ACAHeaders=x-serviceworker-test',
286 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
287 [methodIsPUT, hasCustomHeader]],
288 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&headers=CUSTOM&ACAMethods= PUT, XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWor ker-ServerHeader',
289 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
290 [methodIsPUT, hasCustomHeader]],
291 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=' + BASE_ORIGIN,
292 [fetchRejected]],
293 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=' + BASE_ORIGIN +
294 '&ACAMethods=PUT',
295 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
296 [methodIsPUT]],
297 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=' + BASE_ORIGIN +
298 '&headers=CUSTOM&ACAMethods=PUT',
299 [fetchRejected]],
300 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=' + BASE_ORIGIN +
301 '&headers=CUSTOM&ACAMethods=PUT&ACAHeaders=x-serviceworker-test',
302 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
303 [methodIsPUT, hasCustomHeader]],
304 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=' + BASE_ORIGIN +
305 '&headers=CUSTOM&ACAMethods=PUT&ACAHeaders=x-serviceworker-test&ACEHeaders=Co ntent-Length, X-ServiceWorker-ServerHeader',
306 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
307 [methodIsPUT, hasCustomHeader]],
308 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=' + BASE_ORIGIN +
309 '&headers=CUSTOM&ACAMethods=PUT, XXX',
310 [fetchRejected]],
311 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=' + BASE_ORIGIN +
312 '&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test',
313 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
314 [methodIsPUT, hasCustomHeader]],
315 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=' + BASE_ORIGIN +
316 '&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test&ACEHeade rs=Content-Length, X-ServiceWorker-ServerHeader',
317 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
318 [methodIsPUT, hasCustomHeader]],
319
320 // Test that Access-Control-Allow-Methods is checked in CORS preflight fetch.
321 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&PACAOrigin=*&PACAMethods=P UT&PreflightTest=200',
322 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
323 [methodIsPUT]],
324 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&PACAOrigin=*&ACAMethods=PU T&PreflightTest=200',
325 [fetchRejected]],
326
327 // Test that Access-Control-Allow-Headers is checked in CORS preflight fetch.
328 [OTHER_BASE_URL + 'mode=cors&method=PUT&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAMethods=PUT&PACAHeaders=x-serviceworker-test&PreflightTest=200',
329 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
330 [methodIsPUT, hasCustomHeader]],
331 [OTHER_BASE_URL + 'mode=cors&method=PUT&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAMethods=PUT&ACAHeaders=x-serviceworker-test&PreflightTest=200',
332 [fetchRejected]],
333
334 // Test that CORS check is done in both preflight and main fetch.
335 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&PACAMethods=PUT&PreflightT est=200',
336 [fetchRejected]],
337 [OTHER_BASE_URL + 'mode=cors&method=PUT&PACAOrigin=*&PACAMethods=PUT&Preflight Test=200',
338 [fetchRejected]],
339
340 // Test that Access-Control-Expose-Headers of CORS preflight is ignored.
341 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&PACAOrigin=*&PACAMethods=P UT&PACEHeaders=Content-Length, X-ServiceWorker-ServerHeader&PreflightTest=200',
342 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
343 [methodIsPUT]],
344
345 // Test that CORS preflight with Status 2XX succeeds.
346 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&PACAOrigin=*&PACAMethods=P UT&PreflightTest=201',
347 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
348 [methodIsPUT]],
349
350 // Test that CORS preflight with Status other than 2XX fails.
351 // https://crbug.com/452394
352 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&PACAOrigin=*&PACAMethods=P UT&PreflightTest=301',
353 [fetchRejected]],
354 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&PACAOrigin=*&PACAMethods=P UT&PreflightTest=401',
355 [fetchRejected]],
356 [OTHER_BASE_URL + 'mode=cors&method=PUT&ACAOrigin=*&PACAOrigin=*&PACAMethods=P UT&PreflightTest=500',
357 [fetchRejected]],
358
359 // Test CORS preflight with multiple request headers.
360 [OTHER_BASE_URL + 'mode=cors&method=PUT&headers=CUSTOM2&ACAOrigin=*&PACAOrigin =*&PACAMethods=PUT&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicew Orker-test, x-sErviceworker-s, x-sErviceworker-v&PreflightTest=200',
361 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
362 [methodIsPUT, hasCustomHeader2]],
363 [OTHER_BASE_URL + 'mode=cors&method=PUT&headers=CUSTOM2&ACAOrigin=*&PACAOrigin =*&PACAMethods=PUT&PACAHeaders=x-servicewOrker-test&PreflightTest=200',
364 [fetchRejected]],
365
366 // Test request headers sent in CORS preflight requests.
367 [OTHER_BASE_URL + 'mode=cors&method=PUT&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAMethods=PUT&PACAHeaders=x-serviceworker-test&PreflightTest=200&PACRMethod= PUT&PACRHeaders=x-serviceworker-test',
368 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
369 [methodIsPUT, hasCustomHeader]],
370 // Test Access-Control-Request-Headers is sorted https://crbug.com/452391
371 [OTHER_BASE_URL + 'mode=cors&method=PUT&headers=CUSTOM2&ACAOrigin=*&PACAOrigin =*&PACAMethods=PUT&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicew Orker-test, x-sErviceworker-s, x-sErviceworker-v&PreflightTest=200&PACRMethod=PU T&PACRHeaders=x-serviceworker-s, x-serviceworker-test, x-serviceworker-u, x-serv iceworker-ua, x-serviceworker-v',
372 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
373 [methodIsPUT, hasCustomHeader2]],
374
375 // method=XXX
376
377 // CORS check
378 // https://fetch.spec.whatwg.org/#concept-cors-check
379 // Tests for Access-Control-Allow-Origin header.
380 // CORS preflight fetch
381 // https://fetch.spec.whatwg.org/#cors-preflight-fetch
382 // Tests for Access-Control-Allow-Methods header.
383 // Tests for Access-Control-Allow-Headers header.
384
385 [OTHER_BASE_URL + 'mode=cors&method=XXX',
386 [fetchRejected]],
387 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAMethods=XXX',
388 [fetchRejected]],
389 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*',
390 [fetchRejected]],
391 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&ACAMethods=XXX',
392 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
393 [methodIsXXX]],
394 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods= XXX',
395 [fetchRejected]],
396 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods= XXX&ACAHeaders=x-serviceworker-test',
397 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
398 [methodIsXXX, hasCustomHeader]],
399 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods= XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWorker-S erverHeader',
400 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
401 [methodIsXXX, hasCustomHeader]],
402 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods= PUT, XXX',
403 [fetchRejected]],
404 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods= PUT, XXX&ACAHeaders=x-serviceworker-test',
405 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
406 [methodIsXXX, hasCustomHeader]],
407 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&headers=CUSTOM&ACAMethods= PUT, XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Content-Length, X-ServiceWor ker-ServerHeader',
408 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
409 [methodIsXXX, hasCustomHeader]],
410 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=' + BASE_ORIGIN,
411 [fetchRejected]],
412 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=' + BASE_ORIGIN +
413 '&ACAMethods=XXX',
414 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
415 [methodIsXXX]],
416 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=' + BASE_ORIGIN +
417 '&headers=CUSTOM&ACAMethods=XXX',
418 [fetchRejected]],
419 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=' + BASE_ORIGIN +
420 '&headers=CUSTOM&ACAMethods=XXX&ACAHeaders=x-serviceworker-test',
421 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
422 [methodIsXXX, hasCustomHeader]],
423 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=' + BASE_ORIGIN +
424 '&headers=CUSTOM&ACAMethods=XXX&ACAHeaders=x-serviceworker-test&ACEHeaders=Co ntent-Length, X-ServiceWorker-ServerHeader',
425 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
426 [methodIsXXX, hasCustomHeader]],
427 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=' + BASE_ORIGIN +
428 '&headers=CUSTOM&ACAMethods=PUT, XXX',
429 [fetchRejected]],
430 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=' + BASE_ORIGIN +
431 '&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test',
432 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
433 [methodIsXXX, hasCustomHeader]],
434 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=' + BASE_ORIGIN +
435 '&headers=CUSTOM&ACAMethods=PUT, XXX&ACAHeaders=x-serviceworker-test&ACEHeade rs=Content-Length, X-ServiceWorker-ServerHeader',
436 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors],
437 [methodIsXXX, hasCustomHeader]],
438
439 // Test that Access-Control-Allow-Methods is checked in CORS preflight fetch.
440 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&PACAOrigin=*&PACAMethods=X XX&PreflightTest=200',
441 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
442 [methodIsXXX]],
443 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&PACAOrigin=*&ACAMethods=XX X&PreflightTest=200',
444 [fetchRejected]],
445
446 // Test that Access-Control-Allow-Headers is checked in CORS preflight fetch.
447 [OTHER_BASE_URL + 'mode=cors&method=XXX&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAMethods=XXX&PACAHeaders=x-serviceworker-test&PreflightTest=200',
448 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
449 [methodIsXXX, hasCustomHeader]],
450 [OTHER_BASE_URL + 'mode=cors&method=XXX&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAMethods=XXX&ACAHeaders=x-serviceworker-test&PreflightTest=200',
451 [fetchRejected]],
452
453 // Test that CORS check is done in both preflight and main fetch.
454 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&PACAMethods=XXX&PreflightT est=200',
455 [fetchRejected]],
456 [OTHER_BASE_URL + 'mode=cors&method=XXX&PACAOrigin=*&PACAMethods=XXX&Preflight Test=200',
457 [fetchRejected]],
458
459 // Test that Access-Control-Expose-Headers of CORS preflight is ignored.
460 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&PACAOrigin=*&PACAMethods=X XX&PACEHeaders=Content-Length, X-ServiceWorker-ServerHeader&PreflightTest=200',
461 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
462 [methodIsXXX]],
463
464 // Test that CORS preflight with Status 2XX succeeds.
465 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&PACAOrigin=*&PACAMethods=X XX&PreflightTest=201',
466 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
467 [methodIsXXX]],
468
469 // Test that CORS preflight with Status other than 2XX fails.
470 // https://crbug.com/452394
471 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&PACAOrigin=*&PACAMethods=X XX&PreflightTest=301',
472 [fetchRejected]],
473 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&PACAOrigin=*&PACAMethods=X XX&PreflightTest=401',
474 [fetchRejected]],
475 [OTHER_BASE_URL + 'mode=cors&method=XXX&ACAOrigin=*&PACAOrigin=*&PACAMethods=X XX&PreflightTest=500',
476 [fetchRejected]],
477
478 // Test CORS preflight with multiple request headers.
479 [OTHER_BASE_URL + 'mode=cors&method=XXX&headers=CUSTOM2&ACAOrigin=*&PACAOrigin =*&PACAMethods=XXX&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicew Orker-test, x-sErviceworker-s, x-sErviceworker-v&PreflightTest=200',
480 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
481 [methodIsXXX, hasCustomHeader2]],
482 [OTHER_BASE_URL + 'mode=cors&method=XXX&headers=CUSTOM2&ACAOrigin=*&PACAOrigin =*&PACAMethods=XXX&PACAHeaders=x-servicewOrker-test&PreflightTest=200',
483 [fetchRejected]],
484
485 // Test request headers sent in CORS preflight requests.
486 [OTHER_BASE_URL + 'mode=cors&method=XXX&headers=CUSTOM&ACAOrigin=*&PACAOrigin= *&PACAMethods=XXX&PACAHeaders=x-serviceworker-test&PreflightTest=200&PACRMethod= XXX&PACRHeaders=x-serviceworker-test',
487 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
488 [methodIsXXX, hasCustomHeader]],
489 // Test Access-Control-Request-Headers is sorted https://crbug.com/452391
490 [OTHER_BASE_URL + 'mode=cors&method=XXX&headers=CUSTOM2&ACAOrigin=*&PACAOrigin =*&PACAMethods=XXX&PACAHeaders=x-servicEworker-u, x-servicEworker-ua, x-servicew Orker-test, x-sErviceworker-s, x-sErviceworker-v&PreflightTest=200&PACRMethod=XX X&PACRHeaders=x-serviceworker-s, x-serviceworker-test, x-serviceworker-u, x-serv iceworker-ua, x-serviceworker-v',
491 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors],
492 [methodIsXXX, hasCustomHeader2]],
493 ]; 89 ];
494 90
495 if (self.importScripts) { 91 if (self.importScripts) {
496 executeTests(TEST_TARGETS); 92 executeTests(TEST_TARGETS);
497 done(); 93 done();
498 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698