[webkit-changes] [WebKit/WebKit] 0ea5fe: Queue and fire API events for Web Extensions.
kiaraarose
noreply at github.com
Thu Dec 15 14:35:57 PST 2022
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0ea5fe052ea303c25413797a41e1523d3c3d30c8
https://github.com/WebKit/WebKit/commit/0ea5fe052ea303c25413797a41e1523d3c3d30c8
Author: Kiara Rose <kiara_rose at apple.com>
Date: 2022-12-15 (Thu, 15 Dec 2022)
Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIEventCocoa.mm
M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationEventCocoa.mm
Log Message:
-----------
Queue and fire API events for Web Extensions.
https://bugs.webkit.org/show_bug.cgi?id=249254
Reviewed by Timothy Hatcher.
This patch adds support for queuing and firing API events for web extensions.
Testing:
I added an event listener in the background page of a test extension, and with this code below,
I tested that the completion handler was successfully called.
EventListenerTypeSet set;
set.add(WebExtensionEventListenerType::ActionOnClicked);
fireEvents(set, makeBlockPtr([ protectedThis = Ref { *this }]() {
RELEASE_LOG(Extensions, "KIARA");
}));
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::loadBackgroundContentIfNecessary):
(WebKit::WebExtensionContext::scheduleBackgroundContentToUnload):
(WebKit::WebExtensionContext::queueStartupAndInstallEventsForExtensionIfNecessary):
Queue and fire event listeners.
(WebKit::WebExtensionContext::performTasksAfterBackgroundContentLoads):
(WebKit::WebExtensionContext::fireEvents):
Call the completion handler for persistent background pages. For non-persistent backgrounds, wake
up the background page and queue the listener to fire after the background is loaded.
(WebKit::WebExtensionContext::queueEventToFireAfterBackgroundContentLoads):
Add completion handler to queue of listeners to fires.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIEventCocoa.mm:
(WebKit::WebExtensionAPIEvent::addListener):
(WebKit::WebExtensionAPIEvent::removeListener):
Add the extension context identifier. Without this, we won't know which context this message is for.
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIWebNavigationEventCocoa.mm:
(WebKit::WebExtensionAPIWebNavigationEvent::addListener):
(WebKit::WebExtensionAPIWebNavigationEvent::removeListener):
Add the extension context identifier. Without this, we won't know which context this message is for.
Canonical link: https://commits.webkit.org/257958@main
More information about the webkit-changes
mailing list