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 var TEST_TARGETS = [ | 6 var TEST_TARGETS = [ |
7 // Redirect: same origin -> same origin | 7 // Redirect: same origin -> same origin |
8 [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 8 [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
9 '&mode=same-origin&method=GET', | 9 '&mode=same-origin&method=GET', |
10 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, | 10 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, |
11 checkURLList.bind(self, [BASE_URL])], | 11 responseRedirected, checkURLList.bind(self, [BASE_URL])], |
12 [methodIsGET, authCheck1]], | 12 [methodIsGET, authCheck1]], |
13 | 13 |
14 // https://fetch.spec.whatwg.org/#concept-http-fetch | 14 // https://fetch.spec.whatwg.org/#concept-http-fetch |
15 // Step 4, Case 301/302/303/307/308: | 15 // Step 4, Case 301/302/303/307/308: |
16 // Step 2: If location is null, return response. | 16 // Step 2: If location is null, return response. |
17 [REDIRECT_URL + 'noLocation' + | 17 [REDIRECT_URL + 'noLocation' + |
18 '&mode=same-origin&method=GET&NoRedirectTest=true', | 18 '&mode=same-origin&method=GET&NoRedirectTest=true', |
19 [fetchResolved, hasBody, typeBasic, checkURLList.bind(self, [])], | 19 [fetchResolved, hasBody, typeBasic, responseNotRedirected, |
| 20 checkURLList.bind(self, [])], |
20 [checkJsonpNoRedirect]], | 21 [checkJsonpNoRedirect]], |
21 // Step 5: If locationURL is failure, return a network error. | 22 // Step 5: If locationURL is failure, return a network error. |
22 [REDIRECT_URL + 'http://' + | 23 [REDIRECT_URL + 'http://' + |
23 '&mode=same-origin&method=GET', | 24 '&mode=same-origin&method=GET', |
24 [fetchRejected]], | 25 [fetchRejected]], |
25 | 26 |
26 [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 27 [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
27 '&mode=same-origin&method=GET&headers=CUSTOM', | 28 '&mode=same-origin&method=GET&headers=CUSTOM', |
28 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, | 29 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, |
29 checkURLList.bind(self, [BASE_URL])], | 30 responseRedirected, checkURLList.bind(self, [BASE_URL])], |
30 [methodIsGET, hasCustomHeader, authCheck1]], | 31 [methodIsGET, hasCustomHeader, authCheck1]], |
31 // Chrome changes the method from POST to GET when it recieves 301 redirect | 32 // Chrome changes the method from POST to GET when it recieves 301 redirect |
32 // response. See a note in http://tools.ietf.org/html/rfc7231#section-6.4.2 | 33 // response. See a note in http://tools.ietf.org/html/rfc7231#section-6.4.2 |
33 [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 34 [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
34 '&mode=same-origin&method=POST&Status=301', | 35 '&mode=same-origin&method=POST&Status=301', |
35 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, | 36 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, |
36 checkURLList.bind(self, [BASE_URL])], | 37 responseRedirected, checkURLList.bind(self, [BASE_URL])], |
37 [methodIsGET, authCheck1]], | 38 [methodIsGET, authCheck1]], |
38 // Chrome changes the method from POST to GET when it recieves 302 redirect | 39 // Chrome changes the method from POST to GET when it recieves 302 redirect |
39 // response. See a note in http://tools.ietf.org/html/rfc7231#section-6.4.3 | 40 // response. See a note in http://tools.ietf.org/html/rfc7231#section-6.4.3 |
40 [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 41 [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
41 '&mode=same-origin&method=POST', | 42 '&mode=same-origin&method=POST', |
42 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, | 43 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, |
43 checkURLList.bind(self, [BASE_URL])], | 44 responseRedirected, checkURLList.bind(self, [BASE_URL])], |
44 [methodIsGET, authCheck1]], | 45 [methodIsGET, authCheck1]], |
45 // GET method must be used for 303 redirect. | 46 // GET method must be used for 303 redirect. |
46 [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 47 [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
47 '&mode=same-origin&method=POST&Status=303', | 48 '&mode=same-origin&method=POST&Status=303', |
48 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, | 49 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, |
49 checkURLList.bind(self, [BASE_URL])], | 50 responseRedirected, checkURLList.bind(self, [BASE_URL])], |
50 [methodIsGET, authCheck1]], | 51 [methodIsGET, authCheck1]], |
51 // The 307 redirect response doesn't change the method. | 52 // The 307 redirect response doesn't change the method. |
52 [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 53 [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
53 '&mode=same-origin&method=POST&Status=307', | 54 '&mode=same-origin&method=POST&Status=307', |
54 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, | 55 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, |
55 checkURLList.bind(self, [BASE_URL])], | 56 responseRedirected, checkURLList.bind(self, [BASE_URL])], |
56 [methodIsPOST, authCheck1]], | 57 [methodIsPOST, authCheck1]], |
57 // The 308 redirect response doesn't change the method. | 58 // The 308 redirect response doesn't change the method. |
58 // FIXME: currently this and following 308 tests are disabled because they | 59 // FIXME: currently this and following 308 tests are disabled because they |
59 // fail on try bots, probably due to Apache/PHP versions. | 60 // fail on try bots, probably due to Apache/PHP versions. |
60 // https://crbug.com/451938 | 61 // https://crbug.com/451938 |
61 // [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 62 // [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
62 // '&mode=same-origin&method=POST&Status=308', | 63 // '&mode=same-origin&method=POST&Status=308', |
63 // [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], | 64 // [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic], |
64 // [methodIsPOST, authCheck1]], | 65 // [methodIsPOST, authCheck1]], |
65 | 66 |
66 // Do not redirect for other status even if Location header exists. | 67 // Do not redirect for other status even if Location header exists. |
67 [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 68 [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
68 '&mode=same-origin&credentials=same-origin&method=POST&Status=201&' + | 69 '&mode=same-origin&credentials=same-origin&method=POST&Status=201&' + |
69 'NoRedirectTest=true', | 70 'NoRedirectTest=true', |
70 [fetchResolved, hasBody, typeBasic, checkURLList.bind(self, [])], | 71 [fetchResolved, hasBody, typeBasic, |
| 72 responseNotRedirected, checkURLList.bind(self, [])], |
71 [checkJsonpNoRedirect]], | 73 [checkJsonpNoRedirect]], |
72 | 74 |
73 [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 75 [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
74 '&mode=same-origin&credentials=same-origin&method=PUT', | 76 '&mode=same-origin&credentials=same-origin&method=PUT', |
75 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, | 77 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, |
76 checkURLList.bind(self, [BASE_URL])], | 78 responseRedirected, checkURLList.bind(self, [BASE_URL])], |
77 [methodIsPUT, authCheck1]], | 79 [methodIsPUT, authCheck1]], |
78 | 80 |
79 [REDIRECT_URL + encodeURIComponent(BASE_URL) + | 81 [REDIRECT_URL + encodeURIComponent(BASE_URL) + |
80 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM', | 82 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM', |
81 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, | 83 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeBasic, |
82 checkURLList.bind(self, [BASE_URL])], | 84 responseRedirected, checkURLList.bind(self, [BASE_URL])], |
83 [methodIsGET, hasCustomHeader, authCheck1]], | 85 [methodIsGET, hasCustomHeader, authCheck1]], |
84 | 86 |
85 // Redirect: same origin -> other origin | 87 // Redirect: same origin -> other origin |
86 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + | 88 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + |
87 '&mode=same-origin&credentials=same-origin&method=GET', | 89 '&mode=same-origin&credentials=same-origin&method=GET', |
88 [fetchRejected]], | 90 [fetchRejected]], |
89 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + | 91 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + |
90 '&mode=same-origin&credentials=same-origin&method=POST', | 92 '&mode=same-origin&credentials=same-origin&method=POST', |
91 [fetchRejected]], | 93 [fetchRejected]], |
92 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + | 94 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + |
93 '&mode=same-origin&credentials=same-origin&method=PUT', | 95 '&mode=same-origin&credentials=same-origin&method=PUT', |
94 [fetchRejected]], | 96 [fetchRejected]], |
95 | 97 |
96 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + | 98 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + |
97 '&mode=cors&credentials=same-origin&method=GET', | 99 '&mode=cors&credentials=same-origin&method=GET', |
98 [fetchRejected]], | 100 [fetchRejected]], |
99 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + | 101 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + |
100 '&mode=cors&credentials=same-origin&method=PUT', | 102 '&mode=cors&credentials=same-origin&method=PUT', |
101 [fetchRejected]], | 103 [fetchRejected]], |
102 | 104 |
103 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + | 105 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + |
104 '&mode=cors&credentials=same-origin&method=GET', | 106 '&mode=cors&credentials=same-origin&method=GET', |
105 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 107 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 108 responseRedirected, |
106 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], | 109 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], |
107 [methodIsGET, authCheckNone]], | 110 [methodIsGET, authCheckNone]], |
108 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + | 111 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + |
109 '&mode=cors&credentials=same-origin&method=PUT', | 112 '&mode=cors&credentials=same-origin&method=PUT', |
110 [fetchRejected]], | 113 [fetchRejected]], |
111 [REDIRECT_URL + | 114 [REDIRECT_URL + |
112 encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*&ACAMethods=PUT') + | 115 encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*&ACAMethods=PUT') + |
113 '&mode=cors&credentials=same-origin&method=PUT', | 116 '&mode=cors&credentials=same-origin&method=PUT', |
114 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 117 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 118 responseRedirected, |
115 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*&ACAMethods=PUT'])], | 119 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*&ACAMethods=PUT'])], |
116 [methodIsPUT, noCustomHeader, authCheckNone]], | 120 [methodIsPUT, noCustomHeader, authCheckNone]], |
117 | 121 |
118 // Status code tests for mode="cors" | 122 // Status code tests for mode="cors" |
119 // The 301 redirect response MAY change the request method from POST to GET. | 123 // The 301 redirect response MAY change the request method from POST to GET. |
120 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + | 124 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + |
121 '&mode=cors&credentials=same-origin&method=POST&Status=301', | 125 '&mode=cors&credentials=same-origin&method=POST&Status=301', |
122 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 126 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 127 responseRedirected, |
123 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], | 128 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], |
124 [methodIsGET]], | 129 [methodIsGET]], |
125 // The 302 redirect response MAY change the request method from POST to GET. | 130 // The 302 redirect response MAY change the request method from POST to GET. |
126 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + | 131 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + |
127 '&mode=cors&credentials=same-origin&method=POST&Status=302', | 132 '&mode=cors&credentials=same-origin&method=POST&Status=302', |
128 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 133 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 134 responseRedirected, |
129 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], | 135 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], |
130 [methodIsGET]], | 136 [methodIsGET]], |
131 // GET method must be used for 303 redirect. | 137 // GET method must be used for 303 redirect. |
132 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + | 138 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + |
133 '&mode=cors&credentials=same-origin&method=POST&Status=303', | 139 '&mode=cors&credentials=same-origin&method=POST&Status=303', |
134 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 140 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 141 responseRedirected, |
135 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], | 142 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], |
136 [methodIsGET]], | 143 [methodIsGET]], |
137 // The 307 redirect response MUST NOT change the method. | 144 // The 307 redirect response MUST NOT change the method. |
138 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + | 145 [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + |
139 '&mode=cors&credentials=same-origin&method=POST&Status=307', | 146 '&mode=cors&credentials=same-origin&method=POST&Status=307', |
140 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 147 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 148 responseRedirected, |
141 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], | 149 checkURLList.bind(self, [OTHER_BASE_URL + '&ACAOrigin=*'])], |
142 [methodIsPOST]], | 150 [methodIsPOST]], |
143 // The 308 redirect response MUST NOT change the method. | 151 // The 308 redirect response MUST NOT change the method. |
144 // FIXME: disabled due to https://crbug.com/451938 | 152 // FIXME: disabled due to https://crbug.com/451938 |
145 // [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + | 153 // [REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + '&ACAOrigin=*') + |
146 // '&mode=cors&credentials=same-origin&method=POST&Status=308', | 154 // '&mode=cors&credentials=same-origin&method=POST&Status=308', |
147 // [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | 155 // [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], |
148 // [methodIsPOST]], | 156 // [methodIsPOST]], |
149 | 157 |
150 // Custom header | 158 // Custom header |
151 [REDIRECT_URL + | 159 [REDIRECT_URL + |
152 encodeURIComponent( | 160 encodeURIComponent( |
153 OTHER_BASE_URL + | 161 OTHER_BASE_URL + |
154 'ACAOrigin=*&ACAHeaders=x-serviceworker-test') + | 162 'ACAOrigin=*&ACAHeaders=x-serviceworker-test') + |
155 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM', | 163 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM', |
156 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 164 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 165 responseRedirected, |
157 checkURLList.bind( | 166 checkURLList.bind( |
158 self, | 167 self, |
159 [OTHER_BASE_URL + 'ACAOrigin=*&ACAHeaders=x-serviceworker-test'])], | 168 [OTHER_BASE_URL + 'ACAOrigin=*&ACAHeaders=x-serviceworker-test'])], |
160 [methodIsGET, hasCustomHeader, authCheckNone]], | 169 [methodIsGET, hasCustomHeader, authCheckNone]], |
161 [REDIRECT_URL + | 170 [REDIRECT_URL + |
162 encodeURIComponent(OTHER_BASE_URL +'ACAOrigin=*') + | 171 encodeURIComponent(OTHER_BASE_URL +'ACAOrigin=*') + |
163 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM', | 172 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM', |
164 [fetchRejected]], | 173 [fetchRejected]], |
165 [REDIRECT_URL + | 174 [REDIRECT_URL + |
166 encodeURIComponent(OTHER_BASE_URL + 'ACAHeaders=x-serviceworker-test') + | 175 encodeURIComponent(OTHER_BASE_URL + 'ACAHeaders=x-serviceworker-test') + |
167 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM', | 176 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM', |
168 [fetchRejected]], | 177 [fetchRejected]], |
169 | 178 |
170 // Server header | 179 // Server header |
171 [REDIRECT_URL + | 180 [REDIRECT_URL + |
172 encodeURIComponent( | 181 encodeURIComponent( |
173 OTHER_BASE_URL + | 182 OTHER_BASE_URL + |
174 '&ACAOrigin=' + BASE_ORIGIN + | 183 '&ACAOrigin=' + BASE_ORIGIN + |
175 '&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader') + | 184 '&ACEHeaders=Content-Length, X-ServiceWorker-ServerHeader') + |
176 '&mode=cors&credentials=same-origin&method=GET', | 185 '&mode=cors&credentials=same-origin&method=GET', |
177 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors, | 186 [fetchResolved, hasContentLength, hasServerHeader, hasBody, typeCors, |
| 187 responseRedirected, |
178 checkURLList.bind( | 188 checkURLList.bind( |
179 self, | 189 self, |
180 [OTHER_BASE_URL +'&ACAOrigin=' + BASE_ORIGIN + | 190 [OTHER_BASE_URL +'&ACAOrigin=' + BASE_ORIGIN + |
181 '&ACEHeaders=Content-Length,%20X-ServiceWorker-ServerHeader'])], | 191 '&ACEHeaders=Content-Length,%20X-ServiceWorker-ServerHeader'])], |
182 [methodIsGET, authCheckNone]], | 192 [methodIsGET, authCheckNone]], |
183 | 193 |
184 // Redirect: other origin -> same origin | 194 // Redirect: other origin -> same origin |
185 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL) + | 195 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL) + |
186 '&mode=same-origin&credentials=same-origin&method=GET', | 196 '&mode=same-origin&credentials=same-origin&method=GET', |
187 [fetchRejected]], | 197 [fetchRejected]], |
188 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL) + | 198 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL) + |
189 '&mode=same-origin&credentials=same-origin&method=POST', | 199 '&mode=same-origin&credentials=same-origin&method=POST', |
190 [fetchRejected]], | 200 [fetchRejected]], |
191 | 201 |
192 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL) + | 202 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL) + |
193 '&mode=cors&credentials=same-origin&method=GET', | 203 '&mode=cors&credentials=same-origin&method=GET', |
194 [fetchRejected]], | 204 [fetchRejected]], |
195 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL) + | 205 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL) + |
196 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 206 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
197 [fetchRejected]], | 207 [fetchRejected]], |
198 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + | 208 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + |
199 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 209 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
200 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 210 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 211 responseRedirected, |
201 checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], | 212 checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], |
202 [methodIsGET, authCheckNone]], | 213 [methodIsGET, authCheckNone]], |
203 | 214 |
204 // Status code tests for mode="cors" | 215 // Status code tests for mode="cors" |
205 // The 301 redirect response MAY change the request method from POST to GET. | 216 // The 301 redirect response MAY change the request method from POST to GET. |
206 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + | 217 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + |
207 '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=301', | 218 '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=301', |
208 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 219 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
209 checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], | 220 responseRedirected, checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], |
210 [methodIsGET]], | 221 [methodIsGET]], |
211 // The 302 redirect response MAY change the request method from POST to GET. | 222 // The 302 redirect response MAY change the request method from POST to GET. |
212 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + | 223 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + |
213 '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=302', | 224 '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=302', |
214 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 225 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
215 checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], | 226 responseRedirected, checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], |
216 [methodIsGET]], | 227 [methodIsGET]], |
217 // GET method must be used for 303 redirect. | 228 // GET method must be used for 303 redirect. |
218 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + | 229 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + |
219 '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=303', | 230 '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=303', |
220 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 231 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
221 checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], | 232 responseRedirected, checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], |
222 [methodIsGET]], | 233 [methodIsGET]], |
223 // The 307 redirect response MUST NOT change the method. | 234 // The 307 redirect response MUST NOT change the method. |
224 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + | 235 [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + |
225 '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=307', | 236 '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=307', |
226 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 237 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
227 checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], | 238 responseRedirected, checkURLList.bind(self, [BASE_URL + 'ACAOrigin=*'])], |
228 [methodIsPOST]], | 239 [methodIsPOST]], |
229 // The 308 redirect response MUST NOT change the method. | 240 // The 308 redirect response MUST NOT change the method. |
230 // FIXME: disabled due to https://crbug.com/451938 | 241 // FIXME: disabled due to https://crbug.com/451938 |
231 // [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + | 242 // [OTHER_REDIRECT_URL + encodeURIComponent(BASE_URL + 'ACAOrigin=*') + |
232 // '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=308', | 243 // '&mode=cors&credentials=same-origin&method=post&ACAOrigin=*&Status=308', |
233 // [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | 244 // [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], |
234 // [methodIsPOST]], | 245 // [methodIsPOST]], |
235 | 246 |
236 // Custom method | 247 // Custom method |
237 [OTHER_REDIRECT_URL + | 248 [OTHER_REDIRECT_URL + |
(...skipping 17 matching lines...) Expand all Loading... |
255 [fetchRejected]], | 266 [fetchRejected]], |
256 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + | 267 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + |
257 '&mode=cors&credentials=same-origin&method=GET', | 268 '&mode=cors&credentials=same-origin&method=GET', |
258 [fetchRejected]], | 269 [fetchRejected]], |
259 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + | 270 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL) + |
260 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 271 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
261 [fetchRejected]], | 272 [fetchRejected]], |
262 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + | 273 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + |
263 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 274 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
264 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 275 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 276 responseRedirected, |
265 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], | 277 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], |
266 [methodIsGET, authCheckNone]], | 278 [methodIsGET, authCheckNone]], |
267 [OTHER_REDIRECT_URL + | 279 [OTHER_REDIRECT_URL + |
268 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=' + BASE_ORIGIN + '') + | 280 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=' + BASE_ORIGIN + '') + |
269 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 281 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
270 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 282 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 283 responseRedirected, |
271 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=' + BASE_ORIGIN])], | 284 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=' + BASE_ORIGIN])], |
272 [methodIsGET, authCheckNone]], | 285 [methodIsGET, authCheckNone]], |
273 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + | 286 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + |
274 '&mode=cors&credentials=same-origin&method=GET' + | 287 '&mode=cors&credentials=same-origin&method=GET' + |
275 '&ACAOrigin=' + BASE_ORIGIN + '', | 288 '&ACAOrigin=' + BASE_ORIGIN + '', |
276 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 289 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 290 responseRedirected, |
277 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], | 291 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], |
278 [methodIsGET, authCheckNone]], | 292 [methodIsGET, authCheckNone]], |
279 [OTHER_REDIRECT_URL + | 293 [OTHER_REDIRECT_URL + |
280 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=' + BASE_ORIGIN + '') + | 294 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=' + BASE_ORIGIN + '') + |
281 '&mode=cors&credentials=same-origin&method=GET' + | 295 '&mode=cors&credentials=same-origin&method=GET' + |
282 '&ACAOrigin=' + BASE_ORIGIN + '', | 296 '&ACAOrigin=' + BASE_ORIGIN + '', |
283 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 297 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 298 responseRedirected, |
284 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=' + BASE_ORIGIN])], | 299 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=' + BASE_ORIGIN])], |
285 [methodIsGET, authCheckNone]], | 300 [methodIsGET, authCheckNone]], |
286 | 301 |
287 // Status code tests for mode="cors" | 302 // Status code tests for mode="cors" |
288 // The 301 redirect response MAY change the request method from POST to GET. | 303 // The 301 redirect response MAY change the request method from POST to GET. |
289 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + | 304 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + |
290 '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=301', | 305 '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=301', |
291 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 306 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 307 responseRedirected, |
292 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], | 308 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], |
293 [methodIsGET]], | 309 [methodIsGET]], |
294 // The 302 redirect response MAY change the request method from POST to GET. | 310 // The 302 redirect response MAY change the request method from POST to GET. |
295 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + | 311 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + |
296 '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=302', | 312 '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=302', |
297 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 313 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 314 responseRedirected, |
298 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], | 315 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], |
299 [methodIsGET]], | 316 [methodIsGET]], |
300 // GET method must be used for 303 redirect. | 317 // GET method must be used for 303 redirect. |
301 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + | 318 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + |
302 '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=303', | 319 '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=303', |
303 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 320 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 321 responseRedirected, |
304 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], | 322 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], |
305 [methodIsGET]], | 323 [methodIsGET]], |
306 // The 307 redirect response MUST NOT change the method. | 324 // The 307 redirect response MUST NOT change the method. |
307 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + | 325 [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + |
308 '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=307', | 326 '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=307', |
309 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, | 327 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors, |
| 328 responseRedirected, |
310 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], | 329 checkURLList.bind(self, [OTHER_BASE_URL + 'ACAOrigin=*'])], |
311 [methodIsPOST]], | 330 [methodIsPOST]], |
312 // The 308 redirect response MUST NOT change the method. | 331 // The 308 redirect response MUST NOT change the method. |
313 // FIXME: disabled due to https://crbug.com/451938 | 332 // FIXME: disabled due to https://crbug.com/451938 |
314 // [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + | 333 // [OTHER_REDIRECT_URL + encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*') + |
315 // '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=308', | 334 // '&mode=cors&credentials=same-origin&method=POST&ACAOrigin=*&Status=308', |
316 // [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | 335 // [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], |
317 // [methodIsPOST]], | 336 // [methodIsPOST]], |
318 | 337 |
319 // Server header | 338 // Server header |
320 [OTHER_REDIRECT_URL + | 339 [OTHER_REDIRECT_URL + |
321 encodeURIComponent(OTHER_BASE_URL + | 340 encodeURIComponent(OTHER_BASE_URL + |
322 'ACAOrigin=*&ACEHeaders=X-ServiceWorker-ServerHeader') + | 341 'ACAOrigin=*&ACEHeaders=X-ServiceWorker-ServerHeader') + |
323 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', | 342 '&mode=cors&credentials=same-origin&method=GET&ACAOrigin=*', |
324 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors, | 343 [fetchResolved, noContentLength, hasServerHeader, hasBody, typeCors, |
| 344 responseRedirected, |
325 checkURLList.bind( | 345 checkURLList.bind( |
326 self, | 346 self, |
327 [OTHER_BASE_URL + | 347 [OTHER_BASE_URL + |
328 'ACAOrigin=*&ACEHeaders=X-ServiceWorker-ServerHeader'])], | 348 'ACAOrigin=*&ACEHeaders=X-ServiceWorker-ServerHeader'])], |
329 [methodIsGET, authCheckNone]], | 349 [methodIsGET, authCheckNone]], |
330 | 350 |
331 // Custom method | 351 // Custom method |
332 [OTHER_REDIRECT_URL + | 352 [OTHER_REDIRECT_URL + |
333 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*&ACAMethods=PUT') + | 353 encodeURIComponent(OTHER_BASE_URL + 'ACAOrigin=*&ACAMethods=PUT') + |
334 '&mode=cors&credentials=same-origin&method=PUT&ACAOrigin=*&ACAMethods=PUT', | 354 '&mode=cors&credentials=same-origin&method=PUT&ACAOrigin=*&ACAMethods=PUT', |
335 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | 355 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], |
336 [methodIsPUT, authCheckNone]], | 356 [methodIsPUT, authCheckNone]], |
337 // Custom header | 357 // Custom header |
338 [OTHER_REDIRECT_URL + | 358 [OTHER_REDIRECT_URL + |
339 encodeURIComponent( | 359 encodeURIComponent( |
340 OTHER_BASE_URL + | 360 OTHER_BASE_URL + |
341 'ACAOrigin=' + BASE_ORIGIN + '&ACAHeaders=x-serviceworker-test') + | 361 'ACAOrigin=' + BASE_ORIGIN + '&ACAHeaders=x-serviceworker-test') + |
342 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM' + | 362 '&mode=cors&credentials=same-origin&method=GET&headers=CUSTOM' + |
343 '&ACAOrigin=' + BASE_ORIGIN + '&ACAHeaders=x-serviceworker-test', | 363 '&ACAOrigin=' + BASE_ORIGIN + '&ACAHeaders=x-serviceworker-test', |
344 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], | 364 [fetchResolved, noContentLength, noServerHeader, hasBody, typeCors], |
345 [methodIsGET, hasCustomHeader, authCheckNone]], | 365 [methodIsGET, hasCustomHeader, authCheckNone]], |
346 ]; | 366 ]; |
347 | 367 |
348 if (self.importScripts) { | 368 if (self.importScripts) { |
349 executeTests(TEST_TARGETS); | 369 executeTests(TEST_TARGETS); |
350 done(); | 370 done(); |
351 } | 371 } |
OLD | NEW |