OLD | NEW |
1 if (self.importScripts) { | 1 if (self.importScripts) { |
2 importScripts('/fetch/resources/fetch-test-helpers.js'); | 2 importScripts('/fetch/resources/fetch-test-helpers.js'); |
3 importScripts('/fetch/resources/thorough-util.js'); | 3 importScripts('/fetch/resources/thorough-util.js'); |
4 } | 4 } |
5 | 5 |
6 function createExpectedURLList(prefix, count, last) { | 6 function createExpectedURLList(prefix, count, last) { |
7 var array = []; | 7 var array = []; |
8 for (var i = count; i > 0; --i) | 8 for (var i = count; i > 0; --i) |
9 array.push(prefix + i); | 9 array.push(prefix + i); |
10 array.push(last); | 10 array.push(last); |
11 return array; | 11 return array; |
12 } | 12 } |
13 | 13 |
14 var TEST_TARGETS = [ | 14 var TEST_TARGETS = [ |
15 // Redirect loop: same origin -> same origin | 15 // Redirect loop: same origin -> same origin |
16 [REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL) + '&Count=20&mode=cors' + | 16 [REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL) + '&Count=20&mode=cors' + |
17 '&credentials=same-origin', | 17 '&credentials=same-origin', |
18 [fetchResolved, hasContentLength, hasBody, typeBasic, | 18 [fetchResolved, hasContentLength, hasBody, typeBasic, |
| 19 responseRedirected, |
19 checkURLList.bind( | 20 checkURLList.bind( |
20 self, | 21 self, |
21 createExpectedURLList( | 22 createExpectedURLList( |
22 REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL) + '&Count=', | 23 REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL) + '&Count=', |
23 19, BASE_URL))], | 24 19, BASE_URL))], |
24 [methodIsGET, authCheck1]], | 25 [methodIsGET, authCheck1]], |
25 [REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL) + '&Count=21&mode=cors' + | 26 [REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL) + '&Count=21&mode=cors' + |
26 '&credentials=same-origin', | 27 '&credentials=same-origin', |
27 [fetchRejected]], | 28 [fetchRejected]], |
28 | 29 |
29 // Redirect loop: same origin -> other origin | 30 // Redirect loop: same origin -> other origin |
30 [REDIRECT_LOOP_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + | 31 [REDIRECT_LOOP_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + |
31 '&Count=20&mode=cors&credentials=same-origin&method=GET', | 32 '&Count=20&mode=cors&credentials=same-origin&method=GET', |
32 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 33 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 34 responseRedirected, |
33 checkURLList.bind( | 35 checkURLList.bind( |
34 self, | 36 self, |
35 createExpectedURLList( | 37 createExpectedURLList( |
36 REDIRECT_LOOP_URL + | 38 REDIRECT_LOOP_URL + |
37 encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=') + '%2A&Count=', | 39 encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=') + '%2A&Count=', |
38 19, | 40 19, |
39 OTHER_BASE_URL + '&ACAOrigin=*'))], | 41 OTHER_BASE_URL + '&ACAOrigin=*'))], |
40 [methodIsGET, authCheckNone]], | 42 [methodIsGET, authCheckNone]], |
41 // FIXME: due to the current implementation of Chromium, | 43 // FIXME: due to the current implementation of Chromium, |
42 // Count=21 is resolved, Count=22 is rejected. | 44 // Count=21 is resolved, Count=22 is rejected. |
43 // https://crbug.com/353768 | 45 // https://crbug.com/353768 |
44 [REDIRECT_LOOP_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + | 46 [REDIRECT_LOOP_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + |
45 '&Count=22&mode=cors&credentials=same-origin&method=GET', | 47 '&Count=22&mode=cors&credentials=same-origin&method=GET', |
46 [fetchRejected]], | 48 [fetchRejected]], |
47 | 49 |
48 // Redirect loop: other origin -> same origin | 50 // Redirect loop: other origin -> same origin |
49 [OTHER_REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + | 51 [OTHER_REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + |
50 '&Count=20&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 52 '&Count=20&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
51 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 53 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 54 responseRedirected, |
52 checkURLList.bind( | 55 checkURLList.bind( |
53 self, | 56 self, |
54 createExpectedURLList( | 57 createExpectedURLList( |
55 OTHER_REDIRECT_LOOP_URL + | 58 OTHER_REDIRECT_LOOP_URL + |
56 encodeURIComponent(BASE_URL + 'ACAOrigin=') + | 59 encodeURIComponent(BASE_URL + 'ACAOrigin=') + |
57 '%2A&ACAOrigin=*&Count=', | 60 '%2A&ACAOrigin=*&Count=', |
58 19, | 61 19, |
59 BASE_URL + 'ACAOrigin=*'))], | 62 BASE_URL + 'ACAOrigin=*'))], |
60 [methodIsGET, authCheckNone]], | 63 [methodIsGET, authCheckNone]], |
61 [OTHER_REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + | 64 [OTHER_REDIRECT_LOOP_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + |
62 '&Count=21&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 65 '&Count=21&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
63 [fetchRejected]], | 66 [fetchRejected]], |
64 | 67 |
65 // Redirect loop: other origin -> other origin | 68 // Redirect loop: other origin -> other origin |
66 [OTHER_REDIRECT_LOOP_URL + | 69 [OTHER_REDIRECT_LOOP_URL + |
67 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + | 70 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + |
68 '&Count=20&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 71 '&Count=20&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
69 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 72 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 73 responseRedirected, |
70 checkURLList.bind( | 74 checkURLList.bind( |
71 self, | 75 self, |
72 createExpectedURLList( | 76 createExpectedURLList( |
73 OTHER_REDIRECT_LOOP_URL + | 77 OTHER_REDIRECT_LOOP_URL + |
74 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=') + | 78 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=') + |
75 '%2A&ACAOrigin=*&Count=', | 79 '%2A&ACAOrigin=*&Count=', |
76 19, | 80 19, |
77 OTHER_BASE_URL + 'ACAOrigin=*'))], | 81 OTHER_BASE_URL + 'ACAOrigin=*'))], |
78 [methodIsGET, authCheckNone]], | 82 [methodIsGET, authCheckNone]], |
79 [OTHER_REDIRECT_LOOP_URL + | 83 [OTHER_REDIRECT_LOOP_URL + |
80 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + | 84 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + |
81 '&Count=21&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 85 '&Count=21&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
82 [fetchRejected]], | 86 [fetchRejected]], |
83 ]; | 87 ]; |
84 | 88 |
85 if (self.importScripts) { | 89 if (self.importScripts) { |
86 executeTests(TEST_TARGETS); | 90 executeTests(TEST_TARGETS); |
87 done(); | 91 done(); |
88 } | 92 } |
OLD | NEW |