Title: [282105] trunk
Revision
282105
Author
[email protected]
Date
2021-09-07 12:38:07 -0700 (Tue, 07 Sep 2021)

Log Message

Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel
https://bugs.webkit.org/show_bug.cgi?id=229814

Reviewed by Alex Christensen.

Source/WebCore:

Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel to address privacy
concerns, as discussed here:
- https://github.com/whatwg/html/issues/5803

Test: http/tests/messaging/broadcastchannel-partitioning.html

* dom/BroadcastChannel.cpp:
(WebCore::BroadcastChannel::BroadcastChannel):
(WebCore::m_identifier):
(WebCore::BroadcastChannel::dispatchMessage):
* dom/BroadcastChannel.h:
* dom/BroadcastChannelRegistry.h:
* loader/EmptyClients.cpp:

Source/WebKit:

Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel to address privacy
concerns, as discussed here:
- https://github.com/whatwg/html/issues/5803

* NetworkProcess/NetworkBroadcastChannelRegistry.cpp:
(WebKit::NetworkBroadcastChannelRegistry::registerChannel):
(WebKit::NetworkBroadcastChannelRegistry::unregisterChannel):
(WebKit::NetworkBroadcastChannelRegistry::postMessage):
(WebKit::NetworkBroadcastChannelRegistry::removeConnection):
* NetworkProcess/NetworkBroadcastChannelRegistry.h:
* NetworkProcess/NetworkBroadcastChannelRegistry.messages.in:
* WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp:
(WebKit::WebBroadcastChannelRegistry::registerChannel):
(WebKit::WebBroadcastChannelRegistry::unregisterChannel):
(WebKit::WebBroadcastChannelRegistry::postMessage):
* WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h:

Source/WebKitLegacy:

Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel to address privacy
concerns, as discussed here:
- https://github.com/whatwg/html/issues/5803

* WebCoreSupport/WebBroadcastChannelRegistry.cpp:
(WebBroadcastChannelRegistry::registerChannel):
(WebBroadcastChannelRegistry::unregisterChannel):
(WebBroadcastChannelRegistry::postMessage):
* WebCoreSupport/WebBroadcastChannelRegistry.h:

Source/WTF:

Add experimental preference for BroadcastChannel origin partitioning. This is useful because we currently
disable this when running web-platform-tests in WKTR / DRT for now.

* Scripts/Preferences/WebPreferencesExperimental.yaml:

Tools:

Disable BroadcastChannel origin partitioning when running layout tests since it would cause
too many test failures in WPT tests at this point (e.g. COOP/COEP tests).

* TestRunnerShared/TestFeatures.cpp:
(WTR::shouldDisableBroadcastChannelOriginPartitioning):
(WTR::hardcodedFeaturesBasedOnPathForTest):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):
* WebKitTestRunner/TestOptions.cpp:
(WTR::TestOptions::defaults):

LayoutTests:

Add layout test coverage.

* http/tests/messaging/broadcastchannel-partitioning-expected.txt: Added.
* http/tests/messaging/broadcastchannel-partitioning.html: Added.
* http/tests/messaging/resources/broadcastchannel-partitioning-iframe.html: Added.
* http/tests/messaging/resources/broadcastchannel-partitioning-popup.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (282104 => 282105)


--- trunk/LayoutTests/ChangeLog	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/LayoutTests/ChangeLog	2021-09-07 19:38:07 UTC (rev 282105)
@@ -1,3 +1,17 @@
+2021-09-07  Chris Dumez  <[email protected]>
+
+        Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel
+        https://bugs.webkit.org/show_bug.cgi?id=229814
+
+        Reviewed by Alex Christensen.
+
+        Add layout test coverage.
+
+        * http/tests/messaging/broadcastchannel-partitioning-expected.txt: Added.
+        * http/tests/messaging/broadcastchannel-partitioning.html: Added.
+        * http/tests/messaging/resources/broadcastchannel-partitioning-iframe.html: Added.
+        * http/tests/messaging/resources/broadcastchannel-partitioning-popup.html: Added.
+
 2021-09-07  Ayumi Kojima  <[email protected]>
 
         [iOS, BigSur+] webrtc/datachannel/getStats-no-prflx-remote-candidate.html is a flaky timeout.

