Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7acdcf23cf0c0b6631a83a3a32911122766fe9a4
https://github.com/WebKit/WebKit/commit/7acdcf23cf0c0b6631a83a3a32911122766fe9a4
Author: Elijah Sawyers <[email protected]>
Date: 2026-09-03 (Thu, 03 Sep 2026)
Changed paths:
M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
M Tools/TestWebKitAPI/Helpers/cocoa/WebExtensionUtilities.h
M Tools/TestWebKitAPI/Helpers/cocoa/WebExtensionUtilities.mm
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIWebRequest.mm
Log Message:
-----------
webRequest events not firing with tabs.create
https://bugs.webkit.org/show_bug.cgi?id=315367
rdar://177727052
Reviewed by Timothy Hatcher and Kiara Rose.
This patch makes a Safari Web Extension's webRequest events fire for the
initial main-frame
navigation of a tab or window created with browser.tabs.create or
browser.windows.create.
hasPermissionToSendWebRequestEvent required the extension to have host access
to the tab's
committed document URL. A newly created tab whose main-frame navigation has not
committed yet
has no committed URL, so the check failed and every webRequest event for the
initial load was
dropped. Reloading or navigating from the address bar worked because the tab
already had a
committed URL by then.
The committed document is only the relevant page for subresource and subframe
loads. For a
top-level navigation the request is the document itself, and it is already
covered by the
per-request host permission checks, so this patch skips the committed-document
check for
main-frame navigations.
The test harness reports a tab's URL as its web view's URL, which during a
navigation is the
provisional destination rather than the empty committed URL a new tab has, so
it could not
reproduce this on its own. TestWebExtensionTab gains an overrideURL so a test
can report a
document URL the extension cannot access.
Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIWebRequest.mm
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::hasPermissionToSendWebRequestEvent):
* Tools/TestWebKitAPI/Helpers/cocoa/WebExtensionUtilities.h:
* Tools/TestWebKitAPI/Helpers/cocoa/WebExtensionUtilities.mm:
(-[TestWebExtensionTab urlForWebExtensionContext:]):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIWebRequest.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPIWebRequest,
WebRequestFiresForTabsCreate)):
(TestWebKitAPI::TEST(WKWebExtensionAPIWebRequest,
WebRequestFiresForWindowsCreate)):
Canonical link: https://commits.webkit.org/320430@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications