[webkit-changes] [WebKit/WebKit] e82bb6: Temporary extension resources are not deleted when...

Timothy Hatcher noreply at github.com
Mon Jan 13 16:32:18 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e82bb6d82140825672ab1494b74ca8467f854dd8
      https://github.com/WebKit/WebKit/commit/e82bb6d82140825672ab1494b74ca8467f854dd8
  Author: Timothy Hatcher <timothy at apple.com>
  Date:   2025-01-13 (Mon, 13 Jan 2025)

  Changed paths:
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtension.cpp
    M Source/WebKit/UIProcess/Extensions/WebExtension.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIRuntime.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIScripting.mm
    M Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h
    M Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm

  Log Message:
  -----------
  Temporary extension resources are not deleted when it is unloaded.
https://webkit.org/b/285871
rdar://142834398

Reviewed by Brian Weinstein.

Delete the extension resources in ~WebExtension if they were extracted from a Zip archive
into a temporary directory.

Changed the test manager to unload extension contexts on dealloc, so the cleanup code paths get
exercised in testing. This uncovered a case where the extension can load and unload so quickly,
the background page loading completions handlers waiting for wakeup don't have time to be called,
so they hit the uncalled assertion. Changing these to Function fixes this, since they are not
guaranteed to be called.

Moved the Zip file code to the cross-platform WebExtension file, since it is not Cocoa specific.

* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm:
(WebKit::WebExtension::WebExtension):
(WebKit::convertChromeExtensionToTemporaryZipFile): Deleted.
(WebKit::processFileAndExtractZipArchive): Deleted.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::wakeUpBackgroundContentIfNecessary): Use Function.
(WebKit::WebExtensionContext::wakeUpBackgroundContentIfNecessaryToFireEvents): Ditto.
* Source/WebKit/UIProcess/Extensions/WebExtension.cpp:
(WebKit::WebExtension::~WebExtension): Added. Delete temp resources.
(WebKit::convertChromeExtensionToTemporaryZipFile): Added.
(WebKit::WebExtension::processFileAndExtractZipArchive): Added.
* Source/WebKit/UIProcess/Extensions/WebExtension.h:
(WebKit::WebExtension::~WebExtension): Deleted.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIDeclarativeNetRequest.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPIDeclarativeNetRequest, DynamicRules)): Use unload on the manager.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIRuntime.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPIRuntime, StartupEvent)): Ditto.
(TestWebKitAPI::TEST(WKWebExtensionAPIRuntime, InstalledEvent)): Ditto.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIScripting.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPIScripting, RegisteredScriptIsInjectedAfterContextReloads)): Ditto.
* Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.h:
* Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm:
(-[TestWebExtensionManager dealloc]): Added.
(-[TestWebExtensionManager unload]): Added.

Canonical link: https://commits.webkit.org/288826@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