Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can browser.tabs.query({active: true, currentWindow: true}) ever return more than one tab?

My extension needs to do something with the currently active tab. So I use

browser.tabs.query({active: true, currentWindow: true}).then((tabs) =>
  let tab = tabs[0];
  if (tab) {
    // actual code
  } else {
    log("no active tab")
  }
);

Mostly out of curiosity: are there cases where tabs will have more than one tab?

like image 249
Alexey Romanov Avatar asked Oct 28 '25 09:10

Alexey Romanov


1 Answers

TLDR: No

For Chrome, Opera and Firefox this is currently impossible, so it's safe to assume that the array will only contain one element.

Opera has multi-select of tabs, but it uses the property highlighted to indicate the multi-select status. active means "visibly selected in window": the contents of the tab are visible in the browser window.

browser.tabs.query returns an array, regardless of the filter you pass to it. It also returns an array when filtering on "index", containing one result if you have one window open.

like image 79
Smile4ever Avatar answered Oct 30 '25 13:10

Smile4ever