Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6815dd9b127c2197d355f3bd4427b37ed9be2cde
      
https://github.com/WebKit/WebKit/commit/6815dd9b127c2197d355f3bd4427b37ed9be2cde
  Author: Ari Young <[email protected]>
  Date:   2026-08-07 (Fri, 07 Aug 2026)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionContext.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionContextPrivate.h
    M 
Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionControllerDelegatePrivate.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionSidebar.h
    M Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionSidebar.mm
    M 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPISidebarCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionSidebarCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Source/WebKit/UIProcess/Extensions/WebExtensionSidebar.h
    M 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPISidePanelCocoa.mm
    M Tools/TestWebKitAPI/Helpers/cocoa/TestWebExtensionsDelegate.h
    M Tools/TestWebKitAPI/Helpers/cocoa/TestWebExtensionsDelegate.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPISidebar.mm

  Log Message:
  -----------
  Web Extensions sidebar is rendered per-tab instead of per-window, even in the 
absence of tab-specific sidebars
rdar://182752551
https://bugs.webkit.org/show_bug.cgi?id=321128

Reviewed by Timothy Hatcher.

The sidebar pane was rendered per tab rather than per window: every tab was 
given its own
sidebar object and its own WKWebView, even when the extension had set nothing 
specific to that
tab. Switching between such tabs tore down one sidebar and built an identical 
one instead of
leaving the window's sidebar in place, and changes made at the window (or 
global) tier were not
reflected on the tabs that inherited them.

Make each window own a single sidebar whose WKWebView is shared by every tab 
that sets no panel
of its own; a tab gets its own sidebar and web view only while it overrides its 
own panel path.
sidebarForTab: hands back that shared object for every non-overriding tab, so 
the browser can
compare successive results by identity to decide whether the displayed sidebar 
must change on a
tab switch. A tab sidebar is discarded once it stops overriding anything, and 
the browser is told
to drop it through the new didInvalidateSidebar: delegate method.

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

* Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionContext.mm:
(-[WKWebExtensionContext sidebarForTab:]):
    Resolve through the shared per-window sidebar rather than creating a 
tab-specific one.
* Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionContextPrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionControllerDelegatePrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionSidebar.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionSidebar.mm:
(-[_WKWebExtensionSidebar title]):
(-[_WKWebExtensionSidebar viewController]):
(-[_WKWebExtensionSidebar webView]):
(-[_WKWebExtensionSidebar willOpenSidebarFromUserInteraction:]):
(-[_WKWebExtensionSidebar associatedWindow]):
    The sidebar's window, or its tab's window for a tab-specific sidebar.
(-[_WKWebExtensionSidebar willOpenSidebar]): Deleted.
* 
Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPISidebarCocoa.mm:
(WebKit::WebExtensionContext::notifyDelegateOfSidebarUpdate):
(WebKit::WebExtensionContext::notifyDelegateOfSidebarInvalidation):
(WebKit::WebExtensionContext::sidebarOpen):
    Resolve the tab directly; creating a sidebar here would defeat per-window 
sharing.
(WebKit::WebExtensionContext::sidebarClose):
(WebKit::WebExtensionContext::sidebarIsOpen):
(WebKit::WebExtensionContext::sidebarToggle):
    Reject when no panel is set.
(WebKit::WebExtensionContext::sidebarSetTitle):
(WebKit::WebExtensionContext::sidebarGetOptions):
    Use the non-creating resolver so a query never materializes a tab sidebar.
(WebKit::WebExtensionContext::sidebarSetOptions):
    Apply path and enablement together so one call notifies the browser at most 
once.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::unload):
    Clear the sidebar maps, which were never cleared, leaking sidebars and web 
views across reloads.
(WebKit::WebExtensionContext::getCurrentTab const):
(WebKit::WebExtensionContext::didMoveTab):
(WebKit::WebExtensionContext::performAction):
(WebKit::WebExtensionContext::sidebarForTab):
(WebKit::WebExtensionContext::addSidebarPage):
(WebKit::WebExtensionContext::discardSidebarIfUnmodified):
    Drop a tab sidebar which overrides nothing, unlink it, and notify the 
delegate it is invalidated.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionSidebarCocoa.mm:
(-[_WKWebExtensionSidebarWebViewDelegate 
webView:decidePolicyForNavigationAction:decisionHandler:]):
(WebKit::WebExtensionSidebar::hasOverriddenProperties const):
(WebKit::WebExtensionSidebar::parent const):
    Create the window sidebar when resolving a tab's parent, so it inherits 
from its window rather
    than falling through to the global sidebar.
(WebKit::WebExtensionSidebar::propertiesDidChange):
    Report this sidebar to the delegate as well as its children, so a 
parent-tier change reaches
    the tabs that inherit it.
(WebKit::WebExtensionSidebar::setIconsDictionary):
    Notify when an icon override is cleared, not only when one is set.
(WebKit::WebExtensionSidebar::setOptions):
    Replaces setSidebarPath/setEnabled: mutate both, tear down a demoted tab's 
web view, reload the
    shared web views, and notify at most once.
(WebKit::WebExtensionSidebar::willOpenSidebar):
    Grant activeTab only for a user-initiated open, so an extension cannot 
grant itself the
    permission by changing a tab's sidebar.
(WebKit::WebExtensionSidebar::willCloseSidebar):
(WebKit::WebExtensionSidebar::didReceiveUserInteraction):
(WebKit::WebExtensionSidebar::viewController):
(WebKit::WebExtensionSidebar::webView):
(WebKit::WebExtensionSidebar::parentPropertiesWereUpdated):
(WebKit::WebExtensionSidebar::notifyChildrenOfPropertyUpdate):
(WebKit::WebExtensionSidebar::notifyDelegateOfPropertyUpdate):
(WebKit::WebExtensionSidebar::reloadDescendantWebViews):
(WebKit::WebExtensionSidebar::setEnabled): Deleted.
(WebKit::WebExtensionSidebar::setSidebarPath): Deleted.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionSidebar.h:
* 
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPISidePanelCocoa.mm:
(WebKit::WebExtensionAPISidePanel::setOptions):
    Reject a call that sets neither path nor enabled, and forward each only 
when the caller supplied it.
(WebKit::deserializeSidebarParameters): Deleted.
* Tools/TestWebKitAPI/Helpers/cocoa/TestWebExtensionsDelegate.h:
* Tools/TestWebKitAPI/Helpers/cocoa/TestWebExtensionsDelegate.mm:
(-[TestWebExtensionsDelegate 
_webExtensionController:didInvalidateSidebar:forExtensionContext:]):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebExtensionAPISidebar.mm:
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
SidebarActionOpenSucceedsWithUserGesture)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
SidebarActionCloseSucceedsWithUserGesture)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
SidePanelOpenForTabSucceedsWithUserGesture)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
SidePanelOpenForWindowSucceedsWithUserGesture)):
    These four now assert associatedWindow rather than associatedTab, since a 
tab that overrides
    nothing is shown its window's sidebar.
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
TabsWithoutOverridesShareTheirWindowSidebar)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
DidInvalidateSidebarFiresWhenLastOverrideCleared)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
WillOpenSidebarWithoutUserInteractionDoesNotStartUserGesture)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
SidePanelSetOptionsRequiresPathOrEnabled)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
TabPanelOverrideSwapsWebViewAndRestoresIt)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
WindowPanelChangeReloadsSharedWebViewInPlace)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
ParentTitleChangeNotifiesInheritingTabSidebar)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
SetOptionsNotifiesDelegateAtMostOnce)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPISidebar, 
TabSidebarRelinksToNewWindowOnMove)):

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



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

Reply via email to