Reputation: 655
I'm creating a simple webExtension for firefox and I want to use tabs.onUpdated with a filter. I copied an example from mozilla site:
const pattern1 = "https://developer.mozilla.org/*";
const pattern2 = "https://twitter.com/mozdevnet";
const filter = {
urls: [pattern1, pattern2]
}
function handleUpdated(tabId, changeInfo, tabInfo) {
console.log(`Updated tab: ${tabId}`);
console.log("Changed attributes: ", changeInfo);
console.log("New tab Info: ", tabInfo);
}
browser.tabs.onUpdated.addListener(handleUpdated, filter);
When I reload my extension I get this error in console:
Error: Incorrect argument types for tabs.onUpdated. background-script.js:14:1
makeError resource://gre/modules/Schemas.jsm:446:14
throwError resource://gre/modules/Schemas.jsm:2138:11
checkParameters resource://gre/modules/Schemas.jsm:2195:7
addStub resource://gre/modules/Schemas.jsm:2381:21
<anonymous> moz-extension://78d98d27-294e-4774-9461-dfb3dda97871/background-script.js:14:1
I don't know if there was some changes in this api which wasn't documented yet or there is some other problem, maybe with permissions.
These are my permissions from manifest.json
:
"permissions": ["activeTab", "notifications", "tabs"]
Upvotes: 0
Views: 404
Reputation: 3704
extraParameters is supported from Firefox 61 onwards: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/onUpdated
If you want to support an older version, you should use an "if" statement in your onUpdated listener.
Upvotes: 2