Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1efe7e2360c84d4f08a75df6e33010839fb5e3f7
      
https://github.com/WebKit/WebKit/commit/1efe7e2360c84d4f08a75df6e33010839fb5e3f7
  Author: Brian Weinstein <[email protected]>
  Date:   2026-08-11 (Tue, 11 Aug 2026)

  Changed paths:
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIOffscreenCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIOffscreen.mm

  Log Message:
  -----------
  Manage an offscreen web view when implementing the browser.offscreen 
extension API
https://bugs.webkit.org/show_bug.cgi?id=321513
rdar://184269255

Reviewed by Kiara Rose.

This PR does a lot of hooking up the actual offscreen WKWebView with the 
offscreen extension API.

When an offscreen document is created, the corresponding web view is 
instantiated (if one doesn't exist already). One
behavior to note is that the promise isn't fulfilled until the page has 
finished loading. This matches Chrome and
allows messages dispatched immediately after awaiting the creation of the 
offscreen web view to be delivered successfully.

When an offscreen document is closed, the corresponding web view is unloaded 
(if it exists).

offscreen.hasDocument just checks for the presence of the offscreen web view 
ivar.

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

* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIOffscreenCocoa.mm:
(WebKit::WebExtensionContext::offscreenCreateDocument): Create a web view, and 
save the completion handler for when the load finishes.
(WebKit::WebExtensionContext::offscreenCloseDocument): Unload the web view and 
call the completion handler.
(WebKit::WebExtensionContext::offscreenHasDocument): Call the completion 
handler with the presence of the offscreen web view.
(WebKit::WebExtensionContext::unloadOffscreenWebView): Unloads the offscreen 
web view.
(WebKit::WebExtensionContext::performTasksAfterOffscreenContentLoads): Calls 
all the queued completion handlers.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(-[_WKWebExtensionContextDelegate 
webView:didFailProvisionalNavigation:withError:]): Forward this call to 
didFailNavigation.
(WebKit::WebExtensionContext::unload): Call unloadOffscreenWebView.
(WebKit::WebExtensionContext::decidePolicyForNavigationAction): Update for the 
offscreen web view.
(WebKit::WebExtensionContext::didFinishDocumentLoad): Ditto.
(WebKit::WebExtensionContext::didFailNavigation): Ditto.
(WebKit::WebExtensionContext::webViewWebContentProcessDidTerminate): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
(WebKit::WebExtensionContext::offscreenWebView const):
(WebKit::WebExtensionContext::isOffscreenWebView const):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPIOffscreen.mm:
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, CreateAndHasDocument)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, CreateDocumentFails)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, CreateDocumentTwiceFails)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, CloseDocument)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, 
CloseDocumentWithoutOneOpenFails)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, HasDocumentFalseByDefault)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, DocumentContentLoads)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIOffscreen, SendMessageToDocument)):

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



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

Reply via email to