Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 711c65b3c4355df906853568aa45dcf52bc5d705
https://github.com/WebKit/WebKit/commit/711c65b3c4355df906853568aa45dcf52bc5d705
Author: Elijah Sawyers <[email protected]>
Date: 2026-09-16 (Wed, 16 Sep 2026)
Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIWebRequest.mm
Log Message:
-----------
webRequest events never fire for subframes loaded inside an action popup
https://bugs.webkit.org/show_bug.cgi?id=30482
rdar://167403221
Reviewed by Brian Weinstein and Timothy Hatcher.
This patch fixes webRequest events (onBeforeRequest and the related events)
never firing for resource loads that originate inside an extension's own web
views: action popups, the background page, sidebars, offscreen documents, and
inspector pages.
These views run in their own web views and, unlike a browser tab, most are not
associated with one. Every webRequest dispatcher resolved the originating page
with getTab(pageID), which returns null for them, so
hasPermissionToSendWebRequestEvent bailed out at its leading null-tab check and
the events were dropped in the UI process before ever reaching the extension's
listeners.
Detect extension-originated loads with a new isExtensionPage() predicate.
Requests from an extension page with no associated tab are reported with a none
tab identifier (tabId -1); requests from an extension page that does have a tab
(such as an options page) report that tab. Either way the tab-based document
permission check is skipped, since the extension implicitly controls its own
pages. The webRequest permission and the host permission for the request URL
are still required.
The shared resolution, permission check, and tab/window identifier derivation
that every webRequest dispatcher repeated is factored into a single
webRequestEventTabAndWindowIdentifiers() helper.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::hasPermissionToSendWebRequestEvent):
(WebKit::WebExtensionContext::webRequestEventTabAndWindowIdentifiers):
(WebKit::WebExtensionContext::resourceLoadDidSendRequest):
(WebKit::WebExtensionContext::resourceLoadDidPerformHTTPRedirection):
(WebKit::WebExtensionContext::resourceLoadDidReceiveChallenge):
(WebKit::WebExtensionContext::resourceLoadDidReceiveResponse):
(WebKit::WebExtensionContext::resourceLoadDidCompleteWithError):
(WebKit::WebExtensionContext::resourceLoadWasBlockedByDeclarativeNetRequest):
(WebKit::WebExtensionContext::isExtensionPage):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIWebRequest.mm:
(TestWebKitAPI::configurationEnablingFeature): Added.
(TestWebKitAPI::BeforeRequestEventForActionPopupSubframe): Added test.
(TestWebKitAPI::BeforeRequestEventForBackgroundPageRequest): Added test.
(TestWebKitAPI::BeforeRequestEventForSidebarSubframe): Added test.
(TestWebKitAPI::BeforeRequestEventForOffscreenDocumentSubframe): Added test.
Canonical link: https://commits.webkit.org/321290@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications