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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/service-workers/service-worker/fetch-event-redirect.https.html

Issue 2415873002: Import w3c tests for the service workers (Closed)
Patch Set: Rebase Created 4 years, 2 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
(Empty)
1 <!DOCTYPE html>
2 <title>Service Worker: Fetch Event Redirect Handling</title>
3 <meta name=timeout content=long>
4 <script src="/resources/testharness.js"></script>
5 <script src="resources/testharness-helpers.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="resources/get-host-info.sub.js"></script>
8 <script src="resources/test-helpers.sub.js"></script>
9 <body>
10 <script>
11
12 // ------------------------
13 // Utilities for testing non-navigation requests that are intercepted with
14 // a redirect.
15
16 var host_info = get_host_info();
17 var worker = 'resources/fetch-rewrite-worker.js';
18 var frameURL = host_info['HTTPS_ORIGIN'] + base_path() +
19 'resources/fetch-event-redirect-iframe.html';
20 var baseScope = 'resources/';
21 var redirect = 'redirect.py';
22 var success = base_path() + 'resources/success.py';
23
24 function redirect_fetch_test(t, test) {
25 var scope = baseScope + test.name;
26 service_worker_unregister_and_register(t, worker, scope).then(function(reg) {
27 return wait_for_state(t, reg.installing, 'activated');
28 }).then(function() {
29 return with_iframe(scope + '?url=' + encodeURIComponent(frameURL));
30 }).then(function(frame) {
31 var hostKeySuffix = test['url_credentials'] ? '_WITH_CREDS' : '';
32
33 var acaorigin = '';
34 var host = host_info['HTTPS_ORIGIN' + hostKeySuffix];
35 if (test['redirect_dest'] === 'no-cors') {
36 host = host_info['HTTPS_REMOTE_ORIGIN' + hostKeySuffix]
37 } else if (test['redirect_dest'] === 'cors') {
38 acaorigin = '?ACAOrigin=' + encodeURIComponent(host_info['HTTPS_ORIGIN']);
39 host = host_info['HTTPS_REMOTE_ORIGIN' + hostKeySuffix]
40 }
41
42 var dest = '?Redirect=' + encodeURIComponent(host + success + acaorigin);
43
44 var expectedTypeParam = test['expected_type']
45 ? '&expected_type=' + test['expected_type']
46 : '';
47
48 var expectedRedirectedParam = test['expected_redirected']
49 ? '&expected_redirected=' + test['expected_redi rected']
50 : '';
51
52 var url = scope +
53 '?url=' + encodeURIComponent(redirect + dest) +
54 expectedTypeParam + expectedRedirectedParam
55
56 var p = new Promise(function(resolve, reject) {
57 var channel = new MessageChannel();
58 channel.port1.onmessage = function(e) {
59 frame.remove();
60 if (e.data.result === 'reject') {
61 reject(e.data.detail);
62 } else if (e.data.result === 'success') {
63 resolve(e.data.result);
64 } else {
65 resolve(e.data.detail);
66 }
67 };
68 frame.contentWindow.postMessage({
69 url: url,
70 request_init: test.request_init,
71 redirect_dest: test.redirect_dest,
72 expected_type: test.expected_type,
73 expected_redirected: test.expected_redirected,
74 }, '*', [channel.port2]);
75 });
76
77 if (test.should_reject) {
78 return assert_promise_rejects(p);
79 }
80
81 return p.then(function(result) {
82 if (result !== 'success') {
83 throw(new Error(result));
84 }
85 });
86 }).then(function() {
87 return service_worker_unregister_and_done(t, scope);
88 }).catch(unreached_rejection(t));
89 }
90
91 // ------------------------
92 // Test every combination of:
93 // - RequestMode (same-origin, cors, no-cors)
94 // - RequestRedirect (manual, follow, error)
95 // - redirect destination origin (same-origin, cors, no-cors)
96 // - redirect destination credentials (no user/pass, user/pass)
97 //
98 // TODO: add navigation requests
99 // TODO: add redirects to data URI and verify same-origin data-URL flag behavior
100 // TODO: add test where original redirect URI is cross-origin
101 // TODO: verify final method is correct for 301, 302, and 303
102 // TODO: verify CORS redirect results in all further redirects being
103 // considered cross origin
104
105 async_test(function(t) {
106 redirect_fetch_test(t, {
107 name: 'nonav-manual-cors-redirects-to-sameorigin-nocreds',
108 redirect_dest: 'same-origin',
109 url_credentials: false,
110 expected_type: 'opaqueredirect',
111 expected_redirected: false,
112 request_init: {
113 redirect: 'manual',
114 mode: 'cors'
115 },
116 // should reject because only navigations can be intercepted with
117 // opaqueredirect responses
118 should_reject: true
119 });
120 }, 'Non-navigation, manual redirect, cors mode Request redirected to ' +
121 'same-origin without credentials should fail opaqueredirect interception ' +
122 'and response should not be redirected');
123
124 async_test(function(t) {
125 redirect_fetch_test(t, {
126 name: 'nonav-manual-cors-redirects-to-nocors-nocreds',
127 redirect_dest: 'no-cors',
128 url_credentials: false,
129 expected_type: 'opaqueredirect',
130 expected_redirected: false,
131 request_init: {
132 redirect: 'manual',
133 mode: 'cors'
134 },
135 // should reject because only navigations can be intercepted with
136 // opaqueredirect responses
137 should_reject: true
138 });
139 }, 'Non-navigation, manual redirect, cors mode Request redirected to ' +
140 'no-cors without credentials should fail opaqueredirect interception ' +
141 'and response should not be redirected');
142
143 async_test(function(t) {
144 redirect_fetch_test(t, {
145 name: 'nonav-manual-cors-redirects-to-cors-nocreds',
146 redirect_dest: 'cors',
147 url_credentials: false,
148 expected_type: 'opaqueredirect',
149 expected_redirected: false,
150 request_init: {
151 redirect: 'manual',
152 mode: 'cors'
153 },
154 // should reject because only navigations can be intercepted with
155 // opaqueredirect responses
156 should_reject: true
157 });
158 }, 'Non-navigation, manual redirect, cors mode Request redirected to ' +
159 'cors without credentials should fail opaqueredirect interception ' +
160 'and response should not be redirected');
161
162 async_test(function(t) {
163 redirect_fetch_test(t, {
164 name: 'nonav-manual-sameorigin-redirects-to-sameorigin-nocreds',
165 redirect_dest: 'same-origin',
166 url_credentials: false,
167 expected_type: 'opaqueredirect',
168 expected_redirected: false,
169 request_init: {
170 redirect: 'manual',
171 mode: 'same-origin'
172 },
173 // should reject because only navigations can be intercepted with
174 // opaqueredirect responses
175 should_reject: true
176 });
177 }, 'Non-navigation, manual redirect, same-origin mode Request redirected to ' +
178 'same-origin without credentials should fail opaqueredirect interception ' +
179 'and response should not be redirected');
180
181 async_test(function(t) {
182 redirect_fetch_test(t, {
183 name: 'nonav-manual-sameorigin-redirects-to-nocors-nocreds',
184 redirect_dest: 'no-cors',
185 url_credentials: false,
186 expected_type: 'opaqueredirect',
187 expected_redirected: false,
188 request_init: {
189 redirect: 'manual',
190 mode: 'same-origin'
191 },
192 // should reject because only navigations can be intercepted with
193 // opaqueredirect responses
194 should_reject: true
195 });
196 }, 'Non-navigation, manual redirect, same-origin mode Request redirected to ' +
197 'no-cors without credentials should fail opaqueredirect interception ' +
198 'and response should not be redirected');
199
200 async_test(function(t) {
201 redirect_fetch_test(t, {
202 name: 'nonav-manual-sameorigin-redirects-to-cors-nocreds',
203 redirect_dest: 'cors',
204 url_credentials: false,
205 expected_type: 'opaqueredirect',
206 expected_redirected: false,
207 request_init: {
208 redirect: 'manual',
209 mode: 'same-origin'
210 },
211 // should reject because only navigations can be intercepted with
212 // opaqueredirect responses
213 should_reject: true
214 });
215 }, 'Non-navigation, manual redirect, same-origin mode Request redirected to ' +
216 'cors without credentials should fail opaqueredirect interception ' +
217 'and response should not be redirected');
218
219 async_test(function(t) {
220 redirect_fetch_test(t, {
221 name: 'nonav-manual-nocors-redirects-to-sameorigin-nocreds',
222 redirect_dest: 'same-origin',
223 url_credentials: false,
224 expected_type: 'opaqueredirect',
225 expected_redirected: false,
226 request_init: {
227 redirect: 'manual',
228 mode: 'no-cors'
229 },
230 // should reject because only navigations can be intercepted with
231 // opaqueredirect responses
232 should_reject: true
233 });
234 }, 'Non-navigation, manual redirect, no-cors mode Request redirected to ' +
235 'same-origin without credentials should fail opaqueredirect interception ' +
236 'and response should not be redirected');
237
238 async_test(function(t) {
239 redirect_fetch_test(t, {
240 name: 'nonav-manual-nocors-redirects-to-nocors-nocreds',
241 redirect_dest: 'no-cors',
242 url_credentials: false,
243 expected_type: 'opaqueredirect',
244 expected_redirected: false,
245 request_init: {
246 redirect: 'manual',
247 mode: 'no-cors'
248 },
249 should_reject: false
250 });
251 }, 'Non-navigation, manual redirect, no-cors mode Request redirected to ' +
252 'no-cors without credentials should succeed interception ' +
253 'and response should not be redirected');
254
255 async_test(function(t) {
256 redirect_fetch_test(t, {
257 name: 'nonav-manual-nocors-redirects-to-cors-nocreds',
258 redirect_dest: 'cors',
259 url_credentials: false,
260 expected_type: 'opaqueredirect',
261 expected_redirected: false,
262 request_init: {
263 redirect: 'manual',
264 mode: 'no-cors'
265 },
266 should_reject: false
267 });
268 }, 'Non-navigation, manual redirect, no-cors mode Request redirected to ' +
269 'cors without credentials should succeed interception ' +
270 'and response should not be redirected');
271
272 async_test(function(t) {
273 redirect_fetch_test(t, {
274 name: 'nonav-manual-cors-redirects-to-sameorigin-creds',
275 redirect_dest: 'same-origin',
276 url_credentials: true,
277 expected_type: 'opaqueredirect',
278 expected_redirected: false,
279 request_init: {
280 redirect: 'manual',
281 mode: 'cors'
282 },
283 // should reject because only navigations can be intercepted with
284 // opaqueredirect responses
285 should_reject: true
286 });
287 }, 'Non-navigation, manual redirect, cors mode Request redirected to ' +
288 'same-origin with credentials should fail opaqueredirect interception ' +
289 'and response should not be redirected');
290
291 async_test(function(t) {
292 redirect_fetch_test(t, {
293 name: 'nonav-manual-cors-redirects-to-nocors-creds',
294 redirect_dest: 'no-cors',
295 url_credentials: true,
296 expected_type: 'opaqueredirect',
297 expected_redirected: false,
298 request_init: {
299 redirect: 'manual',
300 mode: 'cors'
301 },
302 // should reject because only navigations can be intercepted with
303 // opaqueredirect responses
304 should_reject: true
305 });
306 }, 'Non-navigation, manual redirect, cors mode Request redirected to ' +
307 'no-cors with credentials should fail opaqueredirect interception ' +
308 'and response should not be redirected');
309
310 async_test(function(t) {
311 redirect_fetch_test(t, {
312 name: 'nonav-manual-cors-redirects-to-cors-creds',
313 redirect_dest: 'cors',
314 url_credentials: true,
315 expected_type: 'opaqueredirect',
316 expected_redirected: false,
317 request_init: {
318 redirect: 'manual',
319 mode: 'cors'
320 },
321 // should reject because only navigations can be intercepted with
322 // opaqueredirect responses
323 should_reject: true
324 });
325 }, 'Non-navigation, manual redirect, cors mode Request redirected to ' +
326 'cors with credentials should fail opaqueredirect interception ' +
327 'and response should not be redirected');
328
329 async_test(function(t) {
330 redirect_fetch_test(t, {
331 name: 'nonav-manual-sameorigin-redirects-to-sameorigin-creds',
332 redirect_dest: 'same-origin',
333 url_credentials: true,
334 expected_type: 'opaqueredirect',
335 expected_redirected: false,
336 request_init: {
337 redirect: 'manual',
338 mode: 'same-origin'
339 },
340 // should reject because only navigations can be intercepted with
341 // opaqueredirect responses
342 should_reject: true
343 });
344 }, 'Non-navigation, manual redirect, same-origin mode Request redirected to ' +
345 'same-origin with credentials should fail opaqueredirect interception ' +
346 'and response should not be redirected');
347
348 async_test(function(t) {
349 redirect_fetch_test(t, {
350 name: 'nonav-manual-sameorigin-redirects-to-nocors-creds',
351 redirect_dest: 'no-cors',
352 url_credentials: true,
353 expected_type: 'opaqueredirect',
354 expected_redirected: false,
355 request_init: {
356 redirect: 'manual',
357 mode: 'same-origin'
358 },
359 // should reject because only navigations can be intercepted with
360 // opaqueredirect responses
361 should_reject: true
362 });
363 }, 'Non-navigation, manual redirect, same-origin mode Request redirected to ' +
364 'no-cors with credentials should fail opaqueredirect interception ' +
365 'and response should not be redirected');
366
367 async_test(function(t) {
368 redirect_fetch_test(t, {
369 name: 'nonav-manual-sameorigin-redirects-to-cors-creds',
370 redirect_dest: 'cors',
371 url_credentials: true,
372 expected_type: 'opaqueredirect',
373 expected_redirected: false,
374 request_init: {
375 redirect: 'manual',
376 mode: 'same-origin'
377 },
378 // should reject because only navigations can be intercepted with
379 // opaqueredirect responses
380 should_reject: true
381 });
382 }, 'Non-navigation, manual redirect, same-origin mode Request redirected to ' +
383 'cors with credentials should fail opaqueredirect interception ' +
384 'and response should not be redirected');
385
386 async_test(function(t) {
387 redirect_fetch_test(t, {
388 name: 'nonav-manual-nocors-redirects-to-sameorigin-creds',
389 redirect_dest: 'same-origin',
390 url_credentials: true,
391 expected_type: 'opaqueredirect',
392 expected_redirected: false,
393 request_init: {
394 redirect: 'manual',
395 mode: 'no-cors'
396 },
397 // should reject because only navigations can be intercepted with
398 // opaqueredirect responses
399 should_reject: true
400 });
401 }, 'Non-navigation, manual redirect, no-cors mode Request redirected to ' +
402 'same-origin with credentials should fail opaqueredirect interception ' +
403 'and response should not be redirected');
404
405 async_test(function(t) {
406 redirect_fetch_test(t, {
407 name: 'nonav-manual-nocors-redirects-to-nocors-creds',
408 redirect_dest: 'no-cors',
409 url_credentials: true,
410 expected_type: 'opaqueredirect',
411 expected_redirected: false,
412 request_init: {
413 redirect: 'manual',
414 mode: 'no-cors'
415 },
416 should_reject: false
417 });
418 }, 'Non-navigation, manual redirect, no-cors mode Request redirected to ' +
419 'no-cors with credentials should succeed interception ' +
420 'and response should not be redirected');
421
422 async_test(function(t) {
423 redirect_fetch_test(t, {
424 name: 'nonav-manual-nocors-redirects-to-cors-creds',
425 redirect_dest: 'cors',
426 url_credentials: true,
427 expected_type: 'opaqueredirect',
428 expected_redirected: false,
429 request_init: {
430 redirect: 'manual',
431 mode: 'no-cors'
432 },
433 should_reject: false
434 });
435 }, 'Non-navigation, manual redirect, no-cors mode Request redirected to ' +
436 'cors with credentials should succeed interception ' +
437 'and response should not be redirected');
438
439 async_test(function(t) {
440 redirect_fetch_test(t, {
441 name: 'nonav-follow-cors-redirects-to-sameorigin-nocreds',
442 redirect_dest: 'same-origin',
443 url_credentials: false,
444 expected_type: 'basic',
445 expected_redirected: true,
446 request_init: {
447 redirect: 'follow',
448 mode: 'cors'
449 },
450 should_reject: false
451 });
452 }, 'Non-navigation, follow redirect, cors mode Request redirected to ' +
453 'same-origin without credentials should succeed interception ' +
454 'and response should be redirected');
455
456 async_test(function(t) {
457 redirect_fetch_test(t, {
458 name: 'nonav-follow-cors-redirects-to-nocors-nocreds',
459 redirect_dest: 'no-cors',
460 url_credentials: false,
461 expected_type: 'should-not-get-a-response',
462 expected_redirected: false,
463 request_init: {
464 redirect: 'follow',
465 mode: 'cors'
466 },
467 // should reject because CORS requests require CORS headers on cross-origin
468 // resources
469 should_reject: true
470 });
471 }, 'Non-navigation, follow redirect, cors mode Request redirected to ' +
472 'no-cors without credentials should fail interception ' +
473 'and response should not be redirected');
474
475 async_test(function(t) {
476 redirect_fetch_test(t, {
477 name: 'nonav-follow-cors-redirects-to-cors-nocreds',
478 redirect_dest: 'cors',
479 url_credentials: false,
480 expected_type: 'cors',
481 expected_redirected: true,
482 request_init: {
483 redirect: 'follow',
484 mode: 'cors'
485 },
486 should_reject: false
487 });
488 }, 'Non-navigation, follow redirect, cors mode Request redirected to ' +
489 'cors without credentials should succeed interception ' +
490 'and response should be redirected');
491
492 async_test(function(t) {
493 redirect_fetch_test(t, {
494 name: 'nonav-follow-sameorigin-redirects-to-sameorigin-nocreds',
495 redirect_dest: 'same-origin',
496 url_credentials: false,
497 expected_type: 'basic',
498 expected_redirected: true,
499 request_init: {
500 redirect: 'follow',
501 mode: 'same-origin'
502 },
503 should_reject: false
504 });
505 }, 'Non-navigation, follow redirect, same-origin mode Request redirected to ' +
506 'same-origin without credentials should succeed interception ' +
507 'and response should be redirected');
508
509 async_test(function(t) {
510 redirect_fetch_test(t, {
511 name: 'nonav-follow-sameorigin-redirects-to-nocors-nocreds',
512 redirect_dest: 'no-cors',
513 url_credentials: false,
514 expected_type: 'should-not-get-a-response',
515 expected_redirected: false,
516 request_init: {
517 redirect: 'follow',
518 mode: 'same-origin'
519 },
520 // should reject because same-origin requests cannot load cross-origin
521 // resources
522 should_reject: true
523 });
524 }, 'Non-navigation, follow redirect, same-origin mode Request redirected to ' +
525 'no-cors without credentials should fail interception ' +
526 'and response should not be redirected');
527
528 async_test(function(t) {
529 redirect_fetch_test(t, {
530 name: 'nonav-follow-sameorigin-redirects-to-cors-nocreds',
531 redirect_dest: 'cors',
532 url_credentials: false,
533 expected_type: 'should-not-get-a-response',
534 expected_redirected: false,
535 request_init: {
536 redirect: 'follow',
537 mode: 'same-origin'
538 },
539 // should reject because same-origin requests cannot load cross-origin
540 // resources
541 should_reject: true
542 });
543 }, 'Non-navigation, follow redirect, same-origin mode Request redirected to ' +
544 'cors without credentials should fail interception ' +
545 'and response should not be redirected');
546
547 async_test(function(t) {
548 redirect_fetch_test(t, {
549 name: 'nonav-follow-nocors-redirects-to-sameorigin-nocreds',
550 redirect_dest: 'same-origin',
551 url_credentials: false,
552 expected_type: 'basic',
553 expected_redirected: true,
554 request_init: {
555 redirect: 'follow',
556 mode: 'no-cors'
557 },
558 should_reject: false
559 });
560 }, 'Non-navigation, follow redirect, no-cors mode Request redirected to ' +
561 'same-origin without credentials should succeed interception ' +
562 'and response should be redirected');
563
564 async_test(function(t) {
565 redirect_fetch_test(t, {
566 name: 'nonav-follow-nocors-redirects-to-nocors-nocreds',
567 redirect_dest: 'no-cors',
568 url_credentials: false,
569 expected_type: 'opaque',
570 expected_redirected: false,
571 request_init: {
572 redirect: 'follow',
573 mode: 'no-cors'
574 },
575 should_reject: false
576 });
577 }, 'Non-navigation, follow redirect, no-cors mode Request redirected to ' +
578 'no-cors without credentials should succeed interception ' +
579 'and response should not be redirected');
580
581 async_test(function(t) {
582 redirect_fetch_test(t, {
583 name: 'nonav-follow-nocors-redirects-to-cors-nocreds',
584 redirect_dest: 'cors',
585 url_credentials: false,
586 expected_type: 'opaque',
587 expected_redirected: false,
588 request_init: {
589 redirect: 'follow',
590 mode: 'no-cors'
591 },
592 should_reject: false
593 });
594 }, 'Non-navigation, follow redirect, no-cors mode Request redirected to ' +
595 'cors without credentials should succeed interception ' +
596 'and response should not be redirected');
597
598 async_test(function(t) {
599 redirect_fetch_test(t, {
600 name: 'nonav-follow-cors-redirects-to-sameorigin-creds',
601 redirect_dest: 'same-origin',
602 url_credentials: true,
603 expected_type: 'basic',
604 expected_redirected: true,
605 request_init: {
606 redirect: 'follow',
607 mode: 'cors'
608 },
609 should_reject: false
610 });
611 }, 'Non-navigation, follow redirect, cors mode Request redirected to ' +
612 'same-origin with credentials should succeed interception ' +
613 'and response should be redirected');
614
615 async_test(function(t) {
616 redirect_fetch_test(t, {
617 name: 'nonav-follow-cors-redirects-to-nocors-creds',
618 redirect_dest: 'no-cors',
619 url_credentials: true,
620 expected_type: 'should-not-get-a-response',
621 expected_redirected: false,
622 request_init: {
623 redirect: 'follow',
624 mode: 'cors'
625 },
626 // should reject because CORS requests require CORS headers on cross-origin
627 // resources
628 should_reject: true
629 });
630 }, 'Non-navigation, follow redirect, cors mode Request redirected to ' +
631 'no-cors with credentials should fail interception ' +
632 'and response should not be redirected');
633
634 async_test(function(t) {
635 redirect_fetch_test(t, {
636 name: 'nonav-follow-cors-redirects-to-cors-creds',
637 redirect_dest: 'cors',
638 url_credentials: true,
639 expected_type: 'cors',
640 expected_redirected: true,
641 request_init: {
642 redirect: 'follow',
643 mode: 'cors'
644 },
645 // should reject because CORS requests do not allow user/pass entries in
646 // cross-origin URLs
647 // NOTE: https://github.com/whatwg/fetch/issues/112
648 should_reject: true
649 });
650 }, 'Non-navigation, follow redirect, cors mode Request redirected to ' +
651 'cors with credentials should fail interception ' +
652 'and response should be redirected');
653
654 async_test(function(t) {
655 redirect_fetch_test(t, {
656 name: 'nonav-follow-sameorigin-redirects-to-sameorigin-creds',
657 redirect_dest: 'same-origin',
658 url_credentials: true,
659 expected_type: 'basic',
660 expected_redirected: true,
661 request_init: {
662 redirect: 'follow',
663 mode: 'same-origin'
664 },
665 should_reject: false
666 });
667 }, 'Non-navigation, follow redirect, same-origin mode Request redirected to ' +
668 'same-origin with credentials should succeed interception ' +
669 'and response should be redirected');
670
671 async_test(function(t) {
672 redirect_fetch_test(t, {
673 name: 'nonav-follow-sameorigin-redirects-to-nocors-creds',
674 redirect_dest: 'no-cors',
675 url_credentials: true,
676 expected_type: 'should-not-get-a-response',
677 expected_redirected: false,
678 request_init: {
679 redirect: 'follow',
680 mode: 'same-origin'
681 },
682 // should reject because same-origin requests cannot load cross-origin
683 // resources
684 should_reject: true
685 });
686 }, 'Non-navigation, follow redirect, same-origin mode Request redirected to ' +
687 'no-cors with credentials should fail interception ' +
688 'and response should not be redirected');
689
690 async_test(function(t) {
691 redirect_fetch_test(t, {
692 name: 'nonav-follow-sameorigin-redirects-to-cors-creds',
693 redirect_dest: 'cors',
694 url_credentials: true,
695 expected_type: 'should-not-get-a-response',
696 expected_redirected: false,
697 request_init: {
698 redirect: 'follow',
699 mode: 'same-origin'
700 },
701 // should reject because same-origin requests cannot load cross-origin
702 // resources
703 should_reject: true
704 });
705 }, 'Non-navigation, follow redirect, same-origin mode Request redirected to ' +
706 'cors with credentials should fail interception ' +
707 'and response should not be redirected');
708
709 async_test(function(t) {
710 redirect_fetch_test(t, {
711 name: 'nonav-follow-nocors-redirects-to-sameorigin-creds',
712 redirect_dest: 'same-origin',
713 url_credentials: true,
714 expected_type: 'basic',
715 expected_redirected: true,
716 request_init: {
717 redirect: 'follow',
718 mode: 'no-cors'
719 },
720 should_reject: false
721 });
722 }, 'Non-navigation, follow redirect, no-cors mode Request redirected to ' +
723 'same-origin with credentials should succeed interception ' +
724 'and response should be redirected');
725
726 async_test(function(t) {
727 redirect_fetch_test(t, {
728 name: 'nonav-follow-nocors-redirects-to-nocors-creds',
729 redirect_dest: 'no-cors',
730 url_credentials: true,
731 expected_type: 'opaque',
732 expected_redirected: false,
733 request_init: {
734 redirect: 'follow',
735 mode: 'no-cors'
736 },
737 should_reject: false
738 });
739 }, 'Non-navigation, follow redirect, no-cors mode Request redirected to ' +
740 'no-cors with credentials should succeed interception ' +
741 'and response should not be redirected');
742
743 async_test(function(t) {
744 redirect_fetch_test(t, {
745 name: 'nonav-follow-nocors-redirects-to-cors-creds',
746 redirect_dest: 'cors',
747 url_credentials: true,
748 expected_type: 'opaque',
749 expected_redirected: false,
750 request_init: {
751 redirect: 'follow',
752 mode: 'no-cors'
753 },
754 should_reject: false
755 });
756 }, 'Non-navigation, follow redirect, no-cors mode Request redirected to ' +
757 'cors with credentials should succeed interception ' +
758 'and response should not be redirected');
759
760 async_test(function(t) {
761 redirect_fetch_test(t, {
762 name: 'nonav-error-cors-redirects-to-sameorigin-nocreds',
763 redirect_dest: 'same-origin',
764 url_credentials: false,
765 expected_type: 'error',
766 expected_redirected: false,
767 request_init: {
768 redirect: 'error',
769 mode: 'cors'
770 },
771 // should reject because requests with 'error' RequestRedirect cannot be
772 // redirected.
773 should_reject: true
774 });
775 }, 'Non-navigation, error redirect, cors mode Request redirected to ' +
776 'same-origin without credentials should fail interception ' +
777 'and response should not be redirected');
778
779 async_test(function(t) {
780 redirect_fetch_test(t, {
781 name: 'nonav-error-cors-redirects-to-nocors-nocreds',
782 redirect_dest: 'no-cors',
783 url_credentials: false,
784 expected_type: 'error',
785 expected_redirected: false,
786 request_init: {
787 redirect: 'error',
788 mode: 'cors'
789 },
790 // should reject because requests with 'error' RequestRedirect cannot be
791 // redirected.
792 should_reject: true
793 });
794 }, 'Non-navigation, error redirect, cors mode Request redirected to ' +
795 'no-cors without credentials should fail interception ' +
796 'and response should not be redirected');
797
798 async_test(function(t) {
799 redirect_fetch_test(t, {
800 name: 'nonav-error-cors-redirects-to-cors-nocreds',
801 redirect_dest: 'cors',
802 url_credentials: false,
803 expected_type: 'error',
804 expected_redirected: false,
805 request_init: {
806 redirect: 'error',
807 mode: 'cors'
808 },
809 // should reject because requests with 'error' RequestRedirect cannot be
810 // redirected.
811 should_reject: true
812 });
813 }, 'Non-navigation, error redirect, cors mode Request redirected to ' +
814 'cors without credentials should fail interception ' +
815 'and response should not be redirected');
816
817 async_test(function(t) {
818 redirect_fetch_test(t, {
819 name: 'nonav-error-sameorigin-redirects-to-sameorigin-nocreds',
820 redirect_dest: 'same-origin',
821 url_credentials: false,
822 expected_type: 'error',
823 expected_redirected: false,
824 request_init: {
825 redirect: 'error',
826 mode: 'same-origin'
827 },
828 // should reject because requests with 'error' RequestRedirect cannot be
829 // redirected.
830 should_reject: true
831 });
832 }, 'Non-navigation, error redirect, same-origin mode Request redirected to ' +
833 'same-origin without credentials should fail interception ' +
834 'and response should not be redirected');
835
836 async_test(function(t) {
837 redirect_fetch_test(t, {
838 name: 'nonav-error-sameorigin-redirects-to-nocors-nocreds',
839 redirect_dest: 'no-cors',
840 url_credentials: false,
841 expected_type: 'error',
842 expected_redirected: false,
843 request_init: {
844 redirect: 'error',
845 mode: 'same-origin'
846 },
847 // should reject because requests with 'error' RequestRedirect cannot be
848 // redirected.
849 should_reject: true
850 });
851 }, 'Non-navigation, error redirect, same-origin mode Request redirected to ' +
852 'no-cors without credentials should fail interception ' +
853 'and response should not be redirected');
854
855 async_test(function(t) {
856 redirect_fetch_test(t, {
857 name: 'nonav-error-sameorigin-redirects-to-cors-nocreds',
858 redirect_dest: 'cors',
859 url_credentials: false,
860 expected_type: 'error',
861 expected_redirected: false,
862 request_init: {
863 redirect: 'error',
864 mode: 'same-origin'
865 },
866 // should reject because requests with 'error' RequestRedirect cannot be
867 // redirected.
868 should_reject: true
869 });
870 }, 'Non-navigation, error redirect, same-origin mode Request redirected to ' +
871 'cors without credentials should fail interception ' +
872 'and response should not be redirected');
873
874 async_test(function(t) {
875 redirect_fetch_test(t, {
876 name: 'nonav-error-nocors-redirects-to-sameorigin-nocreds',
877 redirect_dest: 'same-origin',
878 url_credentials: false,
879 expected_type: 'error',
880 expected_redirected: false,
881 request_init: {
882 redirect: 'error',
883 mode: 'no-cors'
884 },
885 // should reject because requests with 'error' RequestRedirect cannot be
886 // redirected.
887 should_reject: true
888 });
889 }, 'Non-navigation, error redirect, no-cors mode Request redirected to ' +
890 'same-origin without credentials should fail interception ' +
891 'and response should not be redirected');
892
893 async_test(function(t) {
894 redirect_fetch_test(t, {
895 name: 'nonav-error-nocors-redirects-to-nocors-nocreds',
896 redirect_dest: 'no-cors',
897 url_credentials: false,
898 expected_type: 'error',
899 expected_redirected: false,
900 request_init: {
901 redirect: 'error',
902 mode: 'no-cors'
903 },
904 // should reject because requests with 'error' RequestRedirect cannot be
905 // redirected.
906 should_reject: true
907 });
908 }, 'Non-navigation, error redirect, no-cors mode Request redirected to ' +
909 'no-cors without credentials should fail interception ' +
910 'and response should not be redirected');
911
912 async_test(function(t) {
913 redirect_fetch_test(t, {
914 name: 'nonav-error-nocors-redirects-to-cors-nocreds',
915 redirect_dest: 'cors',
916 url_credentials: false,
917 expected_type: 'error',
918 expected_redirected: false,
919 request_init: {
920 redirect: 'error',
921 mode: 'no-cors'
922 },
923 // should reject because requests with 'error' RequestRedirect cannot be
924 // redirected.
925 should_reject: true
926 });
927 }, 'Non-navigation, error redirect, no-cors mode Request redirected to ' +
928 'cors without credentials should fail interception ' +
929 'and response should not be redirected');
930
931 async_test(function(t) {
932 redirect_fetch_test(t, {
933 name: 'nonav-error-cors-redirects-to-sameorigin-creds',
934 redirect_dest: 'same-origin',
935 url_credentials: true,
936 expected_type: 'error',
937 expected_redirected: false,
938 request_init: {
939 redirect: 'error',
940 mode: 'cors'
941 },
942 // should reject because requests with 'error' RequestRedirect cannot be
943 // redirected.
944 should_reject: true
945 });
946 }, 'Non-navigation, error redirect, cors mode Request redirected to ' +
947 'same-origin with credentials should fail interception ' +
948 'and response should not be redirected');
949
950 async_test(function(t) {
951 redirect_fetch_test(t, {
952 name: 'nonav-error-cors-redirects-to-nocors-creds',
953 redirect_dest: 'no-cors',
954 url_credentials: true,
955 expected_type: 'error',
956 expected_redirected: false,
957 request_init: {
958 redirect: 'error',
959 mode: 'cors'
960 },
961 // should reject because requests with 'error' RequestRedirect cannot be
962 // redirected.
963 should_reject: true
964 });
965 }, 'Non-navigation, error redirect, cors mode Request redirected to ' +
966 'no-cors with credentials should fail interception ' +
967 'and response should not be redirected');
968
969 async_test(function(t) {
970 redirect_fetch_test(t, {
971 name: 'nonav-error-cors-redirects-to-cors-creds',
972 redirect_dest: 'cors',
973 url_credentials: true,
974 expected_type: 'error',
975 expected_redirected: false,
976 request_init: {
977 redirect: 'error',
978 mode: 'cors'
979 },
980 // should reject because requests with 'error' RequestRedirect cannot be
981 // redirected.
982 should_reject: true
983 });
984 }, 'Non-navigation, error redirect, cors mode Request redirected to ' +
985 'cors with credentials should fail interception ' +
986 'and response should not be redirected');
987
988 async_test(function(t) {
989 redirect_fetch_test(t, {
990 name: 'nonav-error-sameorigin-redirects-to-sameorigin-creds',
991 redirect_dest: 'same-origin',
992 url_credentials: true,
993 expected_type: 'error',
994 expected_redirected: false,
995 request_init: {
996 redirect: 'error',
997 mode: 'same-origin'
998 },
999 // should reject because requests with 'error' RequestRedirect cannot be
1000 // redirected.
1001 should_reject: true
1002 });
1003 }, 'Non-navigation, error redirect, same-origin mode Request redirected to ' +
1004 'same-origin with credentials should fail interception ' +
1005 'and response should not be redirected');
1006
1007 async_test(function(t) {
1008 redirect_fetch_test(t, {
1009 name: 'nonav-error-sameorigin-redirects-to-nocors-creds',
1010 redirect_dest: 'no-cors',
1011 url_credentials: true,
1012 expected_type: 'error',
1013 expected_redirected: false,
1014 request_init: {
1015 redirect: 'error',
1016 mode: 'same-origin'
1017 },
1018 // should reject because requests with 'error' RequestRedirect cannot be
1019 // redirected.
1020 should_reject: true
1021 });
1022 }, 'Non-navigation, error redirect, same-origin mode Request redirected to ' +
1023 'no-cors with credentials should fail interception ' +
1024 'and response should not be redirected');
1025
1026 async_test(function(t) {
1027 redirect_fetch_test(t, {
1028 name: 'nonav-error-sameorigin-redirects-to-cors-creds',
1029 redirect_dest: 'cors',
1030 url_credentials: true,
1031 expected_type: 'error',
1032 expected_redirected: false,
1033 request_init: {
1034 redirect: 'error',
1035 mode: 'same-origin'
1036 },
1037 // should reject because requests with 'error' RequestRedirect cannot be
1038 // redirected.
1039 should_reject: true
1040 });
1041 }, 'Non-navigation, error redirect, same-origin mode Request redirected to ' +
1042 'cors with credentials should fail interception ' +
1043 'and response should not be redirected');
1044
1045 async_test(function(t) {
1046 redirect_fetch_test(t, {
1047 name: 'nonav-error-nocors-redirects-to-sameorigin-creds',
1048 redirect_dest: 'same-origin',
1049 url_credentials: true,
1050 expected_type: 'error',
1051 expected_redirected: false,
1052 request_init: {
1053 redirect: 'error',
1054 mode: 'no-cors'
1055 },
1056 // should reject because requests with 'error' RequestRedirect cannot be
1057 // redirected.
1058 should_reject: true
1059 });
1060 }, 'Non-navigation, error redirect, no-cors mode Request redirected to ' +
1061 'same-origin with credentials should fail interception ' +
1062 'and response should not be redirected');
1063
1064 async_test(function(t) {
1065 redirect_fetch_test(t, {
1066 name: 'nonav-error-nocors-redirects-to-nocors-creds',
1067 redirect_dest: 'no-cors',
1068 url_credentials: true,
1069 expected_type: 'error',
1070 expected_redirected: false,
1071 request_init: {
1072 redirect: 'error',
1073 mode: 'no-cors'
1074 },
1075 // should reject because requests with 'error' RequestRedirect cannot be
1076 // redirected.
1077 should_reject: true
1078 });
1079 }, 'Non-navigation, error redirect, no-cors mode Request redirected to ' +
1080 'no-cors with credentials should fail interception ' +
1081 'and response should not be redirected');
1082
1083 async_test(function(t) {
1084 redirect_fetch_test(t, {
1085 name: 'nonav-error-nocors-redirects-to-cors-creds',
1086 redirect_dest: 'cors',
1087 url_credentials: true,
1088 expected_type: 'error',
1089 expected_redirected: false,
1090 request_init: {
1091 redirect: 'error',
1092 mode: 'no-cors'
1093 },
1094 // should reject because requests with 'error' RequestRedirect cannot be
1095 // redirected.
1096 should_reject: true
1097 });
1098 }, 'Non-navigation, error redirect, no-cors mode Request redirected to ' +
1099 'cors with credentials should fail interception and response should not ' +
1100 'be redirected');
1101 </script>
1102 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698