Closed Bug 1551378 Opened 6 years ago Closed 2 years ago

Support `tabs.query` extension API

Categories

(GeckoView :: Extensions, enhancement, P3)

Unspecified
Android
enhancement

Tracking

(firefox67 wontfix, firefox67.0.1 wontfix, firefox68 wontfix, firefox69 wontfix)

RESOLVED WORKSFORME
Tracking Status
firefox67 --- wontfix
firefox67.0.1 --- wontfix
firefox68 --- wontfix
firefox69 --- wontfix

People

(Reporter: agi, Unassigned)

References

(Blocks 1 open bug)

Details

Right now it returns an empty array, it should return a list of tabs as described in: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/query

This bug might be related to tabId bug 1551377.

OS: All → Android
Priority: -- → P2

From my quick testing tabs.query seems to return only the last tab that received a navigation event but not all of them.

We inherit the query method from a common implementation here: https://searchfox.org/mozilla-central/rev/967bc2a7540a505ad31d186804bd048bb2fa3689/toolkit/components/extensions/parent/ext-tabs-base.js#1923-1953

In GeckoView (IIRC) every tab is in it's own window, so the problem is likely in the mobile implementation on WindowTracker: https://searchfox.org/mozilla-central/rev/967bc2a7540a505ad31d186804bd048bb2fa3689/mobile/android/components/extensions/ext-utils.js#745-761

It could also related to the fact the all tabs have the same ID, as mentioned by Chris in Comment #1. In that case the place to look at would be our TabTracker implementation: https://searchfox.org/mozilla-central/rev/967bc2a7540a505ad31d186804bd048bb2fa3689/mobile/android/components/extensions/ext-utils.js#235

This is the code I've been testing this with (in a background script):

function logTabs(tabs) {
  console.log(tabs.map(tab => tab.url));
}

function onError(error) {
  console.log(`Error: ${error}`);
}

function queryTabs() {
  const querying = browser.tabs.query({currentWindow: true});
  querying.then(logTabs, onError);
  setTimeout(queryTabs, 1000);
}

queryTabs();

I think my changes in https://bugzilla.mozilla.org/show_bug.cgi?id=1539144 make tabs.query to work correctly. Assumption is that every GeckoSession represents a Gecko window with exactly one tab.

(In reply to Krzysztof Jan Modras from comment #3)

I think my changes in https://bugzilla.mozilla.org/show_bug.cgi?id=1539144 make tabs.query to work correctly. Assumption is that every GeckoSession represents a Gecko window with exactly one tab.

That approach holds only in case all sessions are loaded in GeckoView - I can imagine an application that holds unused session out side of GeckoView util they get accessed by the user, in such case tabs.query will fail to return information about them.
A more GeckoView-like approach would be to delegate tabs.query to GeckoRuntime so application can decide which tabs are available.

In addon perspective the first approach should be good enough for now as addons should probably only interact with tabs that are currently in use, but behavior may be problematic to expecting it developers.

(In reply to Krzysztof Jan Modras from comment #3)

I think my changes in https://bugzilla.mozilla.org/show_bug.cgi?id=1539144 make tabs.query to work correctly. Assumption is that every GeckoSession represents a Gecko window with exactly one tab.

Yep, that should be correct.

(In reply to Krzysztof Jan Modras from comment #4)

That approach holds only in case all sessions are loaded in GeckoView - I can imagine an application that holds unused session out side of GeckoView util they get accessed by the user, in such case tabs.query will fail to return information about them.
A more GeckoView-like approach would be to delegate tabs.query to GeckoRuntime so application can decide which tabs are available.

In addon perspective the first approach should be good enough for now as addons should probably only interact with tabs that are currently in use, but behavior may be problematic to expecting it developers.

I think it's OK to ignore GeckoSessions that are not attached to a GeckoView, especially for MVP. If there's a clear need / usecase for it we can discuss it in a separate bug.

Assignee: nobody → krzysztof.modras
Depends on: 1562844

I'm editing a bunch of GeckoView bugs. If you'd like to filter all this bugmail, search and destroy emails containing this UUID:

e88a5094-0fc0-4b7c-b7c5-aef00a11dbc9

Priority: P2 → P3

Mass moving bugs to the Extension component.

Component: General → Extensions

The bug assignee didn't login in Bugzilla in the last 7 months.
:amoya, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: krzysztof.modras → nobody
Flags: needinfo?(amoya)
Severity: normal → N/A
Summary: Support `tabs.query` → Support `tabs.query` extension API
Flags: needinfo?(amoya)
Whiteboard: [addons-jira]
Whiteboard: [addons-jira]

In fact, tabs.query() seems to be supported nowadays.

I am going to close this bug. Unfortunately I cannot retrieve the bug for the implementation.

:robwu if you remember, please add the bug ID here, otherwise ignore my NI. Thanks!

Flags: needinfo?(rob)
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → INVALID

It was fixed by the "depends on" bug, specifically https://hg.mozilla.org/mozilla-central/rev/d74231becedc . There are some other features missing from the tabs API, but these are already covered by other bugs. Notably bug 1583281.

Flags: needinfo?(rob)
Resolution: INVALID → WORKSFORME
See Also: → 1856222
You need to log in before you can comment on or make changes to this bug.