[webkit-changes] [WebKit/WebKit] 001f6f: Registered scripts aren't injected when an extensi...

kiaraarose noreply at github.com
Thu Mar 28 16:36:19 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 001f6f0f95890b04ad8df89594174c8a25bccdf8
      https://github.com/WebKit/WebKit/commit/001f6f0f95890b04ad8df89594174c8a25bccdf8
  Author: Kiara Rose <kiara_rose at apple.com>
  Date:   2024-03-28 (Thu, 28 Mar 2024)

  Changed paths:
    M Source/WebKit/Shared/Extensions/_WKWebExtensionRegisteredScriptsSQLiteStore.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIScriptingCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionDynamicScriptsCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionDynamicScripts.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIScripting.mm

  Log Message:
  -----------
  Registered scripts aren't injected when an extension is reloaded
https://bugs.webkit.org/show_bug.cgi?id=266291
rdar://119561550

Reviewed by Brian Weinstein and Timothy Hatcher.

Remove injected content from registered scripts map when an extension unloads.
Without this, we won't inject the scripts when the extension reloads since
`WebExtensionContext::createInjectedContentForScripts()` will fail due to duplicate script IDs.

Also, update WebExtensionContext::injectedContents() to include registered scripts.
Without this, registered scripts will be removed and won't be re-injected in cases
where we call WebExtensionContext::updateInjectedContent().

* Source/WebKit/Shared/Extensions/_WKWebExtensionRegisteredScriptsSQLiteStore.mm:
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIScriptingCocoa.mm:
(WebKit::WebExtensionContext::scriptingRegisterContentScripts):
(WebKit::WebExtensionContext::scriptingUpdateRegisteredScripts):
(WebKit::WebExtensionContext::loadRegisteredContentScripts):
(WebKit::WebExtensionContext::createInjectedContentForScripts):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::unload):
(WebKit::WebExtensionContext::injectedContents):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionDynamicScriptsCocoa.mm:
(WebKit::WebExtensionDynamicScripts::WebExtensionRegisteredScript::WebExtensionRegisteredScript): Deleted.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionDynamicScripts.h:
(WebKit::WebExtensionDynamicScripts::WebExtensionRegisteredScript::updateInjectedContent):
(WebKit::WebExtensionDynamicScripts::WebExtensionRegisteredScript::injectedContent):
(WebKit::WebExtensionDynamicScripts::WebExtensionRegisteredScript::WebExtensionRegisteredScript):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIScripting.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPIScripting, RegisteredScriptIsInjectedAfterContextReloads)): Added.

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



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


More information about the webkit-changes mailing list