TypeError: browser.tabs.show is not a function

In my extension, browser.tabs.query works well.
But browser.tabs.show gives "TypeError: browser.tabs.show is not a function" error.

My script.js content is copied from sample:

function onShown() {

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

browser.tabs.show(2).then(onShown, onError);

My html:

<!doctype html>
    <script src="script.js"></script>

I couldn’t find such issue in Google or this forum.

Do you have the tabHide permission?

1 Like

Thank you. It works now. I had only tabs permission.

PS as a novice in Firefox extensions, it was impossible for me to find that calling tabs.show requires tabHide permission. I was following documentation of tabs.show function at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/show but it is not mentioned there.

It is mentioned at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/hide which you presumably called to hide the tab in the first place.

Ok, so this means dead end for me.
I just wanted to make tab of given ID active with a button click.
Now I see, that tabs.show works only when used in conjuntion with tabs.hide.
After digging a while in docs, my next candidate is tabs.update(..active: true..)

That would be the correct approach to activating a tab and shouldn’t even require any permissions once you have the tabId.

1 Like