Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9bcf5840ef6d317468b11e3e1730278920af91dc
https://github.com/WebKit/WebKit/commit/9bcf5840ef6d317468b11e3e1730278920af91dc
Author: Brian Weinstein <[email protected]>
Date: 2026-09-21 (Mon, 21 Sep 2026)
Changed paths:
M Source/WebCore/page/Page.cpp
M Source/WebCore/page/Page.h
M Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
M Source/WebCore/workers/service/context/ServiceWorkerThread.h
M Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionContext.mm
M Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionContextPrivate.h
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIRuntimeCocoa.mm
M Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIOffscreen.mm
Log Message:
-----------
Don't consider a Web Extension service worker as fully loaded until
registration has been completed
https://bugs.webkit.org/show_bug.cgi?id=324743
rdar://186304610
Reviewed by Timothy Hatcher.
When determining if a Web Extension service worker has finished loading and is
ready to receive messages,
make sure that the service worker registration has finished. Without this, it's
possible for the service
worker to not think it has any clients, breaking extension compatibility with
the offscreen API.
I'm not sure if polling is the best way to handle this, but this was successful
in my testing.
Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIOffscreen.mm
* Source/WebCore/page/Page.cpp:
(WebCore::Page::serviceWorkerThread const): Expose the service worker thread.
* Source/WebCore/page/Page.h:
* Source/WebCore/workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::finishedFiringActivateEvent): Expose whether or
not the thread has
finished activating.
* Source/WebCore/workers/service/context/ServiceWorkerThread.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionContext.mm:
(-[WKWebExtensionContext _unloadBackgroundContentForTesting]): Call into
WebExtensionContextCocoa.
* Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionContextPrivate.h:
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::unloadBackgroundContentForTesting): Unload the
background content.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIRuntimeCocoa.mm:
(WebKit::WebExtensionContextProxy::backgroundServiceWorkerIsStillActivating):
Determines if there is a service worker still activating.
(WebKit::WebExtensionContextProxy::internalDispatchRuntimeMessageEvent): Don't
dispatch the message until the background service worker is
active.
(WebKit::WebExtensionContextProxy::dispatchRuntimeMessageEventOnceBackgroundServiceWorkerIsActive):
Poll for the service worker
(WebKit::WebExtensionContextProxy::isBackgroundServiceWorkerStillActivating):
waiting to finish activation.
* Source/WebKit/WebProcess/Extensions/WebExtensionContextProxy.h:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIOffscreen.mm:
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen,
OffscreenDocumentImmediatelyVisibleToClientsMatchAllWhenWokenByTabMessage)):
Make sure
that the service worker has the offscreen page as a client when it has been
spun up from receiving a message.
Canonical link: https://commits.webkit.org/321556@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications