Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9936ea82683e58a49ade3958b0352782bbd01bcc
https://github.com/WebKit/WebKit/commit/9936ea82683e58a49ade3958b0352782bbd01bcc
Author: Elijah Sawyers <[email protected]>
Date: 2025-01-21 (Tue, 21 Jan 2025)
Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIEventCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITestCocoa.mm
M Source/WebKit/WebProcess/Extensions/Cocoa/WebExtensionContextProxyCocoa.mm
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.cpp
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITest.mm
Log Message:
-----------
Send browser.test messages to all extension content world types
https://bugs.webkit.org/show_bug.cgi?id=286158
rdar://143142956
Reviewed by Timothy Hatcher.
This patch fixes a bug where browser.test.onMessage event listeners never
received events in web pages or content scripts. This was happening because
browser.test messages were only being sent to the main world.
We can fix this by sending the messages to all extension content world types.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::sendTestMessage):
Send test messages to main, web page, and content script extension content
world types.
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIEventCocoa.mm:
(WebKit::WebExtensionAPIEvent::addListener):
(WebKit::WebExtensionAPIEvent::removeListener):
(WebKit::WebExtensionAPIEvent::removeAllListeners):
Don't bail out early if we don't have an extension context (i.e. web page)
and we're in test mode. In this case, add the listener to all extension
contexts (and add the frame to the extension context).
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITestCocoa.mm:
(WebKit::WebExtensionContextProxy::dispatchTestMessageEvent):
Enumerate the web page namespace objects if the content world type is web page.
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.cpp:
(WebKit::WebExtensionContextProxy::enumerateFramesAndWebPageNamespaceObjects):
Introduce a new method to enumerate web page namespace object.
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.messages.in:
Send the content world type when sending a test message.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITest.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPITest, MessageEventInWebPage)):
(TestWebKitAPI::TEST(WKWebExtensionAPITest, MessageEventInContentScript)):
Write new API tests.
Canonical link: https://commits.webkit.org/289222@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes