[webkit-changes] [WebKit/WebKit] 84aa82: Web Extension ports can not receive messages in co...
Timothy Hatcher
noreply at github.com
Fri Aug 30 18:43:44 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 84aa82da3f5b983644fffa16a3483d69ef872bc0
https://github.com/WebKit/WebKit/commit/84aa82da3f5b983644fffa16a3483d69ef872bc0
Author: Timothy Hatcher <timothy at apple.com>
Date: 2024-08-30 (Fri, 30 Aug 2024)
Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIPortCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIRuntimeCocoa.mm
M Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIRuntime.mm
Log Message:
-----------
Web Extension ports can not receive messages in content scripts.
https://webkit.org/b/278817
rdar://133501214
Reviewed by Brian Weinstein and Jeff Miller.
When sending the queued message we were sending them to the wrong process,
since `fireQueuedPortMessageEventsIfNeeded()` was being passed in a process
and not using the same delivery logic as `portPostMessage()`.
Factor the code to send the message event out of `portPostMessage()` into a new
`firePortMessageEventsIfNeeded()` method and use that in both places. We also need
call it for both target and source world types, since messages can queue for both.
This impacted content script or web page externally connectable, since the worlds
are different, as compared to main world to main world connections.
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIPortCocoa.mm:
(WebKit::WebExtensionContext::portPostMessage): Use firePortMessageEventsIfNeeded.
(WebKit::WebExtensionContext::firePortMessageEventsIfNeeded): Added.
(WebKit::WebExtensionContext::fireQueuedPortMessageEventsIfNeeded): Use firePortMessageEventsIfNeeded.
(WebKit::WebExtensionContext::clearQueuedPortMessages): Added logging.
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIRuntimeCocoa.mm:
(WebKit::WebExtensionContext::runtimeConnect): Call fireQueuedPortMessageEventsIfNeeded and
clearQueuedPortMessages for both worlds.
(WebKit::WebExtensionContext::runtimeWebPageConnect): Ditto.
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm:
(WebKit::WebExtensionContext::tabsConnect): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIRuntime.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPIRuntime, ConnectFromContentScriptWithImmediateMessage)): Added.
(TestWebKitAPI::TEST(WKWebExtensionAPIRuntime, ConnectFromWebPageWithImmediateMessage)): Added.
Canonical link: https://commits.webkit.org/283006@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list