Activating a tab in a Webextensions add-on

The add-on SDK had tab.activate()

Is this possible with the Webextensions API?

I think WebExtensions covers a lot of needs when it comes to tabs, contrarily to some other areas. You can do the equivalent of tab.activate() using browser.tabs.update(tab.id, {selected: true}).

Do you have any specifics in mind ?

Note: Any tab can be activated… however, it is not possible to focus on it at the moment.

For example in one of my addons, I change a text in the tab from sidebar but you can not change the focus to the tab so that it shows the highlighted text (although it is highlighted).

Warning ! browser.tabs.update(tab.id, {selected: true}) is deprecated ! You should use active instead. So you can focus a tab with the following code :


function focustab(tab){
    browser.windows.update(tab.windowId,{focused: true});
    browser.tabs.update(tab.id,{active: true});
}

Very right ! Thanks.

Thank you, that’s what I was looking for.
I need it for an add-on that can (among other things) remember a tab, and activate this tab when you click a context menu item.