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

Proposal: filter by documentId in tabs.query() #553

Open
bershanskiy opened this issue Feb 25, 2024 · 0 comments
Open

Proposal: filter by documentId in tabs.query() #553

bershanskiy opened this issue Feb 25, 2024 · 0 comments
Labels
enhancement Enhancement or change to an existing feature

Comments

@bershanskiy
Copy link
Member

bershanskiy commented Feb 25, 2024

Background

tabs.query() is not currently aware of tabs being navigated and moved around, so there is very little information to refer to the same document. Luckily, most use cases require querying info about the active tab, which happens to be the default behavior for this API. Unfortunately, some use cases require querying info about non-active tabs. Currently, the best way to match a document belonging to an inactive tab is to refer to its coincidental mutable non-unique attributes like its location (window id and an index on tab strip), its URL or title, which are problematic from privacy perspective.

Problem

tabs.query() and other APIs under tabs are async and inherently racy. For example, the background may get a message from content script, call tabs.query() to get more information about the sender and receive a response containing information about a different document (because the tab may navigate between the message being sent and the tabs.query() being called).

Proposal

Extend tabs.query(queryInfo: QueryInfo, callback)argument QueryInfo (Chrome docs, MDN) to take optional documentId argument.

If developer specifies documentId, browser returns only the tab which currently hosts the corresponding document. If the provided documentId has invalid format, then an error is returned. If provided documentId is semantically valid, but browser is not aware of a document with this id, then nothing is matched so an empty array is returned (since this may be an id from an older browser session, tab open on a different device and synced via storage.sync or something like this). If the provided documentId corresponds to a sub-frame or a top-level frame currently sitting in BFCache, then nothing is returned to match existing behavior.

Relevant links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or change to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants