You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 undertabs
are async and inherently racy. For example, the background may get a message from content script, calltabs.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 thetabs.query()
being called).Proposal
Extend
tabs.query(queryInfo: QueryInfo, callback)
argumentQueryInfo
(Chrome docs, MDN) to take optionaldocumentId
argument.If developer specifies
documentId
, browser returns only the tab which currently hosts the corresponding document. If the provideddocumentId
has invalid format, then an error is returned. If provideddocumentId
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 viastorage.sync
or something like this). If the provideddocumentId
corresponds to a sub-frame or a top-level frame currently sitting in BFCache, then nothing is returned to match existing behavior.Relevant links
The text was updated successfully, but these errors were encountered: