Changeset 293261 in webkit
- Timestamp:
- Apr 22, 2022, 4:02:57 PM (4 years ago)
- Location:
- branches/safari-613.2.7.1-branch
- Files:
-
- 4 added
- 20 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/w3c-import.log (modified) (1 diff)
-
Source/JavaScriptCore/runtime/InternalFunction.cpp.orig (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Headers.cmake (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Source/WebCore/dom/BroadcastChannel.cpp (modified) (5 diffs)
-
Source/WebCore/dom/BroadcastChannelRegistry.h (modified) (1 diff)
-
Source/WebCore/loader/EmptyClients.cpp (modified) (1 diff)
-
Source/WebCore/page/PartitionedSecurityOrigin.h (added)
-
Source/WebCore/page/SecurityOrigin.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.cpp (modified) (5 diffs)
-
Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.h (modified) (2 diffs)
-
Source/WebKit/NetworkProcess/NetworkProcess.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.h (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkSession.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp (modified) (6 diffs)
-
Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h (modified) (3 diffs)
-
Source/WebKitLegacy/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.cpp (modified) (3 diffs)
-
Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-613.2.7.1-branch/LayoutTests/imported/w3c/ChangeLog
r293139 r293261 1 2022-04-22 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r291589. rdar://problem/90511155 4 5 LayoutTests/imported/w3c: 6 BroadcastChannel instances in distinct opaque origins can communicate 7 https://bugs.webkit.org/show_bug.cgi?id=238090 8 <rdar://problem/90511155> 9 10 Reviewed by Alex Christensen. 11 12 Import web-platform-tests test coverage. 13 14 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added. 15 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added. 16 * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log: 17 18 Source/WebCore: 19 BroadcastChannel instances in distinct opaque origins can communicate 20 https://bugs.webkit.org/show_bug.cgi?id=238090 21 <rdar://problem/90511155> 22 23 Reviewed by Alex Christensen. 24 25 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 26 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 27 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 28 unique SecurityOrigins, they would compare as equal. 29 30 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 31 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 32 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 33 would not be equal but the same unique SecurityOrigin would be. I then used this new 34 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 35 ClientOrigin. This allows communication between several BroadcastChannels from the same 36 unique origin, while preventing communication between distinct opaque origins. 37 38 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 39 the Network Process at all since the destination can only be in the same WebProcess. 40 41 Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html 42 43 * Headers.cmake: 44 * WebCore.xcodeproj/project.pbxproj: 45 * dom/BroadcastChannel.cpp: 46 (WebCore::shouldPartitionOrigin): 47 (WebCore::BroadcastChannel::MainThreadBridge::registerChannel): 48 (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel): 49 (WebCore::BroadcastChannel::MainThreadBridge::postMessage): 50 * dom/BroadcastChannelRegistry.h: 51 * loader/EmptyClients.cpp: 52 * page/PartitionedSecurityOrigin.h: Added. 53 (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin): 54 (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const): 55 (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const): 56 (WebCore::operator==): 57 (WTF::add): 58 (WTF::PartitionedSecurityOriginHash::hash): 59 (WTF::PartitionedSecurityOriginHash::equal): 60 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue): 61 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue): 62 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue): 63 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek): 64 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take): 65 66 Source/WebKit: 67 BroadcastChannel instances in distinct opaque origins can communicate 68 https://bugs.webkit.org/show_bug.cgi?id=238090 69 <rdar://problem/90511155> 70 71 Reviewed by Alex Christensen. 72 73 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 74 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 75 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 76 unique SecurityOrigins, they would compare as equal. 77 78 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 79 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 80 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 81 would not be equal but the same unique SecurityOrigin would be. I then used this new 82 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 83 ClientOrigin. This allows communication between several BroadcastChannels from the same 84 unique origin, while preventing communication between distinct opaque origins. 85 86 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 87 the Network Process at all since the destination can only be in the same WebProcess. 88 89 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp: 90 (WebKit::toClientOrigin): 91 (WebKit::WebBroadcastChannelRegistry::registerChannel): 92 (WebKit::WebBroadcastChannelRegistry::unregisterChannel): 93 (WebKit::WebBroadcastChannelRegistry::postMessage): 94 (WebKit::WebBroadcastChannelRegistry::postMessageLocally): 95 (WebKit::WebBroadcastChannelRegistry::postMessageToRemote): 96 (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed): 97 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h: 98 99 Source/WebKitLegacy: 100 Dust off Mac CMake build 101 https://bugs.webkit.org/show_bug.cgi?id=238121 102 103 Reviewed by Yusuke Suzuki. 104 105 * PlatformMac.cmake: 106 107 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291589 268f45cc-cd09-0410-ab3c-d52691b4dbfc 108 109 2022-03-21 Chris Dumez <cdumez@apple.com> 110 111 BroadcastChannel instances in distinct opaque origins can communicate 112 https://bugs.webkit.org/show_bug.cgi?id=238090 113 <rdar://problem/90511155> 114 115 Reviewed by Alex Christensen. 116 117 Import web-platform-tests test coverage. 118 119 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added. 120 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added. 121 * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log: 122 1 123 2022-04-18 Kocsen Chung <kocsen_chung@apple.com> 2 124 -
branches/safari-613.2.7.1-branch/LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/w3c-import.log
r293139 r293261 20 20 /LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/detached-iframe.html 21 21 /LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/interface.any.js 22 /LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html 22 23 /LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/ordering.html 23 24 /LayoutTests/imported/w3c/web-platform-tests/webmessaging/broadcastchannel/origin.window.js -
branches/safari-613.2.7.1-branch/Source/WebCore/ChangeLog
r293250 r293261 1 2022-04-22 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r291589. rdar://problem/90511155 4 5 LayoutTests/imported/w3c: 6 BroadcastChannel instances in distinct opaque origins can communicate 7 https://bugs.webkit.org/show_bug.cgi?id=238090 8 <rdar://problem/90511155> 9 10 Reviewed by Alex Christensen. 11 12 Import web-platform-tests test coverage. 13 14 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added. 15 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added. 16 * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log: 17 18 Source/WebCore: 19 BroadcastChannel instances in distinct opaque origins can communicate 20 https://bugs.webkit.org/show_bug.cgi?id=238090 21 <rdar://problem/90511155> 22 23 Reviewed by Alex Christensen. 24 25 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 26 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 27 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 28 unique SecurityOrigins, they would compare as equal. 29 30 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 31 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 32 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 33 would not be equal but the same unique SecurityOrigin would be. I then used this new 34 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 35 ClientOrigin. This allows communication between several BroadcastChannels from the same 36 unique origin, while preventing communication between distinct opaque origins. 37 38 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 39 the Network Process at all since the destination can only be in the same WebProcess. 40 41 Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html 42 43 * Headers.cmake: 44 * WebCore.xcodeproj/project.pbxproj: 45 * dom/BroadcastChannel.cpp: 46 (WebCore::shouldPartitionOrigin): 47 (WebCore::BroadcastChannel::MainThreadBridge::registerChannel): 48 (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel): 49 (WebCore::BroadcastChannel::MainThreadBridge::postMessage): 50 * dom/BroadcastChannelRegistry.h: 51 * loader/EmptyClients.cpp: 52 * page/PartitionedSecurityOrigin.h: Added. 53 (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin): 54 (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const): 55 (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const): 56 (WebCore::operator==): 57 (WTF::add): 58 (WTF::PartitionedSecurityOriginHash::hash): 59 (WTF::PartitionedSecurityOriginHash::equal): 60 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue): 61 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue): 62 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue): 63 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek): 64 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take): 65 66 Source/WebKit: 67 BroadcastChannel instances in distinct opaque origins can communicate 68 https://bugs.webkit.org/show_bug.cgi?id=238090 69 <rdar://problem/90511155> 70 71 Reviewed by Alex Christensen. 72 73 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 74 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 75 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 76 unique SecurityOrigins, they would compare as equal. 77 78 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 79 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 80 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 81 would not be equal but the same unique SecurityOrigin would be. I then used this new 82 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 83 ClientOrigin. This allows communication between several BroadcastChannels from the same 84 unique origin, while preventing communication between distinct opaque origins. 85 86 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 87 the Network Process at all since the destination can only be in the same WebProcess. 88 89 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp: 90 (WebKit::toClientOrigin): 91 (WebKit::WebBroadcastChannelRegistry::registerChannel): 92 (WebKit::WebBroadcastChannelRegistry::unregisterChannel): 93 (WebKit::WebBroadcastChannelRegistry::postMessage): 94 (WebKit::WebBroadcastChannelRegistry::postMessageLocally): 95 (WebKit::WebBroadcastChannelRegistry::postMessageToRemote): 96 (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed): 97 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h: 98 99 Source/WebKitLegacy: 100 Dust off Mac CMake build 101 https://bugs.webkit.org/show_bug.cgi?id=238121 102 103 Reviewed by Yusuke Suzuki. 104 105 * PlatformMac.cmake: 106 107 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291589 268f45cc-cd09-0410-ab3c-d52691b4dbfc 108 109 2022-03-21 Chris Dumez <cdumez@apple.com> 110 111 BroadcastChannel instances in distinct opaque origins can communicate 112 https://bugs.webkit.org/show_bug.cgi?id=238090 113 <rdar://problem/90511155> 114 115 Reviewed by Alex Christensen. 116 117 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 118 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 119 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 120 unique SecurityOrigins, they would compare as equal. 121 122 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 123 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 124 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 125 would not be equal but the same unique SecurityOrigin would be. I then used this new 126 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 127 ClientOrigin. This allows communication between several BroadcastChannels from the same 128 unique origin, while preventing communication between distinct opaque origins. 129 130 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 131 the Network Process at all since the destination can only be in the same WebProcess. 132 133 Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html 134 135 * Headers.cmake: 136 * WebCore.xcodeproj/project.pbxproj: 137 * dom/BroadcastChannel.cpp: 138 (WebCore::shouldPartitionOrigin): 139 (WebCore::BroadcastChannel::MainThreadBridge::registerChannel): 140 (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel): 141 (WebCore::BroadcastChannel::MainThreadBridge::postMessage): 142 * dom/BroadcastChannelRegistry.h: 143 * loader/EmptyClients.cpp: 144 * page/PartitionedSecurityOrigin.h: Added. 145 (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin): 146 (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const): 147 (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const): 148 (WebCore::operator==): 149 (WTF::add): 150 (WTF::PartitionedSecurityOriginHash::hash): 151 (WTF::PartitionedSecurityOriginHash::equal): 152 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue): 153 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue): 154 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue): 155 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek): 156 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take): 157 1 158 2022-04-22 Russell Epstein <repstein@apple.com> 2 159 -
branches/safari-613.2.7.1-branch/Source/WebCore/Headers.cmake
r293139 r293261 1126 1126 page/PageOverlayController.h 1127 1127 page/PagePasteboardContext.h 1128 page/PartitionedSecurityOrigin.h 1128 1129 page/PerformanceLogging.h 1129 1130 page/PerformanceLoggingClient.h -
branches/safari-613.2.7.1-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r293139 r293261 1347 1347 468344E01EDDFAAA00B7795B /* DOMRectList.h in Headers */ = {isa = PBXBuildFile; fileRef = 468344DE1EDDFA5F00B7795B /* DOMRectList.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1348 1348 4688EE3C26DD2610002AF5C4 /* CrossOriginMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 4688EE3A26DD260C002AF5C4 /* CrossOriginMode.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1349 46893B8427E8D74C002CC13D /* PartitionedSecurityOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = 46893B8327E8D716002CC13D /* PartitionedSecurityOrigin.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1349 1350 469CCCFE269D021C006E0314 /* BroadcastChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 469CCCFC269D0202006E0314 /* BroadcastChannel.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1350 1351 469D77B82701625100142FA6 /* NavigationRequester.h in Headers */ = {isa = PBXBuildFile; fileRef = 469D77B62701625000142FA6 /* NavigationRequester.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 9216 9217 468344DE1EDDFA5F00B7795B /* DOMRectList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMRectList.h; sourceTree = "<group>"; }; 9217 9218 4688EE3A26DD260C002AF5C4 /* CrossOriginMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CrossOriginMode.h; sourceTree = "<group>"; }; 9219 46893B8327E8D716002CC13D /* PartitionedSecurityOrigin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PartitionedSecurityOrigin.h; sourceTree = "<group>"; }; 9218 9220 468B8BDE25CC849300F67822 /* JSBaseAudioContextCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSBaseAudioContextCustom.cpp; sourceTree = "<group>"; }; 9219 9221 469CCCFA269D0202006E0314 /* BroadcastChannel.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BroadcastChannel.cpp; sourceTree = "<group>"; }; … … 24085 24087 371E65CD13661EED00BEEDB0 /* PageSerializer.cpp */, 24086 24088 371E65CB13661EDC00BEEDB0 /* PageSerializer.h */, 24089 46893B8327E8D716002CC13D /* PartitionedSecurityOrigin.h */, 24087 24090 BC4A53282560563B0028C592 /* PDFImageCachingPolicy.h */, 24088 24091 7C72471E2516758800C363CD /* Performance+NavigationTiming.idl */, … … 36373 36376 5C4A0FDA25C3449A00D9EE97 /* ParsedRequestRange.h in Headers */, 36374 36377 536D5A23193E8E0C00CE4CAB /* ParsingUtilities.h in Headers */, 36378 46893B8427E8D74C002CC13D /* PartitionedSecurityOrigin.h in Headers */, 36375 36379 F55B3DCA1251F12D003EF269 /* PasswordInputType.h in Headers */, 36376 36380 4B2708C70AF19EE40065127F /* Pasteboard.h in Headers */, -
branches/safari-613.2.7.1-branch/Source/WebCore/dom/BroadcastChannel.cpp
r293139 r293261 31 31 #include "MessageEvent.h" 32 32 #include "Page.h" 33 #include "PartitionedSecurityOrigin.h" 33 34 #include "SecurityOrigin.h" 34 35 #include "SerializedScriptValue.h" … … 87 88 const BroadcastChannelIdentifier m_identifier; 88 89 const String m_name; // Main thread only. 89 ClientOriginm_origin; // Main thread only.90 std::optional<PartitionedSecurityOrigin> m_origin; // Main thread only. 90 91 }; 91 92 … … 121 122 { 122 123 ensureOnMainThread([this, contextIdentifier = m_broadcastChannel->scriptExecutionContext()->identifier()](auto& document) { 123 m_origin = { shouldPartitionOrigin(document) ? document.topOrigin().data() : document.securityOrigin().data(), document.securityOrigin().data() };124 m_origin = PartitionedSecurityOrigin { shouldPartitionOrigin(document) ? document.topOrigin() : document.securityOrigin(), document.securityOrigin() }; 124 125 if (auto* page = document.page()) 125 page->broadcastChannelRegistry().registerChannel( m_origin, m_name, m_identifier);126 page->broadcastChannelRegistry().registerChannel(*m_origin, m_name, m_identifier); 126 127 channelToContextIdentifier().add(m_identifier, contextIdentifier); 127 128 }); … … 132 133 ensureOnMainThread([this](auto& document) { 133 134 if (auto* page = document.page()) 134 page->broadcastChannelRegistry().unregisterChannel( m_origin, m_name, m_identifier);135 page->broadcastChannelRegistry().unregisterChannel(*m_origin, m_name, m_identifier); 135 136 channelToContextIdentifier().remove(m_identifier); 136 137 }); … … 145 146 146 147 auto blobHandles = message->blobHandles(); 147 page->broadcastChannelRegistry().postMessage( m_origin, m_name, m_identifier, WTFMove(message), [blobHandles = WTFMove(blobHandles)] {148 page->broadcastChannelRegistry().postMessage(*m_origin, m_name, m_identifier, WTFMove(message), [blobHandles = WTFMove(blobHandles)] { 148 149 // Keeps Blob data inside messageData alive until the message has been delivered. 149 150 }); -
branches/safari-613.2.7.1-branch/Source/WebCore/dom/BroadcastChannelRegistry.h
r293139 r293261 32 32 namespace WebCore { 33 33 34 struct PartitionedSecurityOrigin; 34 35 class SerializedScriptValue; 35 struct ClientOrigin;36 36 37 37 class BroadcastChannelRegistry : public RefCounted<BroadcastChannelRegistry> { 38 38 public: 39 39 virtual ~BroadcastChannelRegistry() { } 40 virtual void registerChannel(const ClientOrigin&, const String& name, BroadcastChannelIdentifier) = 0;41 virtual void unregisterChannel(const ClientOrigin&, const String& name, BroadcastChannelIdentifier) = 0;42 virtual void postMessage(const ClientOrigin&, const String& name, BroadcastChannelIdentifier source, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) = 0;40 virtual void registerChannel(const PartitionedSecurityOrigin&, const String& name, BroadcastChannelIdentifier) = 0; 41 virtual void unregisterChannel(const PartitionedSecurityOrigin&, const String& name, BroadcastChannelIdentifier) = 0; 42 virtual void postMessage(const PartitionedSecurityOrigin&, const String& name, BroadcastChannelIdentifier source, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) = 0; 43 43 }; 44 44 -
branches/safari-613.2.7.1-branch/Source/WebCore/loader/EmptyClients.cpp
r293139 r293261 1184 1184 EmptyBroadcastChannelRegistry() = default; 1185 1185 1186 void registerChannel(const ClientOrigin&, const String&, BroadcastChannelIdentifier) final { }1187 void unregisterChannel(const ClientOrigin&, const String&, BroadcastChannelIdentifier) final { }1188 void postMessage(const ClientOrigin&, const String&, BroadcastChannelIdentifier, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) final { }1186 void registerChannel(const PartitionedSecurityOrigin&, const String&, BroadcastChannelIdentifier) final { } 1187 void unregisterChannel(const PartitionedSecurityOrigin&, const String&, BroadcastChannelIdentifier) final { } 1188 void postMessage(const PartitionedSecurityOrigin&, const String&, BroadcastChannelIdentifier, Ref<SerializedScriptValue>&&, CompletionHandler<void()>&&) final { } 1189 1189 }; 1190 1190 -
branches/safari-613.2.7.1-branch/Source/WebCore/page/SecurityOrigin.h
r286821 r293261 307 307 } 308 308 309 inline void add(Hasher& hasher, const SecurityOrigin& origin) 310 { 311 add(hasher, origin.protocol(), origin.host(), origin.port()); 312 } 313 309 314 } // namespace WebCore -
branches/safari-613.2.7.1-branch/Source/WebKit/ChangeLog
r293248 r293261 1 2022-04-22 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r291589. rdar://problem/90511155 4 5 LayoutTests/imported/w3c: 6 BroadcastChannel instances in distinct opaque origins can communicate 7 https://bugs.webkit.org/show_bug.cgi?id=238090 8 <rdar://problem/90511155> 9 10 Reviewed by Alex Christensen. 11 12 Import web-platform-tests test coverage. 13 14 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added. 15 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added. 16 * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log: 17 18 Source/WebCore: 19 BroadcastChannel instances in distinct opaque origins can communicate 20 https://bugs.webkit.org/show_bug.cgi?id=238090 21 <rdar://problem/90511155> 22 23 Reviewed by Alex Christensen. 24 25 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 26 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 27 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 28 unique SecurityOrigins, they would compare as equal. 29 30 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 31 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 32 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 33 would not be equal but the same unique SecurityOrigin would be. I then used this new 34 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 35 ClientOrigin. This allows communication between several BroadcastChannels from the same 36 unique origin, while preventing communication between distinct opaque origins. 37 38 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 39 the Network Process at all since the destination can only be in the same WebProcess. 40 41 Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html 42 43 * Headers.cmake: 44 * WebCore.xcodeproj/project.pbxproj: 45 * dom/BroadcastChannel.cpp: 46 (WebCore::shouldPartitionOrigin): 47 (WebCore::BroadcastChannel::MainThreadBridge::registerChannel): 48 (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel): 49 (WebCore::BroadcastChannel::MainThreadBridge::postMessage): 50 * dom/BroadcastChannelRegistry.h: 51 * loader/EmptyClients.cpp: 52 * page/PartitionedSecurityOrigin.h: Added. 53 (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin): 54 (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const): 55 (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const): 56 (WebCore::operator==): 57 (WTF::add): 58 (WTF::PartitionedSecurityOriginHash::hash): 59 (WTF::PartitionedSecurityOriginHash::equal): 60 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue): 61 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue): 62 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue): 63 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek): 64 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take): 65 66 Source/WebKit: 67 BroadcastChannel instances in distinct opaque origins can communicate 68 https://bugs.webkit.org/show_bug.cgi?id=238090 69 <rdar://problem/90511155> 70 71 Reviewed by Alex Christensen. 72 73 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 74 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 75 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 76 unique SecurityOrigins, they would compare as equal. 77 78 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 79 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 80 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 81 would not be equal but the same unique SecurityOrigin would be. I then used this new 82 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 83 ClientOrigin. This allows communication between several BroadcastChannels from the same 84 unique origin, while preventing communication between distinct opaque origins. 85 86 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 87 the Network Process at all since the destination can only be in the same WebProcess. 88 89 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp: 90 (WebKit::toClientOrigin): 91 (WebKit::WebBroadcastChannelRegistry::registerChannel): 92 (WebKit::WebBroadcastChannelRegistry::unregisterChannel): 93 (WebKit::WebBroadcastChannelRegistry::postMessage): 94 (WebKit::WebBroadcastChannelRegistry::postMessageLocally): 95 (WebKit::WebBroadcastChannelRegistry::postMessageToRemote): 96 (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed): 97 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h: 98 99 Source/WebKitLegacy: 100 Dust off Mac CMake build 101 https://bugs.webkit.org/show_bug.cgi?id=238121 102 103 Reviewed by Yusuke Suzuki. 104 105 * PlatformMac.cmake: 106 107 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291589 268f45cc-cd09-0410-ab3c-d52691b4dbfc 108 109 2022-03-21 Chris Dumez <cdumez@apple.com> 110 111 BroadcastChannel instances in distinct opaque origins can communicate 112 https://bugs.webkit.org/show_bug.cgi?id=238090 113 <rdar://problem/90511155> 114 115 Reviewed by Alex Christensen. 116 117 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 118 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 119 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 120 unique SecurityOrigins, they would compare as equal. 121 122 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 123 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 124 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 125 would not be equal but the same unique SecurityOrigin would be. I then used this new 126 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 127 ClientOrigin. This allows communication between several BroadcastChannels from the same 128 unique origin, while preventing communication between distinct opaque origins. 129 130 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 131 the Network Process at all since the destination can only be in the same WebProcess. 132 133 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp: 134 (WebKit::toClientOrigin): 135 (WebKit::WebBroadcastChannelRegistry::registerChannel): 136 (WebKit::WebBroadcastChannelRegistry::unregisterChannel): 137 (WebKit::WebBroadcastChannelRegistry::postMessage): 138 (WebKit::WebBroadcastChannelRegistry::postMessageLocally): 139 (WebKit::WebBroadcastChannelRegistry::postMessageToRemote): 140 (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed): 141 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h: 142 1 143 2022-04-22 Russell Epstein <repstein@apple.com> 2 144 -
branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.cpp
r293139 r293261 27 27 #include "NetworkBroadcastChannelRegistry.h" 28 28 29 #include "NetworkProcessProxyMessages.h" 29 30 #include "WebBroadcastChannelRegistryMessages.h" 30 31 #include <WebCore/MessageWithMessagePorts.h> … … 33 34 namespace WebKit { 34 35 35 NetworkBroadcastChannelRegistry::NetworkBroadcastChannelRegistry() = default; 36 #define REGISTRY_MESSAGE_CHECK(assertion) REGISTRY_MESSAGE_CHECK_COMPLETION(assertion, (void)0) 37 #define REGISTRY_MESSAGE_CHECK_COMPLETION(assertion, completion) do { \ 38 ASSERT(assertion); \ 39 if (UNLIKELY(!(assertion))) { \ 40 if (auto webProcessIdentifier = m_networkProcess->webProcessIdentifierForConnection(connection)) \ 41 m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::TerminateWebProcess(webProcessIdentifier), 0); \ 42 { completion; } \ 43 return; \ 44 } \ 45 } while (0) 46 47 static bool isValidClientOrigin(const WebCore::ClientOrigin& clientOrigin) 48 { 49 return !clientOrigin.topOrigin.isEmpty() && !clientOrigin.clientOrigin.isEmpty(); 50 } 51 52 NetworkBroadcastChannelRegistry::NetworkBroadcastChannelRegistry(NetworkProcess& networkProcess) 53 : m_networkProcess(networkProcess) 54 { 55 } 36 56 37 57 void NetworkBroadcastChannelRegistry::registerChannel(IPC::Connection& connection, const WebCore::ClientOrigin& origin, const String& name) 38 58 { 59 REGISTRY_MESSAGE_CHECK(isValidClientOrigin(origin)); 60 39 61 auto& channelsForOrigin = m_broadcastChannels.ensure(origin, [] { return NameToConnectionIdentifiersMap { }; }).iterator->value; 40 62 auto& connectionIdentifiersForName = channelsForOrigin.ensure(name, [] { return Vector<IPC::Connection::UniqueID> { }; }).iterator->value; … … 45 67 void NetworkBroadcastChannelRegistry::unregisterChannel(IPC::Connection& connection, const WebCore::ClientOrigin& origin, const String& name) 46 68 { 69 REGISTRY_MESSAGE_CHECK(isValidClientOrigin(origin)); 70 47 71 auto channelsForOriginIterator = m_broadcastChannels.find(origin); 48 72 ASSERT(channelsForOriginIterator != m_broadcastChannels.end()); … … 60 84 void NetworkBroadcastChannelRegistry::postMessage(IPC::Connection& connection, const WebCore::ClientOrigin& origin, const String& name, WebCore::MessageWithMessagePorts&& message, CompletionHandler<void()>&& completionHandler) 61 85 { 86 REGISTRY_MESSAGE_CHECK_COMPLETION(isValidClientOrigin(origin), completionHandler()); 87 62 88 auto channelsForOriginIterator = m_broadcastChannels.find(origin); 63 89 ASSERT(channelsForOriginIterator != m_broadcastChannels.end()); … … 102 128 } 103 129 130 #undef REGISTRY_MESSAGE_CHECK 131 #undef REGISTRY_MESSAGE_CHECK_COMPLETION 132 104 133 } // namespace WebKit -
branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkBroadcastChannelRegistry.h
r293139 r293261 37 37 namespace WebKit { 38 38 39 class NetworkProcess; 40 39 41 class NetworkBroadcastChannelRegistry { 40 42 WTF_MAKE_FAST_ALLOCATED; 41 43 public: 42 NetworkBroadcastChannelRegistry();44 explicit NetworkBroadcastChannelRegistry(NetworkProcess&); 43 45 44 46 void removeConnection(IPC::Connection&); … … 51 53 52 54 private: 55 Ref<NetworkProcess> m_networkProcess; 53 56 using NameToConnectionIdentifiersMap = HashMap<String, Vector<IPC::Connection::UniqueID>>; 54 57 HashMap<WebCore::ClientOrigin, NameToConnectionIdentifiersMap> m_broadcastChannels; -
branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r293139 r293261 2606 2606 } 2607 2607 2608 WebCore::ProcessIdentifier NetworkProcess::webProcessIdentifierForConnection(IPC::Connection& connection) const 2609 { 2610 for (auto& [processIdentifier, webConnection] : m_webProcessConnections) { 2611 if (&webConnection->connection() == &connection) 2612 return processIdentifier; 2613 } 2614 return { }; 2615 } 2616 2608 2617 NetworkConnectionToWebProcess* NetworkProcess::webProcessConnection(ProcessIdentifier identifier) const 2609 2618 { -
branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkProcess.h
r293139 r293261 336 336 337 337 NetworkConnectionToWebProcess* webProcessConnection(WebCore::ProcessIdentifier) const; 338 WebCore::ProcessIdentifier webProcessIdentifierForConnection(IPC::Connection&) const; 338 339 WebCore::MessagePortChannelRegistry& messagePortChannelRegistry() { return m_messagePortChannelRegistry; } 339 340 -
branches/safari-613.2.7.1-branch/Source/WebKit/NetworkProcess/NetworkSession.cpp
r293139 r293261 126 126 , m_privateClickMeasurement(managerOrProxy(*this, networkProcess, parameters)) 127 127 , m_privateClickMeasurementDebugModeEnabled(parameters.enablePrivateClickMeasurementDebugMode) 128 , m_broadcastChannelRegistry(makeUniqueRef<NetworkBroadcastChannelRegistry>( ))128 , m_broadcastChannelRegistry(makeUniqueRef<NetworkBroadcastChannelRegistry>(networkProcess)) 129 129 , m_testSpeedMultiplier(parameters.testSpeedMultiplier) 130 130 , m_allowsServerPreconnect(parameters.allowsServerPreconnect) -
branches/safari-613.2.7.1-branch/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp
r293139 r293261 41 41 } 42 42 43 void WebBroadcastChannelRegistry::registerChannel(const WebCore::ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier) 43 // Unique origins are only stored in process in m_channelsPerOrigin and never sent to the NetworkProcess as a ClientOrigin. 44 // The identity of unique origins wouldn't be preserved when serializing them as a SecurityOriginData (via ClientOrigin). 45 // Since BroadcastChannels from a unique origin can only communicate with other BroadcastChannels from the same unique origin, 46 // the destination channels have to be within the same WebProcess anyway. 47 static std::optional<WebCore::ClientOrigin> toClientOrigin(const WebCore::PartitionedSecurityOrigin& origin) 48 { 49 if (origin.topOrigin->isUnique() || origin.clientOrigin->isUnique()) 50 return std::nullopt; 51 return WebCore::ClientOrigin { origin.topOrigin->data(), origin.clientOrigin->data() }; 52 } 53 54 void WebBroadcastChannelRegistry::registerChannel(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier) 44 55 { 45 56 auto& channelsForOrigin = m_channelsPerOrigin.ensure(origin, [] { return HashMap<String, Vector<WebCore::BroadcastChannelIdentifier>> { }; }).iterator->value; … … 47 58 channelsForName.append(identifier); 48 59 49 if (channelsForName.size() == 1) 50 networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::RegisterChannel { origin, name }, 0); 60 if (channelsForName.size() == 1) { 61 if (auto clientOrigin = toClientOrigin(origin)) 62 networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::RegisterChannel { *clientOrigin, name }, 0); 63 } 51 64 } 52 65 53 void WebBroadcastChannelRegistry::unregisterChannel(const WebCore:: ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)66 void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier) 54 67 { 55 68 auto channelsPerOriginIterator = m_channelsPerOrigin.find(origin); … … 69 82 70 83 channelsForOrigin.remove(channelsForOriginIterator); 71 networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::UnregisterChannel { origin, name }, 0); 84 if (auto clientOrigin = toClientOrigin(origin)) 85 networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::UnregisterChannel { *clientOrigin, name }, 0); 72 86 73 87 if (channelsForOrigin.isEmpty()) … … 75 89 } 76 90 77 void WebBroadcastChannelRegistry::postMessage(const WebCore:: ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)91 void WebBroadcastChannelRegistry::postMessage(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler) 78 92 { 79 93 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 80 94 postMessageLocally(origin, name, source, message.copyRef(), callbackAggregator.copyRef()); 81 networkProcessConnection().sendWithAsyncReply(Messages::NetworkBroadcastChannelRegistry::PostMessage { origin, name, WebCore::MessageWithMessagePorts { WTFMove(message), { } } }, [callbackAggregator] { }, 0); 95 if (auto clientOrigin = toClientOrigin(origin)) 96 networkProcessConnection().sendWithAsyncReply(Messages::NetworkBroadcastChannelRegistry::PostMessage { *clientOrigin, name, WebCore::MessageWithMessagePorts { WTFMove(message), { } } }, [callbackAggregator] { }, 0); 82 97 } 83 98 84 void WebBroadcastChannelRegistry::postMessageLocally(const WebCore:: ClientOrigin& origin, const String& name, std::optional<WebCore::BroadcastChannelIdentifier> sourceInProcess, Ref<WebCore::SerializedScriptValue>&& message, Ref<WTF::CallbackAggregator>&& callbackAggregator)99 void WebBroadcastChannelRegistry::postMessageLocally(const WebCore::PartitionedSecurityOrigin& origin, const String& name, std::optional<WebCore::BroadcastChannelIdentifier> sourceInProcess, Ref<WebCore::SerializedScriptValue>&& message, Ref<WTF::CallbackAggregator>&& callbackAggregator) 85 100 { 86 101 auto channelsPerOriginIterator = m_channelsPerOrigin.find(origin); … … 101 116 } 102 117 103 void WebBroadcastChannelRegistry::postMessageToRemote(const WebCore::ClientOrigin& origin, const String& name, WebCore::MessageWithMessagePorts&& message, CompletionHandler<void()>&& completionHandler)118 void WebBroadcastChannelRegistry::postMessageToRemote(const WebCore::ClientOrigin& clientOrigin, const String& name, WebCore::MessageWithMessagePorts&& message, CompletionHandler<void()>&& completionHandler) 104 119 { 105 120 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 121 WebCore::PartitionedSecurityOrigin origin { clientOrigin.topOrigin.securityOrigin(), clientOrigin.clientOrigin.securityOrigin() }; 106 122 postMessageLocally(origin, name, std::nullopt, *message.message, callbackAggregator.copyRef()); 107 123 } … … 110 126 { 111 127 for (auto& [origin, channelsForOrigin] : m_channelsPerOrigin) { 128 auto clientOrigin = toClientOrigin(origin); 129 if (!clientOrigin) 130 continue; 112 131 for (auto& name : channelsForOrigin.keys()) 113 networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::RegisterChannel { origin, name }, 0);132 networkProcessConnection().send(Messages::NetworkBroadcastChannelRegistry::RegisterChannel { *clientOrigin, name }, 0); 114 133 } 115 134 } -
branches/safari-613.2.7.1-branch/Source/WebKit/WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h
r293139 r293261 29 29 #include <WebCore/BroadcastChannelRegistry.h> 30 30 #include <WebCore/ClientOrigin.h> 31 #include <WebCore/PartitionedSecurityOrigin.h> 32 #include <WebCore/SecurityOrigin.h> 31 33 #include <wtf/HashMap.h> 32 34 #include <wtf/Vector.h> … … 49 51 } 50 52 51 void registerChannel(const WebCore:: ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;52 void unregisterChannel(const WebCore:: ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;53 void postMessage(const WebCore:: ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;53 void registerChannel(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final; 54 void unregisterChannel(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final; 55 void postMessage(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final; 54 56 55 57 void networkProcessCrashed(); … … 61 63 62 64 void postMessageToRemote(const WebCore::ClientOrigin&, const String& name, WebCore::MessageWithMessagePorts&&, CompletionHandler<void()>&&); 63 void postMessageLocally(const WebCore:: ClientOrigin&, const String& name, std::optional<WebCore::BroadcastChannelIdentifier> sourceInProcess, Ref<WebCore::SerializedScriptValue>&&, Ref<WTF::CallbackAggregator>&&);65 void postMessageLocally(const WebCore::PartitionedSecurityOrigin&, const String& name, std::optional<WebCore::BroadcastChannelIdentifier> sourceInProcess, Ref<WebCore::SerializedScriptValue>&&, Ref<WTF::CallbackAggregator>&&); 64 66 65 HashMap<WebCore:: ClientOrigin, HashMap<String, Vector<WebCore::BroadcastChannelIdentifier>>> m_channelsPerOrigin;67 HashMap<WebCore::PartitionedSecurityOrigin, HashMap<String, Vector<WebCore::BroadcastChannelIdentifier>>> m_channelsPerOrigin; 66 68 }; 67 69 -
branches/safari-613.2.7.1-branch/Source/WebKitLegacy/ChangeLog
r293139 r293261 1 2022-01-24 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r288389. rdar://problem/85405320 4 5 Disable CFURLCache in WebKit2 6 https://bugs.webkit.org/show_bug.cgi?id=234988 7 <rdar://problem/87619196> 1 2022-04-22 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r291589. rdar://problem/90511155 4 5 LayoutTests/imported/w3c: 6 BroadcastChannel instances in distinct opaque origins can communicate 7 https://bugs.webkit.org/show_bug.cgi?id=238090 8 <rdar://problem/90511155> 8 9 9 Reviewed by Geoffrey Garen. 10 Reviewed by Alex Christensen. 11 12 Import web-platform-tests test coverage. 13 14 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin-expected.txt: Added. 15 * web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html: Added. 16 * web-platform-tests/webmessaging/broadcastchannel/w3c-import.log: 17 18 Source/WebCore: 19 BroadcastChannel instances in distinct opaque origins can communicate 20 https://bugs.webkit.org/show_bug.cgi?id=238090 21 <rdar://problem/90511155> 22 23 Reviewed by Alex Christensen. 24 25 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 26 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 27 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 28 unique SecurityOrigins, they would compare as equal. 29 30 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 31 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 32 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 33 would not be equal but the same unique SecurityOrigin would be. I then used this new 34 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 35 ClientOrigin. This allows communication between several BroadcastChannels from the same 36 unique origin, while preventing communication between distinct opaque origins. 37 38 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 39 the Network Process at all since the destination can only be in the same WebProcess. 40 41 Test: imported/w3c/web-platform-tests/webmessaging/broadcastchannel/opaque-origin.html 42 43 * Headers.cmake: 44 * WebCore.xcodeproj/project.pbxproj: 45 * dom/BroadcastChannel.cpp: 46 (WebCore::shouldPartitionOrigin): 47 (WebCore::BroadcastChannel::MainThreadBridge::registerChannel): 48 (WebCore::BroadcastChannel::MainThreadBridge::unregisterChannel): 49 (WebCore::BroadcastChannel::MainThreadBridge::postMessage): 50 * dom/BroadcastChannelRegistry.h: 51 * loader/EmptyClients.cpp: 52 * page/PartitionedSecurityOrigin.h: Added. 53 (WebCore::PartitionedSecurityOrigin::PartitionedSecurityOrigin): 54 (WebCore::PartitionedSecurityOrigin::isHashTableDeletedValue const): 55 (WebCore::PartitionedSecurityOrigin::isHashTableEmptyValue const): 56 (WebCore::operator==): 57 (WTF::add): 58 (WTF::PartitionedSecurityOriginHash::hash): 59 (WTF::PartitionedSecurityOriginHash::equal): 60 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::emptyValue): 61 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::constructEmptyValue): 62 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::isEmptyValue): 63 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::peek): 64 (WTF::HashTraits<WebCore::PartitionedSecurityOrigin>::take): 65 66 Source/WebKit: 67 BroadcastChannel instances in distinct opaque origins can communicate 68 https://bugs.webkit.org/show_bug.cgi?id=238090 69 <rdar://problem/90511155> 70 71 Reviewed by Alex Christensen. 72 73 The issue is that we would use a ClientOrigin to distinguish origins for BroadcastChannel, 74 which relies on SecurityOriginData internally. A unique/opaque SecurityOrigin becomes an empty 75 SecurityOriginData upon conversion. As a result, when comparing ClientOrigin objects from 76 unique SecurityOrigins, they would compare as equal. 77 78 To address the issue, I introduced a new PartitionedSecurityOrigin type which is similar 79 to ClientOrigin but stores SecurityOrigin objects internally, instead of SecurityOriginData 80 objects. PartitionedSecurityOrigin's operator==() is such that different SecurityOrigins 81 would not be equal but the same unique SecurityOrigin would be. I then used this new 82 PartitionedSecurityOrigin type as key in our HashMap on the WebProcess side instead of 83 ClientOrigin. This allows communication between several BroadcastChannels from the same 84 unique origin, while preventing communication between distinct opaque origins. 85 86 When the PartitionedSecurityOrigin contains an opaque security origin, we don't involve 87 the Network Process at all since the destination can only be in the same WebProcess. 88 89 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.cpp: 90 (WebKit::toClientOrigin): 91 (WebKit::WebBroadcastChannelRegistry::registerChannel): 92 (WebKit::WebBroadcastChannelRegistry::unregisterChannel): 93 (WebKit::WebBroadcastChannelRegistry::postMessage): 94 (WebKit::WebBroadcastChannelRegistry::postMessageLocally): 95 (WebKit::WebBroadcastChannelRegistry::postMessageToRemote): 96 (WebKit::WebBroadcastChannelRegistry::networkProcessCrashed): 97 * WebProcess/WebCoreSupport/WebBroadcastChannelRegistry.h: 98 99 Source/WebKitLegacy: 100 Dust off Mac CMake build 101 https://bugs.webkit.org/show_bug.cgi?id=238121 102 103 Reviewed by Yusuke Suzuki. 104 105 * PlatformMac.cmake: 106 107 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@291589 268f45cc-cd09-0410-ab3c-d52691b4dbfc 108 109 2022-01-24 Alan Coon <alancoon@apple.com> 110 111 Cherry-pick r288389. rdar://problem/85405320 112 113 Disable CFURLCache in WebKit2 114 https://bugs.webkit.org/show_bug.cgi?id=234988 115 <rdar://problem/87619196> 116 117 Reviewed by Geoffrey Garen. 118 2022-03-21 Chris Dumez <cdumez@apple.com> 119 120 BroadcastChannel instances in distinct opaque origins can communicate 121 https://bugs.webkit.org/show_bug.cgi?id=238090 122 <rdar://problem/90511155> 123 124 Reviewed by Alex Christensen. 125 126 * WebCoreSupport/WebBroadcastChannelRegistry.cpp: 127 (WebBroadcastChannelRegistry::registerChannel): 128 (WebBroadcastChannelRegistry::unregisterChannel): 129 (WebBroadcastChannelRegistry::postMessage): 130 * WebCoreSupport/WebBroadcastChannelRegistry.h: 131 10 132 11 133 Source/WebCore: -
branches/safari-613.2.7.1-branch/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.cpp
r293139 r293261 45 45 } 46 46 47 void WebBroadcastChannelRegistry::registerChannel(const WebCore:: ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)47 void WebBroadcastChannelRegistry::registerChannel(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier) 48 48 { 49 49 ASSERT(isMainThread()); … … 54 54 } 55 55 56 void WebBroadcastChannelRegistry::unregisterChannel(const WebCore:: ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier)56 void WebBroadcastChannelRegistry::unregisterChannel(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier identifier) 57 57 { 58 58 ASSERT(isMainThread()); … … 67 67 } 68 68 69 void WebBroadcastChannelRegistry::postMessage(const WebCore:: ClientOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler)69 void WebBroadcastChannelRegistry::postMessage(const WebCore::PartitionedSecurityOrigin& origin, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&& message, CompletionHandler<void()>&& completionHandler) 70 70 { 71 71 ASSERT(isMainThread()); -
branches/safari-613.2.7.1-branch/Source/WebKitLegacy/WebCoreSupport/WebBroadcastChannelRegistry.h
r293139 r293261 25 25 26 26 #include <WebCore/BroadcastChannelRegistry.h> 27 #include <WebCore/ ClientOrigin.h>27 #include <WebCore/PartitionedSecurityOrigin.h> 28 28 #include <wtf/Forward.h> 29 29 #include <wtf/WeakPtr.h> … … 35 35 static Ref<WebBroadcastChannelRegistry> getOrCreate(bool privateSession); 36 36 37 void registerChannel(const WebCore:: ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;38 void unregisterChannel(const WebCore:: ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final;39 void postMessage(const WebCore:: ClientOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final;37 void registerChannel(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final; 38 void unregisterChannel(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier) final; 39 void postMessage(const WebCore::PartitionedSecurityOrigin&, const String& name, WebCore::BroadcastChannelIdentifier source, Ref<WebCore::SerializedScriptValue>&&, CompletionHandler<void()>&&) final; 40 40 41 41 private: … … 43 43 44 44 using NameToChannelIdentifiersMap = HashMap<String, Vector<WebCore::BroadcastChannelIdentifier>>; 45 HashMap<WebCore:: ClientOrigin, NameToChannelIdentifiersMap> m_channels;45 HashMap<WebCore::PartitionedSecurityOrigin, NameToChannelIdentifiersMap> m_channels; 46 46 };
Note:
See TracChangeset
for help on using the changeset viewer.