| OLD | NEW |
| (Empty) |
| 1 if (self.importScripts) { | |
| 2 importScripts('../resources/fetch-test-helpers.js'); | |
| 3 importScripts('../resources/fetch-access-control-util.js'); | |
| 4 } | |
| 5 | |
| 6 // This test assumes TEST_TARGETS are executed in order and sequentially. | |
| 7 var TEST_TARGETS = []; | |
| 8 | |
| 9 // cookieCheckX checks the cookies sent in the request. | |
| 10 // SetCookie=cookieX indicates to set cookies in the response. | |
| 11 // So a SetCookie=cookieX indication may affect the next cookieCheckX, | |
| 12 // but not the cookieCheckX in the same request. | |
| 13 | |
| 14 // Test same-origin requests. | |
| 15 // The same set of requests are also in fetch-access-control-cookie.js, | |
| 16 // with different modes (same-origin and cors). | |
| 17 // forEach structure is left unchanged here to keep | |
| 18 // fetch-access-control-cookie.js and fetch-access-control-cookie-no-cors.js | |
| 19 // parallel with small diffs. | |
| 20 ['no-cors'].forEach(function(mode) { | |
| 21 // At first, cookie is cookie=cookie1. | |
| 22 TEST_TARGETS.push( | |
| 23 // Set cookie=cookieA by credentials=same-origin. | |
| 24 [BASE_URL + 'mode=' + mode + '&credentials=same-origin&SetCookie=cookieA', | |
| 25 [fetchResolved, hasBody], [cookieCheck1]], | |
| 26 | |
| 27 // Set cookie=cookieB by credentials=include. | |
| 28 [BASE_URL + 'mode=' + mode + '&credentials=include&SetCookie=cookieB', | |
| 29 [fetchResolved, hasBody], [cookieCheckA]], | |
| 30 // Check cookie. | |
| 31 [BASE_URL + 'mode=' + mode + '&credentials=same-origin', | |
| 32 [fetchResolved, hasBody], [cookieCheckB]], | |
| 33 | |
| 34 // Try to set cookie=cookieC by credentials=omit, but | |
| 35 // cookie is not sent/updated if credentials flag is unset. | |
| 36 [BASE_URL + 'mode=' + mode + '&credentials=omit&SetCookie=cookieC', | |
| 37 [fetchResolved, hasBody], [cookieCheckNone]], | |
| 38 | |
| 39 // Set-Cookie2 header is ignored. | |
| 40 [BASE_URL + 'mode=' + mode + | |
| 41 '&credentials=same-origin&SetCookie2=cookieC', | |
| 42 [fetchResolved, hasBody], [cookieCheckB]], | |
| 43 | |
| 44 // Reset cookie to cookie1. | |
| 45 [BASE_URL + 'mode=' + mode + '&credentials=same-origin&SetCookie=cookie1', | |
| 46 [fetchResolved, hasBody], [cookieCheckB]]); | |
| 47 }); | |
| 48 | |
| 49 // Test cross-origin requests. | |
| 50 | |
| 51 // URL to check current cookie. | |
| 52 var OTHER_CHECK_URL = | |
| 53 OTHER_BASE_URL + | |
| 54 'mode=cors&credentials=include&method=POST&ACAOrigin=' + BASE_ORIGIN + | |
| 55 '&ACACredentials=true&label='; | |
| 56 | |
| 57 TEST_TARGETS.push( | |
| 58 // At first, cookie is cookie=cookie2. | |
| 59 // Tests for mode=no-cors. | |
| 60 | |
| 61 // Try to set cookieC, but | |
| 62 // cookie is not sent/updated because credentials flag is not set. | |
| 63 [OTHER_BASE_URL + 'mode=no-cors&credentials=omit&SetCookie=cookieC', | |
| 64 [fetchResolved, noBody, typeOpaque], | |
| 65 onlyOnServiceWorkerProxiedTest([cookieCheckNone])], | |
| 66 [OTHER_CHECK_URL + 'otherCheck1', [fetchResolved], [cookieCheck2]], | |
| 67 | |
| 68 // Set cookieC with opaque response. Response is opaque, but cookie is set. | |
| 69 [OTHER_BASE_URL + 'mode=no-cors&credentials=include&SetCookie=cookieC', | |
| 70 [fetchResolved, noBody, typeOpaque], | |
| 71 onlyOnServiceWorkerProxiedTest([cookieCheck2])], | |
| 72 [OTHER_CHECK_URL + 'otherCheck2', [fetchResolved], [cookieCheckC]], | |
| 73 | |
| 74 // Set cookieA with opaque response. Response is opaque, but cookie is set. | |
| 75 [OTHER_BASE_URL + 'mode=no-cors&credentials=same-origin&SetCookie=cookieA', | |
| 76 [fetchResolved, noBody, typeOpaque], | |
| 77 onlyOnServiceWorkerProxiedTest([cookieCheckC])], | |
| 78 [OTHER_CHECK_URL + 'otherCheck3', [fetchResolved], [cookieCheckA]] | |
| 79 ); | |
| 80 | |
| 81 if (self.importScripts) { | |
| 82 executeTests(TEST_TARGETS); | |
| 83 done(); | |
| 84 } | |
| OLD | NEW |