From 8acce123e6ed1080821e892c4337ca88439656f8 Mon Sep 17 00:00:00 2001 From: Blink WPT Bot Date: Thu, 24 Sep 2020 19:13:33 +0000 Subject: [PATCH] Bug 1666996 [wpt PR 25748] - Refine crossOriginIsolated implementation for workers, a=testonly Automatic update from web-platform-tests Refine crossOriginIsolated implementation for workers (#25748) - Fix WindowOrWorketGlobalScope.crossOriginIsolated behavior for workers. - For SharedWorkers and ServiceWorkers it always return false. See https://crbug.com/1131403 and https://crbug.com/1131404. - Rename ExecutionContext::IsCrossOriginIsolated to CrossOriginCapability. This is aligned with https://html.spec.whatwg.org/C/#concept-settings-object-cross-origin-isolated-capability. - Fix wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/blob-data.https.html. I originally planned to do that in https://github.com/web-platform-tests/wpt/pull/24600 but I couldn't do that due to some flakiness. - Add more tests for workers in wpt/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https.html. Bug: 1115379, 1018680, 1131403, 1131404 Change-Id: I2afcb01403f67a11fd06aefde1238aba16b68f36 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416428 Commit-Queue: Yutaka Hirano Reviewed-by: Domenic Denicola Reviewed-by: Robert Flack Reviewed-by: Hiroki Nakagawa Cr-Commit-Position: refs/heads/master@{#810130} Co-authored-by: Yutaka Hirano -- wpt-commits: ce281cc3f32d8e93ecbb33a51321d846ee2aae37 wpt-pr: 25748 --- ...ross-origin-isolated-permission.https.html | 156 +++++++++++++++--- .../resources/cross-origin-isolated-worker.js | 11 ++ .../shared-array-buffers/blob-data.https.html | 12 +- 3 files changed, 154 insertions(+), 25 deletions(-) create mode 100644 testing/web-platform/tests/html/cross-origin-embedder-policy/resources/cross-origin-isolated-worker.js diff --git a/testing/web-platform/tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https.html b/testing/web-platform/tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https.html index aec1b858542b..2fc545d5acb6 100644 --- a/testing/web-platform/tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https.html +++ b/testing/web-platform/tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https.html @@ -3,24 +3,28 @@ + + diff --git a/testing/web-platform/tests/html/cross-origin-embedder-policy/resources/cross-origin-isolated-worker.js b/testing/web-platform/tests/html/cross-origin-embedder-policy/resources/cross-origin-isolated-worker.js new file mode 100644 index 000000000000..9f1e3710af6e --- /dev/null +++ b/testing/web-platform/tests/html/cross-origin-embedder-policy/resources/cross-origin-isolated-worker.js @@ -0,0 +1,11 @@ +// For DedicatedWorker and ServiceWorker +self.addEventListener('message', (e) => { + e.data.port.postMessage(self.crossOriginIsolated); +}); + +// For SharedWorker +self.addEventListener('connect', (e) => { + e.ports[0].onmessage = (ev) => { + ev.data.port.postMessage(self.crossOriginIsolated); + }; +}); \ No newline at end of file diff --git a/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/blob-data.https.html b/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/blob-data.https.html index dbc73e98f578..bfcc8b61ca23 100644 --- a/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/blob-data.https.html +++ b/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/blob-data.https.html @@ -50,14 +50,14 @@ `; } -function propertyTests(name) { +function propertyTests(name, crossOriginIsolated) { return ` test(() => { assert_equals(self.origin, self.location.origin); }, "${name}: self.origin"); test(() => { - assert_true(self.crossOriginIsolated); + assert_equals(self.crossOriginIsolated, ${crossOriginIsolated}); }, "${name}: self.crossOriginIsolated"); test(() => { @@ -74,7 +74,7 @@ ${blobWorkerIncrementerTest("blob worker", self.location.origin)} -${propertyTests("blob worker")} +${propertyTests("blob worker", true)} done(); `; @@ -90,7 +90,7 @@ ${blobWorkerIncrementerTest("blob frame", self.location.origin)} -${propertyTests("blob frame")} +${propertyTests("blob frame", true)} <\/script> `; @@ -106,7 +106,7 @@ ${blobWorkerIncrementerTest("data worker")} -${propertyTests("data worker")} +${propertyTests("data worker", false)} done(); `; @@ -121,7 +121,7 @@ ${blobWorkerIncrementerTest("data frame")} -${propertyTests("data frame")} +${propertyTests("data frame", true)} <\/script> `;