Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome: Error in event handler for tabs.onUpdated: Error: Expected at most 0 arguments for show(), got 1 #24

Closed
T-vK opened this issue Feb 16, 2017 · 2 comments

Comments

@T-vK
Copy link

T-vK commented Feb 16, 2017

Screenshot

My extension works without any errors in the latest version of Firefox. In Chrome I get this error.
Honestly, I'm not sure what is causing this error. I am using tabs.onUpdated and within that I'm using pageAction.show(). If you need more information, tell me.

Edit:
Maybe the issue is that I'm calling browser.pageAction.show() with a tab id in as the first argument as required by Firefox. I guess Chrome doesn't support it?
I tried to work around it using browser.pageAction.show(browser.pageAction.show.length?tabId:undefined).
But that didn't make any difference.

Edit2:
It seems to be a misconfiguration in the browser-polifill library. Setting minArgs and maxArgs of show under pageAction to 1 seems to fix it.

Edit3:
Actually I'm still getting an error:
Error: Invocation of form pageAction.show(integer, function) doesn't match definition pageAction.show(integer tabId)

Edit4:
Here is the code causing the error:

browser.tabs.query({}).then( tabs => {
    if (!tabs)
        return
    let promiseArray = []
    tabs.forEach(tab => {
        let tabId = tab.id
        promiseArray.push(browser.pageAction.show(tabId).then(()=>{
            return browser.pageAction.setIcon({tabId: tabId, path: 'disabled.ico'})
        }))
    })
    return Promise.all(promiseArray)
}).then(()=>{
    /* ... */
}).catch(console.error)
@Rob--W
Copy link
Member

Rob--W commented Feb 17, 2017

See #13 (and #9). For now, just use chrome.pageAction.setIcon (or apply PR #13).

@Rob--W
Copy link
Member

Rob--W commented May 31, 2018

Fixed by #59.

@Rob--W Rob--W closed this as completed May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants