OLD | NEW |
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 // This test assumes TEST_TARGETS are executed in order and sequentially. | 6 // This test assumes TEST_TARGETS are executed in order and sequentially. |
7 var TEST_TARGETS = []; | 7 var TEST_TARGETS = []; |
8 | 8 |
9 // cookieCheckX checks the cookies sent in the request. | 9 // cookieCheckX checks the cookies sent in the request. |
10 // SetCookie=cookieX indicates to set cookies in the response. | 10 // SetCookie=cookieX indicates to set cookies in the response. |
11 // So a SetCookie=cookieX indication may affect the next cookieCheckX, | 11 // So a SetCookie=cookieX indication may affect the next cookieCheckX, |
12 // but not the cookieCheckX in the same request. | 12 // but not the cookieCheckX in the same request. |
13 | 13 |
14 // Test same-origin requests. | 14 // Test same-origin requests. |
15 ['same-origin', 'cors', 'no-cors'].forEach(function(mode) { | 15 // The same set of requests are also in fetch-access-control-cookie-no-cors.js, |
| 16 // with different mode (no-cors). |
| 17 ['same-origin', 'cors'].forEach(function(mode) { |
16 // At first, cookie is cookie=cookie1. | 18 // At first, cookie is cookie=cookie1. |
17 TEST_TARGETS.push( | 19 TEST_TARGETS.push( |
18 // Set cookie=cookieA by credentials=same-origin. | 20 // Set cookie=cookieA by credentials=same-origin. |
19 [BASE_URL + 'mode=' + mode + '&credentials=same-origin&SetCookie=cookieA', | 21 [BASE_URL + 'mode=' + mode + '&credentials=same-origin&SetCookie=cookieA', |
20 [fetchResolved, hasBody], [cookieCheck1]], | 22 [fetchResolved, hasBody], [cookieCheck1]], |
21 | 23 |
22 // Set cookie=cookieB by credentials=include. | 24 // Set cookie=cookieB by credentials=include. |
23 [BASE_URL + 'mode=' + mode + '&credentials=include&SetCookie=cookieB', | 25 [BASE_URL + 'mode=' + mode + '&credentials=include&SetCookie=cookieB', |
24 [fetchResolved, hasBody], [cookieCheckA]], | 26 [fetchResolved, hasBody], [cookieCheckA]], |
25 // Check cookie. | 27 // Check cookie. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 [fetchResolved, hasBody, typeCors], [cookieCheckB]], | 122 [fetchResolved, hasBody, typeCors], [cookieCheckB]], |
121 [OTHER_CHECK_URL + 'otherCheck9', [fetchResolved], [cookieCheckB]], | 123 [OTHER_CHECK_URL + 'otherCheck9', [fetchResolved], [cookieCheckB]], |
122 | 124 |
123 // Set-Cookie2=cookieC is sent in CORS preflight, but this should be ignored. | 125 // Set-Cookie2=cookieC is sent in CORS preflight, but this should be ignored. |
124 [OTHER_BASE_URL + 'mode=cors&credentials=include&ACAOrigin=' + BASE_ORIGIN + | 126 [OTHER_BASE_URL + 'mode=cors&credentials=include&ACAOrigin=' + BASE_ORIGIN + |
125 '&PACAOrigin=' + BASE_ORIGIN + | 127 '&PACAOrigin=' + BASE_ORIGIN + |
126 '&ACACredentials=true&PACACredentials=true&method=PUT&PACAMethods=PUT&PSetCoo
kie2=cookieC&PreflightTest=200', | 128 '&ACACredentials=true&PACACredentials=true&method=PUT&PACAMethods=PUT&PSetCoo
kie2=cookieC&PreflightTest=200', |
127 [fetchResolved, hasBody, typeCors], [cookieCheckB]], | 129 [fetchResolved, hasBody, typeCors], [cookieCheckB]], |
128 [OTHER_CHECK_URL + 'otherCheck10', [fetchResolved], [cookieCheckB]], | 130 [OTHER_CHECK_URL + 'otherCheck10', [fetchResolved], [cookieCheckB]], |
129 | 131 |
130 // Tests for mode=no-cors. | |
131 | |
132 // Try to set cookieC, but | |
133 // cookie is not sent/updated because credentials flag is not set. | |
134 [OTHER_BASE_URL + 'mode=no-cors&credentials=omit&SetCookie=cookieC', | |
135 [fetchResolved, noBody, typeOpaque], | |
136 onlyOnServiceWorkerProxiedTest([cookieCheckNone])], | |
137 [OTHER_CHECK_URL + 'otherCheck11', [fetchResolved], [cookieCheckB]], | |
138 | |
139 // Set cookieC with opaque response. Response is opaque, but cookie is set. | |
140 [OTHER_BASE_URL + 'mode=no-cors&credentials=include&SetCookie=cookieC', | |
141 [fetchResolved, noBody, typeOpaque], | |
142 onlyOnServiceWorkerProxiedTest([cookieCheckB])], | |
143 [OTHER_CHECK_URL + 'otherCheck12', [fetchResolved], [cookieCheckC]], | |
144 | |
145 // Set cookieA with opaque response. Response is opaque, but cookie is set. | |
146 [OTHER_BASE_URL + 'mode=no-cors&credentials=same-origin&SetCookie=cookieA', | |
147 [fetchResolved, noBody, typeOpaque], | |
148 onlyOnServiceWorkerProxiedTest([cookieCheckC])], | |
149 [OTHER_CHECK_URL + 'otherCheck13', [fetchResolved], [cookieCheckA]], | |
150 | |
151 // Tests for mode=same-origin. | 132 // Tests for mode=same-origin. |
152 // Rejected as Network Error before entering basic fetch or HTTP fetch, | 133 // Rejected as Network Error before entering basic fetch or HTTP fetch, |
153 // so no cookies are set. | 134 // so no cookies are set. |
154 | 135 |
155 // Try to set cookieB. | 136 // Try to set cookieC. |
156 [OTHER_BASE_URL + 'mode=same-origin&credentials=omit&SetCookie=cookieB', | 137 [OTHER_BASE_URL + 'mode=same-origin&credentials=omit&SetCookie=cookieC', |
157 [fetchRejected]], | 138 [fetchRejected]], |
158 [OTHER_CHECK_URL + 'otherCheck14', [fetchResolved], [cookieCheckA]], | 139 [OTHER_CHECK_URL + 'otherCheck11', [fetchResolved], [cookieCheckB]], |
159 | 140 |
160 // Try to set cookieB. | 141 // Try to set cookieC. |
161 [OTHER_BASE_URL + 'mode=same-origin&credentials=include&SetCookie=cookieB', | 142 [OTHER_BASE_URL + 'mode=same-origin&credentials=include&SetCookie=cookieC', |
162 [fetchRejected]], | 143 [fetchRejected]], |
163 [OTHER_CHECK_URL + 'otherCheck15', [fetchResolved], [cookieCheckA]], | 144 [OTHER_CHECK_URL + 'otherCheck12', [fetchResolved], [cookieCheckB]], |
164 | 145 |
165 // Try to set cookieB. | 146 // Try to set cookieC. |
166 [OTHER_BASE_URL + | 147 [OTHER_BASE_URL + |
167 'mode=same-origin&credentials=same-origin&SetCookie=cookieB', | 148 'mode=same-origin&credentials=same-origin&SetCookie=cookieC', |
168 [fetchRejected]], | 149 [fetchRejected]], |
169 [OTHER_CHECK_URL + 'otherCheck16', [fetchResolved], [cookieCheckA]] | 150 [OTHER_CHECK_URL + 'otherCheck13', [fetchResolved], [cookieCheckB]] |
170 ); | 151 ); |
171 | 152 |
172 if (self.importScripts) { | 153 if (self.importScripts) { |
173 executeTests(TEST_TARGETS); | 154 executeTests(TEST_TARGETS); |
174 done(); | 155 done(); |
175 } | 156 } |
OLD | NEW |