| Index: LayoutTests/http/tests/fetch/script-tests/fetch-access-control-cookie-nocors.js | 
| diff --git a/LayoutTests/http/tests/fetch/script-tests/fetch-access-control-cookie-nocors.js b/LayoutTests/http/tests/fetch/script-tests/fetch-access-control-cookie-nocors.js | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..c8e6c860ca63d5d96d6dd30354c527fcd6c1b3f3 | 
| --- /dev/null | 
| +++ b/LayoutTests/http/tests/fetch/script-tests/fetch-access-control-cookie-nocors.js | 
| @@ -0,0 +1,84 @@ | 
| +if (self.importScripts) { | 
| +  importScripts('../resources/fetch-test-helpers.js'); | 
| +  importScripts('/serviceworker/resources/fetch-access-control-util.js'); | 
| +} | 
| + | 
| +// This test assumes TEST_TARGETS are executed in order and sequentially. | 
| +var TEST_TARGETS = []; | 
| + | 
| +// cookieCheckX checks the cookies sent in the request. | 
| +// SetCookie=cookieX indicates to set cookies in the response. | 
| +// So a SetCookie=cookieX indication may affect the next cookieCheckX, | 
| +// but not the cookieCheckX in the same request. | 
| + | 
| +// Test same-origin requests. | 
| +// The same set of requests are also in fetch-access-control-cookie.js, | 
| +// with different modes (same-origin and cors). | 
| +// forEach structure is left unchanged here to keep | 
| +// fetch-access-control-cookie.js and fetch-access-control-cookie-no-cors.js | 
| +// parallel with small diffs. | 
| +['no-cors'].forEach(function(mode) { | 
| +    // At first, cookie is cookie=cookie1. | 
| +    TEST_TARGETS.push( | 
| +      // Set cookie=cookieA by credentials=same-origin. | 
| +      [BASE_URL + 'mode=' + mode + '&credentials=same-origin&SetCookie=cookieA', | 
| +       [fetchResolved, hasBody], [cookieCheck1]], | 
| + | 
| +      // Set cookie=cookieB by credentials=include. | 
| +      [BASE_URL + 'mode=' + mode + '&credentials=include&SetCookie=cookieB', | 
| +       [fetchResolved, hasBody], [cookieCheckA]], | 
| +      // Check cookie. | 
| +      [BASE_URL + 'mode=' + mode + '&credentials=same-origin', | 
| +       [fetchResolved, hasBody], [cookieCheckB]], | 
| + | 
| +      // Try to set cookie=cookieC by credentials=omit, but | 
| +      // cookie is not sent/updated if credentials flag is unset. | 
| +      [BASE_URL + 'mode=' + mode + '&credentials=omit&SetCookie=cookieC', | 
| +       [fetchResolved, hasBody], [cookieCheckNone]], | 
| + | 
| +      // Set-Cookie2 header is ignored. | 
| +      [BASE_URL + 'mode=' + mode + | 
| +       '&credentials=same-origin&SetCookie2=cookieC', | 
| +       [fetchResolved, hasBody], [cookieCheckB]], | 
| + | 
| +      // Reset cookie to cookie1. | 
| +      [BASE_URL + 'mode=' + mode + '&credentials=same-origin&SetCookie=cookie1', | 
| +       [fetchResolved, hasBody], [cookieCheckB]]); | 
| +  }); | 
| + | 
| +// Test cross-origin requests. | 
| + | 
| +// URL to check current cookie. | 
| +var OTHER_CHECK_URL = | 
| +  OTHER_BASE_URL + | 
| +  'mode=cors&credentials=include&method=POST&ACAOrigin=' + BASE_ORIGIN + | 
| +  '&ACACredentials=true&label='; | 
| + | 
| +TEST_TARGETS.push( | 
| +  // At first, cookie is cookie=cookie2. | 
| +  // Tests for mode=no-cors. | 
| + | 
| +  // Try to set cookieC, but | 
| +  // cookie is not sent/updated because credentials flag is not set. | 
| +  [OTHER_BASE_URL + 'mode=no-cors&credentials=omit&SetCookie=cookieC', | 
| +   [fetchResolved, noBody, typeOpaque], | 
| +   onlyOnServiceWorkerProxiedTest([cookieCheckNone])], | 
| +  [OTHER_CHECK_URL + 'otherCheck1', [fetchResolved], [cookieCheck2]], | 
| + | 
| +  // Set cookieC with opaque response. Response is opaque, but cookie is set. | 
| +  [OTHER_BASE_URL + 'mode=no-cors&credentials=include&SetCookie=cookieC', | 
| +   [fetchResolved, noBody, typeOpaque], | 
| +   onlyOnServiceWorkerProxiedTest([cookieCheck2])], | 
| +  [OTHER_CHECK_URL + 'otherCheck2', [fetchResolved], [cookieCheckC]], | 
| + | 
| +  // Set cookieA with opaque response. Response is opaque, but cookie is set. | 
| +  [OTHER_BASE_URL + 'mode=no-cors&credentials=same-origin&SetCookie=cookieA', | 
| +   [fetchResolved, noBody, typeOpaque], | 
| +   onlyOnServiceWorkerProxiedTest([cookieCheckC])], | 
| +  [OTHER_CHECK_URL + 'otherCheck3', [fetchResolved], [cookieCheckA]] | 
| +); | 
| + | 
| +if (self.importScripts) { | 
| +  executeTests(TEST_TARGETS); | 
| +  done(); | 
| +} | 
|  |