Bug 1465794 [wpt PR 11274] - Worker: Change the default credentials option from 'omit' to 'same-origin', a=testonly
authorHiroki Nakagawa <nhiroki@chromium.org>
Wed, 06 Jun 2018 17:35:41 +0000
changeset 422265 8501df66d1b82cd635660d7868271fc02bd2f0fb
parent 422264 fb519193b813bc8ebf9283d3ef1be821b0da74f5
child 422266 ef4541dc85a91e5b7a09c9621e9453584937d17f
push id34122
push userebalazs@mozilla.com
push dateMon, 11 Jun 2018 09:37:00 +0000
treeherdermozilla-central@9941eb8c3b29 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1465794, 11274, 848247, 1080668, 563465
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1465794 [wpt PR 11274] - Worker: Change the default credentials option from 'omit' to 'same-origin', a=testonly Automatic update from web-platform-testsWorker: Change the default credentials option from 'omit' to 'same-origin' This is a follow-up for the spec change: https://github.com/whatwg/html/pull/3656 Note that ES Modules for dedicated workers is still behind the flag and this change doesn't affect applications in the real world. Bug: 848247 Change-Id: I25083f3f11f9d13663e16e2f4c137095e9b12b01 Reviewed-on: https://chromium-review.googlesource.com/1080668 Reviewed-by: Matt Falkenhagen <falken@chromium.org> Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org> Cr-Commit-Position: refs/heads/master@{#563465} -- wpt-commits: 72c7cfed684554c0d65b7a33d413df9ae1c5999f wpt-pr: 11274
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/workers/modules/dedicated-worker-options-credentials.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -624659,17 +624659,17 @@
    "32cd3419ff904a2440d9a6eaa7cb28f78d4a7e32",
    "testharness"
   ],
   "workers/modules/dedicated-worker-import.html": [
    "0b839e87ae98ad1abf32216a2086334cbc011ac0",
    "testharness"
   ],
   "workers/modules/dedicated-worker-options-credentials.html": [
-   "1d6a1629f81d26efcd05bf1c7d40011609238f4f",
+   "f182ac364e933ce744b18c0ca6e03ae975a883a3",
    "testharness"
   ],
   "workers/modules/dedicated-worker-options-credentials.html.headers": [
    "0de4f6326452e016161eabf248e047253507b79d",
    "support"
   ],
   "workers/modules/dedicated-worker-options-type.html": [
    "9f6f1be759beb885e2baa746e36ace83685f649b",
--- a/testing/web-platform/tests/workers/modules/dedicated-worker-options-credentials.html
+++ b/testing/web-platform/tests/workers/modules/dedicated-worker-options-credentials.html
@@ -12,67 +12,74 @@
 function DetermineExpectedCookieValue(options) {
   // Classic script loading should always send credentials regardless of the
   // 'credentials' option because the spec says the option takes effect only
   // for module script loading.
   if (options.type == 'classic')
     return 'COOKIE_VALUE';
   assert_equals(options.type, 'module');
 
-  if (!options.credentials || options.credentials == 'omit')
+  if (!options.credentials ||
+      options.credentials == 'same-origin' ||
+      options.credentials == 'include') {
+    return 'COOKIE_VALUE';
+  }
+  if (options.credentials == 'omit')
     return '';
-  if (options.credentials == 'same-origin' || options.credentials == 'include')
-    return 'COOKIE_VALUE';
   assert_unreached('Invalid credentials option was specified: ' +
                    options.credentials);
 }
 
 // Runs a credentials test with the given WorkerOptions.
-async function runCredentialsTest(options) {
-  const worker = new Worker('resources/credentials.py', options);
+function credentials_test(options, description) {
+  promise_test(async () => {
+    const worker = new Worker('resources/credentials.py', options);
 
-  // Wait until the worker sends the actual cookie value.
-  const msg_event = await new Promise(resolve => worker.onmessage = resolve);
+    // Wait until the worker sends the actual cookie value.
+    const msg_event = await new Promise(resolve => worker.onmessage = resolve);
 
-  const expectedCookieValue = DetermineExpectedCookieValue(options);
-  assert_equals(msg_event.data, expectedCookieValue);
+    const expectedCookieValue = DetermineExpectedCookieValue(options);
+    assert_equals(msg_event.data, expectedCookieValue);
+  }, description);
 }
 
 // Tests for module scripts.
 
-promise_test(() => runCredentialsTest({ type: 'module'}),
-    'new Worker() with the default credentials option should not send ' +
-    'the credentials');
+credentials_test(
+    { type: 'module'},
+    'new Worker() with the default credentials option should behave as ' +
+    'credentials=same-origin and send the credentials');
 
-promise_test(() => runCredentialsTest({ credentials: 'omit',
-                                        type: 'module' }),
+credentials_test(
+    { credentials: 'omit', type: 'module' },
     'new Worker() with credentials=omit should not send the credentials');
 
-promise_test(() => runCredentialsTest({ credentials: 'same-origin',
-                                        type: 'module' }),
+credentials_test(
+    { credentials: 'same-origin', type: 'module' },
     'new Worker() with credentials=same-origin should send the credentials');
 
-promise_test(() => runCredentialsTest({ credentials: 'include',
-                                        type: 'module' }),
+credentials_test(
+    { credentials: 'include', type: 'module' },
     'new Worker() with credentials=include should send the credentials');
 
 // Tests for classic scripts.
 
-promise_test(() => runCredentialsTest({ type: 'classic' }),
+credentials_test(
+    { type: 'classic' },
     'new Worker() with type=classic should always send the credentials ' +
     'regardless of the credentials option (default).');
 
-promise_test(() => runCredentialsTest({ credentials: 'omit',
-                                        type: 'classic' }),
+credentials_test(
+    { credentials: 'omit', type: 'classic' },
     'new Worker() with type=classic should always send the credentials ' +
     'regardless of the credentials option (omit).');
 
-promise_test(() => runCredentialsTest({ credentials: 'same-origin',
-                                        type: 'classic' }),
+credentials_test(
+    { credentials: 'same-origin', type: 'classic' },
     'new Worker() with type=classic should always send the credentials ' +
     'regardless of the credentials option (same-origin).');
 
-promise_test(() => runCredentialsTest({ credentials: 'include',
-                                        type: 'classic' }),
+credentials_test(
+    { credentials: 'include', type: 'classic' },
     'new Worker() with type=classic should always send the credentials ' +
     'regardless of the credentials option (include).');
 
 </script>