Proposal: improve tabs.query
API when unexpected property is used
#769
Labels
needs-triage: chrome
Chrome needs to assess this issue for the first time
needs-triage: firefox
Firefox needs to assess this issue for the first time
needs-triage: safari
Safari needs to assess this issue for the first time
Motivation
Querying tabs is useful and resource friendly, but most of the time I end up querying everything, and then filtering the result manually:
Why?
Uncaught TypeError: Error in invocation of tabs.query(object queryInfo, function callback): Error at parameter 'queryInfo': Unexpected property: 'hidden'.
The issue is that many fields are browser/platform/version specific. And they will throw when used!
For example:
hidden
fails in ChromiumautoDiscardable
fails in Firefox for Androidfrozen
fails in Firefox or in Chrome 131 and lowerThis makes cross-browser development quite challenging and
tabs.query
looses it's usefulness.Solutions
This is a bit harder than I thought, so let's brainstorm some ideas.
Solution 1 - ignore unexpected properties
Instead of an exception, it would only log a warning to the console.
Problem:
If the query is asking for the "special" fields only, it would wrongly return all tabs:
Solution 2 - define unexpected behavior
Similarly to
ORDER BY ... NULLS LAST
in SQL, we could add an extra parameter to the query call, which would define what to do when unexpected field is found:Problem:
This would be sufficient only in simple cases, but combining problematic fields would cause issues:
What we really want in this case is "empty" for
frozen
and "ignore" forhidden
.Solution 3 - define unexpected behavior for each property
We could use the fact that none of the existing properties values is an
object
yet (we have boolean, string, string[], integer).Example:
Problem:
Verbose?
The text was updated successfully, but these errors were encountered: