Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5e7069877320611bed55e9cf6fbb8297f3f70146
      
https://github.com/WebKit/WebKit/commit/5e7069877320611bed55e9cf6fbb8297f3f70146
  Author: Kiara Rose <[email protected]>
  Date:   2025-06-23 (Mon, 23 Jun 2025)

  Changed paths:
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionController.h
    M Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPINamespace.mm

  Log Message:
  -----------
  Browser namespace is sometimes undefined in content scripts
https://bugs.webkit.org/show_bug.cgi?id=294769
rdar://152683413

Reviewed by Timothy Hatcher.

This bug was reproducing because the browser namespace was never added to the 
extension's content
world after the extension was granted access to a page was already loaded. To 
fix this, add a call to
`globalObjectIsAvailableForFrame` before any script is injected to ensure that 
the browser namespace
is added.

In addition, move the code for notifying the WebProcess that an extension was 
loaded to before we
inject content scripts. This way, when we make the call to 
`globalObjectIsAvailableForFrame`, the
WebProcess is aware of the extension and won't fail to add the browser 
namespace.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::load):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionControllerCocoa.mm:
(WebKit::WebExtensionController::load):
(WebKit::WebExtensionController::dispatchDidLoad):
* Source/WebKit/UIProcess/Extensions/WebExtensionController.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::willInjectUserScript):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPINamespace.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPINamespace, 
BrowserNamespaceIsAvailableInContentScripts)):
Added a new test. Verified the test fails without this change.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to