Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tabs.update to be called without a tabID #24964

Conversation

b-weinstein
Copy link
Contributor

@b-weinstein b-weinstein commented Feb 22, 2024

5e245ad

Allow tabs.update to be called without a tabID
https://bugs.webkit.org/show_bug.cgi?id=269934
rdar://123407828

Reviewed by Timothy Hatcher.

The tabID is an optional argument to tabs.update. We were always attempting to get the value of the optional.

If it isn't passed, then it is meant to fall back to the active tab of the current context, which means:
- If this was called from a popup, then the active tab of the popup's window
- If this was called from the background page, then the active tab of the active window

This required some refactoring to WebExtensionContext::getTab and WebExtensionContext::getCurrentTab to support this,
and some tests were added calling this method without a tab ID from both contexts.

* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm:
(WebKit::WebExtensionContext::tabsUpdate):
(WebKit::WebExtensionContext::tabsReload):
(WebKit::WebExtensionContext::tabsGoBack):
(WebKit::WebExtensionContext::tabsGoForward):
(WebKit::WebExtensionContext::tabsDetectLanguage):
(WebKit::WebExtensionContext::tabsToggleReaderMode):
(WebKit::WebExtensionContext::tabsGetZoom):
(WebKit::WebExtensionContext::tabsSetZoom):
(WebKit::WebExtensionContext::tabsExecuteScript):
(WebKit::WebExtensionContext::tabsInsertCSS):
(WebKit::WebExtensionContext::tabsRemoveCSS):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::getWindow const):
(WebKit::WebExtensionContext::getTab const):
(WebKit::WebExtensionContext::getCurrentTab const):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm:
(WebKit::WebExtensionAPITabs::update):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAction.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm:
(TestWebKitAPI::TEST):

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

665c4c3

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe   πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug   πŸ§ͺ wpe-wk2
  πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac   πŸ§ͺ api-wpe
  πŸ§ͺ ios-wk2-wpt   πŸ§ͺ mac-wk1 βœ… πŸ›  gtk
  πŸ§ͺ api-ios   πŸ§ͺ mac-wk2   πŸ§ͺ gtk-wk2
  πŸ›  tv   πŸ§ͺ mac-AS-debug-wk2   πŸ§ͺ api-gtk
  πŸ›  tv-sim
  πŸ›  πŸ§ͺ merge   πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge   πŸ›  watch-sim

@b-weinstein b-weinstein self-assigned this Feb 22, 2024
@b-weinstein b-weinstein added the WebKit Extensions Bugs related to extension support. label Feb 22, 2024
@b-weinstein b-weinstein force-pushed the eng/Allow-tabs-update-to-be-called-without-a-tabID branch from 6206c06 to 181cd64 Compare February 22, 2024 21:51
@xeenon xeenon self-requested a review February 22, 2024 21:53
@b-weinstein b-weinstein added merge-queue Applied to send a pull request to merge-queue unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing and removed merge-queue Applied to send a pull request to merge-queue unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing labels Feb 22, 2024
@b-weinstein b-weinstein force-pushed the eng/Allow-tabs-update-to-be-called-without-a-tabID branch from 181cd64 to 665c4c3 Compare February 22, 2024 23:09
@b-weinstein b-weinstein added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Feb 22, 2024
https://bugs.webkit.org/show_bug.cgi?id=269934
rdar://123407828

Reviewed by Timothy Hatcher.

The tabID is an optional argument to tabs.update. We were always attempting to get the value of the optional.

If it isn't passed, then it is meant to fall back to the active tab of the current context, which means:
- If this was called from a popup, then the active tab of the popup's window
- If this was called from the background page, then the active tab of the active window

This required some refactoring to WebExtensionContext::getTab and WebExtensionContext::getCurrentTab to support this,
and some tests were added calling this method without a tab ID from both contexts.

* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPITabsCocoa.mm:
(WebKit::WebExtensionContext::tabsUpdate):
(WebKit::WebExtensionContext::tabsReload):
(WebKit::WebExtensionContext::tabsGoBack):
(WebKit::WebExtensionContext::tabsGoForward):
(WebKit::WebExtensionContext::tabsDetectLanguage):
(WebKit::WebExtensionContext::tabsToggleReaderMode):
(WebKit::WebExtensionContext::tabsGetZoom):
(WebKit::WebExtensionContext::tabsSetZoom):
(WebKit::WebExtensionContext::tabsExecuteScript):
(WebKit::WebExtensionContext::tabsInsertCSS):
(WebKit::WebExtensionContext::tabsRemoveCSS):
* Source/WebKit/UIProcess/Extensions/Cocoa/WebExtensionContextCocoa.mm:
(WebKit::WebExtensionContext::getWindow const):
(WebKit::WebExtensionContext::getTab const):
(WebKit::WebExtensionContext::getCurrentTab const):
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.h:
* Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm:
(WebKit::WebExtensionAPITabs::update):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIAction.mm:
(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPITabs.mm:
(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/275204@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Allow-tabs-update-to-be-called-without-a-tabID branch from 665c4c3 to 5e245ad Compare February 22, 2024 23:13
@webkit-commit-queue
Copy link
Collaborator

Committed 275204@main (5e245ad): https://commits.webkit.org/275204@main

Reviewed commits have been landed. Closing PR #24964 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 5e245ad into WebKit:main Feb 22, 2024
@webkit-commit-queue webkit-commit-queue removed merge-queue Applied to send a pull request to merge-queue unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing labels Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit Extensions Bugs related to extension support.
Projects
None yet
4 participants