Added: trunk/LayoutTests/http/tests/messaging/broadcastchannel-partitioning-expected.txt (0 => 282105)


--- trunk/LayoutTests/http/tests/messaging/broadcastchannel-partitioning-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/messaging/broadcastchannel-partitioning-expected.txt	2021-09-07 19:38:07 UTC (rev 282105)
@@ -0,0 +1,13 @@
+Tests that BroadcastChannel is partioning based on top origin / frame origin.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Received message from same-origin popup
+PASS gotMessageFromSameOriginPopup is false
+PASS Received message from same-origin iframe under same-origin popup
+PASS gotMessageFromSameOriginIframeUnderSameOriginPopup is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/messaging/broadcastchannel-partitioning.html (0 => 282105)


--- trunk/LayoutTests/http/tests/messaging/broadcastchannel-partitioning.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/messaging/broadcastchannel-partitioning.html	2021-09-07 19:38:07 UTC (rev 282105)
@@ -0,0 +1,39 @@
+<!DOCTYPE html><!-- webkit-test-runner [ BroadcastChannelOriginPartitioningEnabled=true ] -->
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that BroadcastChannel is partioning based on top origin / frame origin.");
+jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setCanOpenWindows();
+
+let bc = new BroadcastChannel("broadcastchannel-partitioning");
+
+let gotMessageFromSameOriginPopup = false;
+let gotMessageFromSameOriginIframeUnderSameOriginPopup = false;
+bc._onmessage_ = (message) => {
+    if (message.data == "same-origin-popup") {
+        testPassed("Received message from same-origin popup");
+        shouldBeFalse("gotMessageFromSameOriginPopup");
+        gotMessageFromSameOriginPopup = true;
+    } else if (message.data == "same-origin-iframe-under-same-origin-popup") {
+        testPassed("Received message from same-origin iframe under same-origin popup");
+        shouldBeFalse("gotMessageFromSameOriginIframeUnderSameOriginPopup");
+        gotMessageFromSameOriginIframeUnderSameOriginPopup = true;
+    } else {
+        testFailed("Received unexpected message: " + message.data);
+    }
+
+    if (gotMessageFromSameOriginPopup && gotMessageFromSameOriginIframeUnderSameOriginPopup)
+        setTimeout(finishJSTest, 1000);
+};
+
+_onload_ = () => {
+    open("http://localhost:8000/messaging/resources/broadcastchannel-partitioning-popup.html");
+    open("resources/broadcastchannel-partitioning-popup.html", "same-origin-popup", "noopener");
+};
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/messaging/resources/broadcastchannel-partitioning-iframe.html (0 => 282105)


--- trunk/LayoutTests/http/tests/messaging/resources/broadcastchannel-partitioning-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/messaging/resources/broadcastchannel-partitioning-iframe.html	2021-09-07 19:38:07 UTC (rev 282105)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+function isSameOriginAsTop()
+{
+    try {
+        return self.origin == top.origin;
+    } catch (e) {
+        return false;
+    }
+}
+
+let bc = new BroadcastChannel("broadcastchannel-partitioning");
+
+if (location.origin == "http://127.0.0.1:8000") {
+    if (isSameOriginAsTop())
+        bc.postMessage("same-origin-iframe-under-same-origin-popup");
+    else
+        bc.postMessage("same-origin-iframe-under-cross-origin-popup");
+} else {
+    if (isSameOriginAsTop())
+        bc.postMessage("cross-origin-iframe-under-cross-origin-popup");
+    else
+        bc.postMessage("cross-origin-iframe-under-same-origin-popup");
+}
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/messaging/resources/broadcastchannel-partitioning-popup.html (0 => 282105)


--- trunk/LayoutTests/http/tests/messaging/resources/broadcastchannel-partitioning-popup.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/messaging/resources/broadcastchannel-partitioning-popup.html	2021-09-07 19:38:07 UTC (rev 282105)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+let bc = new BroadcastChannel("broadcastchannel-partitioning");
+if (location.origin == "http://127.0.0.1:8000")
+    bc.postMessage("same-origin-popup");
+else
+    bc.postMessage("cross-origin-popup");
+</script>
+<iframe src=""
+<iframe src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/win/TestExpectations (282104 => 282105)


--- trunk/LayoutTests/platform/win/TestExpectations	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/LayoutTests/platform/win/TestExpectations	2021-09-07 19:38:07 UTC (rev 282105)
@@ -4636,8 +4636,9 @@
 fast/forms/password-doubleclick-selection.html [ Pass Failure ]
 fast/text/offsetForPosition-complex-fallback.html [ Pass Failure ]
 
-# testRunner.setShouldSwapToEphemeralSessionOnNextNavigation() does not work with window.open() in DRT.
+# No BroadcastChannel support on Windows.
 fast/html/broadcast-channel-between-different-sessions.html [ Skip ]
+http/tests/messaging/broadcastchannel-partitioning.html [ Skip ]
 
 # This test is skipped because the necessary feature flag functionality specific to the Windows WebKit legacy port is
 # not implemented.  The feature flags in question are CSSCounterStyleAtRulesEnabled and CSSCounterStyleAtRuleImageSymbolsEnabled.
@@ -4688,4 +4689,4 @@
 
 webkit.org/b/215318 fast/text/zwj-ligature.html [ ImageOnlyFailure ]
 
-webkit.org/b/229594 js/dfg-int16array.html [ Pass Crash ]
\ No newline at end of file
+webkit.org/b/229594 js/dfg-int16array.html [ Pass Crash ]

Modified: trunk/Source/WTF/ChangeLog (282104 => 282105)


--- trunk/Source/WTF/ChangeLog	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WTF/ChangeLog	2021-09-07 19:38:07 UTC (rev 282105)
@@ -1,3 +1,15 @@
+2021-09-07  Chris Dumez  <[email protected]>
+
+        Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel
+        https://bugs.webkit.org/show_bug.cgi?id=229814
+
+        Reviewed by Alex Christensen.
+
+        Add experimental preference for BroadcastChannel origin partitioning. This is useful because we currently
+        disable this when running web-platform-tests in WKTR / DRT for now.
+
+        * Scripts/Preferences/WebPreferencesExperimental.yaml:
+
 2021-09-06  Dmitry Kalinkin  <[email protected]>
 
         Fix WebKitGTK build on MacOS

Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml (282104 => 282105)


--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml	2021-09-07 19:38:07 UTC (rev 282105)
@@ -87,7 +87,7 @@
     WebCore:
       default: true
 
-# We have to resolve the privacy issue in https://github.com/whatwg/html/issues/5803 before we can enable this.
+# We would have to partition BroadcastChannel based on PageGroups if we wanted to enable this for WebKitLegacy.
 BroadcastChannelEnabled:
   type: bool
   humanReadableName: "BroadcastChannel API"
@@ -100,6 +100,16 @@
     WebCore:
       default: false
 
+BroadcastChannelOriginPartitioningEnabled:
+  type: bool
+  defaultValue:
+    WebKitLegacy:
+      default: true
+    WebKit:
+      default: true
+    WebCore:
+      default: true
+
 CFNetworkNetworkLoaderEnabled:
   type: bool
   humanReadableName: "Experimental network loader"

Modified: trunk/Source/WebCore/ChangeLog (282104 => 282105)


--- trunk/Source/WebCore/ChangeLog	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebCore/ChangeLog	2021-09-07 19:38:07 UTC (rev 282105)
@@ -1,3 +1,24 @@
+2021-09-07  Chris Dumez  <[email protected]>
+
+        Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel
+        https://bugs.webkit.org/show_bug.cgi?id=229814
+
+        Reviewed by Alex Christensen.
+
+        Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel to address privacy
+        concerns, as discussed here:
+        - https://github.com/whatwg/html/issues/5803
+
+        Test: http/tests/messaging/broadcastchannel-partitioning.html
+
+        * dom/BroadcastChannel.cpp:
+        (WebCore::BroadcastChannel::BroadcastChannel):
+        (WebCore::m_identifier):
+        (WebCore::BroadcastChannel::dispatchMessage):
+        * dom/BroadcastChannel.h:
+        * dom/BroadcastChannelRegistry.h:
+        * loader/EmptyClients.cpp:
+
 2021-09-07  Kimmo Kinnunen  <[email protected]>
 
         webgl/2.0.y/deqp/functional/gles3/negativestateapi.html get_framebuffer_attachment_parameter fails on Metal

Modified: trunk/Source/WebCore/dom/BroadcastChannel.cpp (282104 => 282105)


--- trunk/Source/WebCore/dom/BroadcastChannel.cpp	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebCore/dom/BroadcastChannel.cpp	2021-09-07 19:38:07 UTC (rev 282105)
@@ -60,7 +60,7 @@
 BroadcastChannel::BroadcastChannel(ScriptExecutionContext& context, const String& name)
     : ActiveDOMObject(&context)
     , m_name(name)
-    , m_origin(context.securityOrigin()->data())
+    , m_origin { context.settingsValues().broadcastChannelOriginPartitioningEnabled ? context.topOrigin().data() : context.securityOrigin()->data(), context.securityOrigin()->data() }
     , m_identifier(BroadcastChannelIdentifier::generateThreadSafe())
 {
     {
@@ -150,7 +150,7 @@
 
     queueTaskKeepingObjectAlive(*this, TaskSource::PostedMessageQueue, [this, message = WTFMove(message)]() mutable {
         if (!m_isClosed)
-            dispatchEvent(MessageEvent::create({ }, WTFMove(message), m_origin.toString()));
+            dispatchEvent(MessageEvent::create({ }, WTFMove(message), m_origin.clientOrigin.toString()));
     });
 }
 

Modified: trunk/Source/WebCore/dom/BroadcastChannel.h (282104 => 282105)


--- trunk/Source/WebCore/dom/BroadcastChannel.h	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebCore/dom/BroadcastChannel.h	2021-09-07 19:38:07 UTC (rev 282105)
@@ -27,9 +27,9 @@
 
 #include "ActiveDOMObject.h"
 #include "BroadcastChannelIdentifier.h"
+#include "ClientOrigin.h"
 #include "EventTarget.h"
 #include "ExceptionOr.h"
-#include "SecurityOriginData.h"
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
 
@@ -83,7 +83,7 @@
     void stop() final { close(); }
 
     const String m_name;
-    const SecurityOriginData m_origin;
+    const ClientOrigin m_origin;
     const BroadcastChannelIdentifier m_identifier;
     bool m_isClosed { false };
     bool m_hasRelevantEventListener { false };

Modified: trunk/Source/WebCore/dom/BroadcastChannelRegistry.h (282104 => 282105)


--- trunk/Source/WebCore/dom/BroadcastChannelRegistry.h	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebCore/dom/BroadcastChannelRegistry.h	2021-09-07 19:38:07 UTC (rev 282105)
@@ -32,14 +32,14 @@
 namespace WebCore {
 
 class SerializedScriptValue;
-struct SecurityOriginData;
+struct ClientOrigin;
 
 class BroadcastChannelRegistry : public RefCounted<BroadcastChannelRegistry> {
 public:
     virtual ~BroadcastChannelRegistry() { }
-    virtual void registerChannel(const SecurityOriginData&, const String& name, BroadcastChannelIdentifier) = 0;
-    virtual void unregisterChannel(const SecurityOriginData&, const String& name, BroadcastChannelIdentifier) = 0;
-    virtual void postMessage(const SecurityOriginData&, const String& name, BroadcastChannelIdentifier source, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) = 0;
+    virtual void registerChannel(const ClientOrigin&, const String& name, BroadcastChannelIdentifier) = 0;
+    virtual void unregisterChannel(const ClientOrigin&, const String& name, BroadcastChannelIdentifier) = 0;
+    virtual void postMessage(const ClientOrigin&, const String& name, BroadcastChannelIdentifier source, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) = 0;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (282104 => 282105)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2021-09-07 19:38:07 UTC (rev 282105)
@@ -1174,9 +1174,9 @@
 private:
     EmptyBroadcastChannelRegistry() = default;
 
-    void registerChannel(const SecurityOriginData&, const String&, BroadcastChannelIdentifier) final { }
-    void unregisterChannel(const SecurityOriginData&, const String&, BroadcastChannelIdentifier) final { }
-    void postMessage(const SecurityOriginData&, const String&, BroadcastChannelIdentifier, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) final { }
+    void registerChannel(const ClientOrigin&, const String&, BroadcastChannelIdentifier) final { }
+    void unregisterChannel(const ClientOrigin&, const String&, BroadcastChannelIdentifier) final { }
+    void postMessage(const ClientOrigin&, const String&, BroadcastChannelIdentifier, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) final { }
 };
 
 PageConfiguration pageConfigurationWithEmptyClients(PAL::SessionID sessionID)

Modified: trunk/Source/WebKit/ChangeLog (282104 => 282105)


--- trunk/Source/WebKit/ChangeLog	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebKit/ChangeLog	2021-09-07 19:38:07 UTC (rev 282105)
@@ -1,3 +1,27 @@
+2021-09-07  Chris Dumez  <[email protected]>
+
+        Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel
+        https://bugs.webkit.org/show_bug.cgi?id=229814
+
+        Reviewed by Alex Christensen.
+
+        Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel to address privacy
+        concerns, as discussed here:
+        - https://github.com/whatwg/html/issues/5803
+
+        * NetworkProcess/NetworkBroadcastChannelRegistry.cpp:
+        (WebKit::NetworkBroadcastChannelRegistry::registerChannel):
+        (WebKit::NetworkBroadcastChannelRegistry::unregisterChannel):
+        (WebKit::NetworkBroadcastChannelRegistry::postMessage):
+        (WebKit::NetworkBroadcastChannelRegistry::removeConnection):
+        * NetworkProcess/NetworkBroadcastChannelRegistry.h:
+        * NetworkProcess/NetworkBroadcastChannelRegistry.messages.in:
+        * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp:
+        (WebKit::WebBroadcastChannelRegistry::registerChannel):
+        (WebKit::WebBroadcastChannelRegistry::unregisterChannel):
+        (WebKit::WebBroadcastChannelRegistry::postMessage):
+        * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h:
+
 2021-09-07  Wenson Hsieh  <[email protected]>
 
         Post-layout `EditorState` updates should be scheduled using `RenderingUpdateScheduler`

Modified: trunk/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.cpp (282104 => 282105)


--- trunk/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.cpp	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.cpp	2021-09-07 19:38:07 UTC (rev 282105)
@@ -34,7 +34,7 @@
 
 NetworkBroadcastChannelRegistry::NetworkBroadcastChannelRegistry() = default;
 
-void NetworkBroadcastChannelRegistry::registerChannel(IPC::Connection& connection, const WebCore::SecurityOriginData& origin, const String& name, WebCore::BroadcastChannelIdentifier channelIdentifier)
+void NetworkBroadcastChannelRegistry::registerChannel(IPC::Connection& connection, const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier channelIdentifier)
 {
     auto& channelsForOrigin = m_broadcastChannels.ensure(origin, [] { return NameToChannelIdentifiersMap { }; }).iterator->value;
     auto& channelsForName = channelsForOrigin.ensure(name, [] { return Vector<GlobalBroadcastChannelIdentifier> { }; }).iterator->value;
@@ -43,7 +43,7 @@
     channelsForName.append(WTFMove(globalChannelIdentifier));
 }
 
-void NetworkBroadcastChannelRegistry::unregisterChannel(IPC::Connection& connection, const WebCore::SecurityOriginData& origin, const String& name, WebCore::BroadcastChannelIdentifier channelIdentifier)
+void NetworkBroadcastChannelRegistry::unregisterChannel(IPC::Connection& connection, const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier channelIdentifier)
 {
     auto channelsForOriginIterator = m_broadcastChannels.find(origin);
     ASSERT(channelsForOriginIterator != m_broadcastChannels.end());
@@ -59,7 +59,7 @@
     channelsForNameIterator->value.removeFirst(globalChannelIdentifier);
 }
 
-void NetworkBroadcastChannelRegistry::postMessage(IPC::Connection& connection, const WebCore::SecurityOriginData& origin, const String& name, WebCore::BroadcastChannelIdentifier source, WebCore::MessageWithMessagePorts&& message, CompletionHandler<void()>&& completionHandler)
+void NetworkBroadcastChannelRegistry::postMessage(IPC::Connection& connection, const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, WebCore::MessageWithMessagePorts&& message, CompletionHandler<void()>&& completionHandler)
 {
     auto channelsForOriginIterator = m_broadcastChannels.find(origin);
     ASSERT(channelsForOriginIterator != m_broadcastChannels.end());
@@ -86,7 +86,7 @@
 
 void NetworkBroadcastChannelRegistry::removeConnection(IPC::Connection& connection)
 {
-    Vector<WebCore::SecurityOriginData> originsToRemove;
+    Vector<WebCore::ClientOrigin> originsToRemove;
     for (auto& entry : m_broadcastChannels) {
         Vector<String> namesToRemove;
         for (auto& innerEntry : entry.value) {

Modified: trunk/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.h (282104 => 282105)


--- trunk/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.h	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.h	2021-09-07 19:38:07 UTC (rev 282105)
@@ -27,7 +27,7 @@
 
 #include "Connection.h"
 #include <WebCore/BroadcastChannelIdentifier.h>
-#include <WebCore/SecurityOriginData.h>
+#include <WebCore/ClientOrigin.h>
 #include <wtf/HashMap.h>
 
 namespace WebCore {
@@ -45,9 +45,9 @@
 
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
 
-    void registerChannel(IPC::Connection&, const WebCore::SecurityOriginData&, const String& name, WebCore::BroadcastChannelIdentifier);
-    void unregisterChannel(IPC::Connection&, const WebCore::SecurityOriginData&, const String& name, WebCore::BroadcastChannelIdentifier);
-    void postMessage(IPC::Connection&, const WebCore::SecurityOriginData&, const String& name, WebCore::BroadcastChannelIdentifier source, WebCore::MessageWithMessagePorts&&, CompletionHandler<void()>&&);
+    void registerChannel(IPC::Connection&, const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier);
+    void unregisterChannel(IPC::Connection&, const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier);
+    void postMessage(IPC::Connection&, const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, WebCore::MessageWithMessagePorts&&, CompletionHandler<void()>&&);
 
 private:
     struct GlobalBroadcastChannelIdentifier {
@@ -60,9 +60,8 @@
         }
     };
 
-    // FIXME: BroadcastChannel needs partitioning (https://github.com/whatwg/html/issues/5803).
     using NameToChannelIdentifiersMap = HashMap<String, Vector<GlobalBroadcastChannelIdentifier>>;
-    HashMap<WebCore::SecurityOriginData, NameToChannelIdentifiersMap> m_broadcastChannels;
+    HashMap<WebCore::ClientOrigin, NameToChannelIdentifiersMap> m_broadcastChannels;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.messages.in (282104 => 282105)


--- trunk/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.messages.in	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.messages.in	2021-09-07 19:38:07 UTC (rev 282105)
@@ -21,7 +21,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> NetworkBroadcastChannelRegistry NotRefCounted {
-    RegisterChannel(struct WebCore::SecurityOriginData origin, String name, WebCore::BroadcastChannelIdentifier channelIdentifier) WantsConnection
-    UnregisterChannel(struct WebCore::SecurityOriginData origin, String name, WebCore::BroadcastChannelIdentifier channelIdentifier) WantsConnection
-    PostMessage(struct WebCore::SecurityOriginData origin, String name, WebCore::BroadcastChannelIdentifier source, struct WebCore::MessageWithMessagePorts message) -> () Async WantsConnection
+    RegisterChannel(struct WebCore::ClientOrigin origin, String name, WebCore::BroadcastChannelIdentifier channelIdentifier) WantsConnection
+    UnregisterChannel(struct WebCore::ClientOrigin origin, String name, WebCore::BroadcastChannelIdentifier channelIdentifier) WantsConnection
+    PostMessage(struct WebCore::ClientOrigin origin, String name, WebCore::BroadcastChannelIdentifier source, struct WebCore::MessageWithMessagePorts message) -> () Async WantsConnection
 }

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp (282104 => 282105)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp	2021-09-07 19:38:07 UTC (rev 282105)
@@ -39,17 +39,17 @@
     return WebProcess::singleton().ensureNetworkProcessConnection().connection();
 }
 
-void WebBroadcastChannelRegistry::registerChannel(const WebCore::SecurityOriginData& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
+void WebBroadcastChannelRegistry::registerChannel(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
 {
     networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::RegisterChannel { origin, name, identifier }, 0);
 }
 
-void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::SecurityOriginData& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
+void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
 {
     networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::UnregisterChannel { origin, name, identifier }, 0);
 }
 
-void WebBroadcastChannelRegistry::postMessage(const WebCore::SecurityOriginData& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)
+void WebBroadcastChannelRegistry::postMessage(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)
 {
     networkProcessConnection().sendWithAsyncReply(Messages::NetworkBroadcastChannelRegistry::PostMessage { origin, name, source, WebCore::MessageWithMessagePorts { WTFMove(message), { } } }, WTFMove(completionHandler), 0);
 }

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h (282104 => 282105)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h	2021-09-07 19:38:07 UTC (rev 282105)
@@ -41,9 +41,9 @@
         return adoptRef(*new WebBroadcastChannelRegistry);
     }
 
-    void registerChannel(const WebCore::SecurityOriginData&, const String& name, WebCore::BroadcastChannelIdentifier) final;
-    void unregisterChannel(const WebCore::SecurityOriginData&, const String& name, WebCore::BroadcastChannelIdentifier) final;
-    void postMessage(const WebCore::SecurityOriginData&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;
+    void registerChannel(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
+    void unregisterChannel(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
+    void postMessage(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;
 
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
 

Modified: trunk/Source/WebKitLegacy/ChangeLog (282104 => 282105)


--- trunk/Source/WebKitLegacy/ChangeLog	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebKitLegacy/ChangeLog	2021-09-07 19:38:07 UTC (rev 282105)
@@ -1,3 +1,20 @@
+2021-09-07  Chris Dumez  <[email protected]>
+
+        Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel
+        https://bugs.webkit.org/show_bug.cgi?id=229814
+
+        Reviewed by Alex Christensen.
+
+        Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel to address privacy
+        concerns, as discussed here:
+        - https://github.com/whatwg/html/issues/5803
+
+        * WebCoreSupport/WebBroadcastChannelRegistry.cpp:
+        (WebBroadcastChannelRegistry::registerChannel):
+        (WebBroadcastChannelRegistry::unregisterChannel):
+        (WebBroadcastChannelRegistry::postMessage):
+        * WebCoreSupport/WebBroadcastChannelRegistry.h:
+
 2021-08-27  Russell Epstein  <[email protected]>
 
         Land Windows build fixes from safari-612.1.29.14-branch.

Modified: trunk/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.cpp (282104 => 282105)


--- trunk/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.cpp	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.cpp	2021-09-07 19:38:07 UTC (rev 282105)
@@ -44,7 +44,7 @@
     return registry;
 }
 
-void WebBroadcastChannelRegistry::registerChannel(const WebCore::SecurityOriginData& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
+void WebBroadcastChannelRegistry::registerChannel(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
 {
     ASSERT(isMainThread());
     auto& channelsForOrigin = m_channels.ensure(origin, [] { return NameToChannelIdentifiersMap { }; }).iterator->value;
@@ -53,7 +53,7 @@
     channelsForName.append(identifier);
 }
 
-void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::SecurityOriginData& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
+void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)
 {
     ASSERT(isMainThread());
     auto channelsForOriginIterator = m_channels.find(origin);
@@ -66,7 +66,7 @@
     channelsForNameIterator->value.removeFirst(identifier);
 }
 
-void WebBroadcastChannelRegistry::postMessage(const WebCore::SecurityOriginData& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)
+void WebBroadcastChannelRegistry::postMessage(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(isMainThread());
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));

Modified: trunk/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.h (282104 => 282105)


--- trunk/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.h	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.h	2021-09-07 19:38:07 UTC (rev 282105)
@@ -24,7 +24,7 @@
  */
 
 #include <WebCore/BroadcastChannelRegistry.h>
-#include <WebCore/SecurityOriginData.h>
+#include <WebCore/ClientOrigin.h>
 #include <wtf/Forward.h>
 #include <wtf/WeakPtr.h>
 
@@ -34,14 +34,13 @@
 public:
     static Ref<WebBroadcastChannelRegistry> getOrCreate(bool privateSession);
 
-    void registerChannel(const WebCore::SecurityOriginData&, const String& name, WebCore::BroadcastChannelIdentifier) final;
-    void unregisterChannel(const WebCore::SecurityOriginData&, const String& name, WebCore::BroadcastChannelIdentifier) final;
-    void postMessage(const WebCore::SecurityOriginData&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;
+    void registerChannel(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
+    void unregisterChannel(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;
+    void postMessage(const WebCore::ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;
 
 private:
     WebBroadcastChannelRegistry() = default;
 
-    // FIXME: BroadcastChannel needs partitioning (https://github.com/whatwg/html/issues/5803).
     using NameToChannelIdentifiersMap = HashMap<String, Vector<WebCore::BroadcastChannelIdentifier>>;
-    HashMap<WebCore::SecurityOriginData, NameToChannelIdentifiersMap> m_channels;
+    HashMap<WebCore::ClientOrigin, NameToChannelIdentifiersMap> m_channels;
 };

Modified: trunk/Tools/ChangeLog (282104 => 282105)


--- trunk/Tools/ChangeLog	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Tools/ChangeLog	2021-09-07 19:38:07 UTC (rev 282105)
@@ -1,5 +1,23 @@
 2021-09-07  Chris Dumez  <[email protected]>
 
+        Implement origin partitioning (top-origin/frame-origin) for BroadcastChannel
+        https://bugs.webkit.org/show_bug.cgi?id=229814
+
+        Reviewed by Alex Christensen.
+
+        Disable BroadcastChannel origin partitioning when running layout tests since it would cause
+        too many test failures in WPT tests at this point (e.g. COOP/COEP tests).
+
+        * TestRunnerShared/TestFeatures.cpp:
+        (WTR::shouldDisableBroadcastChannelOriginPartitioning):
+        (WTR::hardcodedFeaturesBasedOnPathForTest):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+        * WebKitTestRunner/TestOptions.cpp:
+        (WTR::TestOptions::defaults):
+
+2021-09-07  Chris Dumez  <[email protected]>
+
         Allow layout tests to open popups by default
         https://bugs.webkit.org/show_bug.cgi?id=229881
 

Modified: trunk/Tools/WebKitTestRunner/TestOptions.cpp (282104 => 282105)


--- trunk/Tools/WebKitTestRunner/TestOptions.cpp	2021-09-07 19:01:48 UTC (rev 282104)
+++ trunk/Tools/WebKitTestRunner/TestOptions.cpp	2021-09-07 19:38:07 UTC (rev 282105)
@@ -64,6 +64,7 @@
             { "AllowsInlineMediaPlayback", true },
             { "AsyncFrameScrollingEnabled", false },
             { "AsyncOverflowScrollingEnabled", false },
+            { "BroadcastChannelOriginPartitioningEnabled", false },
             { "CSSOMViewScrollingAPIEnabled", true },
             { "CaptureAudioInGPUProcessEnabled", captureAudioInGPUProcessEnabledValue },
             { "CaptureAudioInUIProcessEnabled", false },
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to