Possible bug tabs query with empty array

180 views
Skip to first unread message

Edu

unread,
Aug 7, 2024, 9:11:37 AMAug 7
to Chromium Extensions
When creating a tabs query using an empty array for the `url` param in the `queryInfo` object, it actually matches all tabs, rather than none, which is unexpected.

The usecase is constructing an array of target URLs against which to match. Would expect that if none match (even if because the array is empty), then none are returned. However, all tabs are currently returned when the array is empty.

Is this a bug?

Patrick Kettner

unread,
Aug 7, 2024, 9:18:33 AMAug 7
to Edu, Chromium Extensions
Hello!
No this is the expected behavior. You are querying all tabs, and filtering by the context you are providing. If you are the items with no information, you will get all items. 

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/5fb6e41a-4e07-4f5b-a983-005984a44681n%40chromium.org.

Cuyler Stuwe

unread,
Aug 7, 2024, 9:28:30 AMAug 7
to Edu, Chromium Extensions
Off the top of my head, there are a couple of reasonable ways of describing what “url” might be expected to mean here. This ambiguity is why I prefer using more descriptive names in my own code.

They are:

A. “Which URLs should we include?” This would follow the behavior of a strict whitelist, so an empty array should “include no URLs”.

B. “Which URL filters should we apply?” This would follow the behavior of the search/filter field in an app that otherwise displays all data. An empty array here would mean “include no URL filters” aka “show everything”.

Of these two, it sounds like you’re describing that it behaves like B. It’s only a “bug” if the documentation describes it differently, or if you can find evidence that it was clearly intended to work differently. The documentation is not incredibly detailed, but it says it will “match tabs against one or more URL patterns”. This statement implies that providing fewer than 1 pattern is “incorrect usage with unspecified behavior”. This line also implies that what you’re entering here are “filters for URLs”, hence it seems totally reasonable that having “no filters for your URLs” would result in having all URLs shown.

--

Edu

unread,
Aug 10, 2024, 6:35:52 PMAug 10
to Chromium Extensions, Cuyler Stuwe, Chromium Extensions, Edu
Thanks all for clarifying. How would we go about updating the docs to offer a better description?

Patrick Kettner

unread,
Aug 10, 2024, 6:36:39 PMAug 10
to Edu, Chromium Extensions, Cuyler Stuwe
I have opened a bug with the folks that write the docs to be more explicit about it.

Reply all
Reply to author
Forward
0 new messages