[webkit-changes] [WebKit/WebKit] fe7e1f: Web Extension objects should return the same JS wr...

Timothy Hatcher noreply at github.com
Tue Apr 2 08:24:08 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: fe7e1f64e14ecf2830f1a88c03276cbf25821cbf
      https://github.com/WebKit/WebKit/commit/fe7e1f64e14ecf2830f1a88c03276cbf25821cbf
  Author: Timothy Hatcher <timothy at apple.com>
  Date:   2024-04-02 (Tue, 02 Apr 2024)

  Changed paths:
    M Source/WebKit/WebProcess/Extensions/Bindings/JSWebExtensionWrapper.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPINamespace.mm

  Log Message:
  -----------
  Web Extension objects should return the same JS wrapper (Bitwarden popup never loads).
https://webkit.org/b/272006
rdar://125633239

Reviewed by Brian Weinstein.

Make a cache per global context that we use to return the same wrapper for the JSWebExtensionWrappable
objects, that way equality checks in JavaScript will succeed.

This was breaking Bitwarden because they are doing a switch on the storage objects to get the
name, and since equality wasn't true, the switch would fail.

    switch (e) {
    case chrome.storage.local:
        return "local";
    case chrome.storage.sync:
        return "sync";
    case chrome.storage.session:
        return "session";
    default:
        throw new Error("Unknown storage location")
    }

* Source/WebKit/WebProcess/Extensions/Bindings/JSWebExtensionWrapper.cpp:
(WebKit::wrapperCache): Added.
(WebKit::cacheMapDestroyed): Added.
(WebKit::wrapperCacheMap): Added.
(WebKit::getCachedWrapper): Added.
(WebKit::JSWebExtensionWrapper::wrap): Lookup and add the wrapper to the cache.
(WebKit::JSWebExtensionWrapper::finalize): Set private to nullptr.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPINamespace.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPINamespace, ObjectEquality)):

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