Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 86ddc7a7a759e3741432f7dac824120cb7de5e58
      
https://github.com/WebKit/WebKit/commit/86ddc7a7a759e3741432f7dac824120cb7de5e58
  Author: Brian Weinstein <[email protected]>
  Date:   2026-08-26 (Wed, 26 Aug 2026)

  Changed paths:
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/loader/DocumentLoader.cpp
    M Source/WebCore/platform/LegacySchemeRegistry.cpp
    M Source/WebCore/platform/LegacySchemeRegistry.h
    M Source/WebCore/workers/service/server/SWServer.cpp
    M Source/WebCore/workers/service/server/SWServerWorker.cpp
    M Source/WebKit/UIProcess/Extensions/WebExtensionMatchPattern.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIOffscreen.mm

  Log Message:
  -----------
  Extension background service worker can't find other extension pages using 
clients.matchAll
https://bugs.webkit.org/show_bug.cgi?id=322306
rdar://185462954

Reviewed by Youenn Fablet.

This PR allows custom extension schemes to be found as clients of the service 
worker if they are
from the same scheme/host.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIOffscreen.mm

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::updateServiceWorkerClientData): Don't return early if the 
scheme is in the list
of schemes allowed to be service worker clients.
* Source/WebCore/loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::matchRegistration): Ditto.
(WebCore::DocumentLoader::commitData): Ditto.
(WebCore::DocumentLoader::startLoadingMainResource): Main resources served by a 
URL scheme handler never create
a NetworkResourceLoader, so the fetch-interception path that normally assigns a 
controlling service worker
registration cannot run for them. Make sure that we register these.
* Source/WebCore/platform/LegacySchemeRegistry.cpp:
(WebCore::WTF_REQUIRES_LOCK):
(WebCore::LegacySchemeRegistry::registerURLSchemeAsAllowingServiceWorkerClients):
(WebCore::LegacySchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkerClients):
(WebCore::schemesAllowingServiceWorkerClients):
* Source/WebCore/platform/LegacySchemeRegistry.h:
* Source/WebCore/workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::origin const): Use the non-strict variant to match 
how clients are keyed.
SecurityOriginData::fromURL() consults 
LegacySchemeRegistry::schemeIsHandledBySchemeHandler(), which is only
populated in a web content process, so it would yield an opaque origin here for 
any non-special scheme served
by a URL scheme handler. This matches the code in validateClientOrigin.
could stall due to the completion handler not being called. This could have 
been a standalone PR, but the bug
was only brought forward from the rest of this change.
* Source/WebKit/UIProcess/Extensions/WebExtensionMatchPattern.cpp:
(WebKit::WebExtensionMatchPattern::registerCustomURLScheme): Add the custom 
scheme to the schemes for service
worker registration.
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIOffscreen.mm:
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, 
OffscreenDocumentVisibleToClientsMatchAll)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, 
OffscreenDocumentRemovedFromClientsMatchAllAfterClose)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, 
ClientsMatchAllUsedAsHasDocumentGuard)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, DocumentContentLoads)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, 
TabAndOffscreenDocumentVisibleToClientsMatchAll)):
* Source/WebCore/workers/service/server/SWServer.cpp:
(WebCore::SWServer::matchAll):

Canonical link: https://commits.webkit.org/319898@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to