[webkit-changes] [WebKit/WebKit] d0a686: Fire open and closed events when a tab is replaced.

Timothy Hatcher noreply at github.com
Wed May 29 14:40:48 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d0a6863b9a013dedac63c644883b0736f5d5dd63
      https://github.com/WebKit/WebKit/commit/d0a6863b9a013dedac63c644883b0736f5d5dd63
  Author: Timothy Hatcher <timothy at apple.com>
  Date:   2024-05-29 (Wed, 29 May 2024)

  Changed paths:
    M Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIRuntimeCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm
    M Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionTabCocoa.mm
    M Source/WebKit/UIProcess/Extensions/WebExtensionContext.h
    M Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm
    M Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm

  Log Message:
  -----------
  Fire open and closed events when a tab is replaced.
https://webkit.org/b/274794
rdar://123344546

Reviewed by Brian Weinstein.

Fire the onCreated and onRemoved events when tabs are replaced. Also return errors
where an extension messages a tab that does not exist to prevent more confusing errors
later when tab properties are missing, etc. Also make sure to always include the windowId
and index properties on the tab object, even if they are -1 and NaN.

* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIRuntimeCocoa.mm:
(WebKit::WebExtensionContext::runtimeSendMessage): Added error if tab is not found.
(WebKit::WebExtensionContext::runtimeConnect): Ditto.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::didCloseTab): Call forgetTab if the tab is already closed.
(WebKit::WebExtensionContext::didReplaceTab): Fire open and closed events.
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionTabCocoa.mm:
(WebKit::WebExtensionTab::parameters const): Always include window and index.
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm:
(WebKit::toWebAPI): Use toWebAPI for the index of notFound is returned as NaN.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm:
(TestWebKitAPI::TEST(WKWebExtensionAPITabs, ReplacedEvent)): Added.
* Tools/TestWebKitAPI/cocoa/WebExtensionUtilities.mm:
(-[TestWebExtensionWindow replaceTab:withTab:]): Swap activeTab if it was active.

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