tabs.onUpdated never returns changeInfo.url

I have followed this example:

function handleUpdated(tabId, changeInfo, tabInfo) {
  if (changeInfo.url) {
    console.log("Tab: " + tabId +
                " URL changed to " + changeInfo.url);
  }
}

browser.tabs.onUpdated.addListener(handleUpdated);

But when I navigate to a new url in a tab, the changeInfo object never gives me changeInfo.url. It’s always undefined. This exact same code works just fine on Chrome.

My system is:
Firefox 78.0.2(64-bits), macOS Catalina 10.15.5

Anyone has the same issue? It’s a real bug or it’s just me.
Thank you in advance.

Do you have “tabs” permission listed in the manifest? Without that things like URL and favicon are not available.

2 Likes

Super thanks @juraj.masiar. You are absolutely correct. I didn’t have “tabs” permission. Once I added the “tabs” permission. All work fine. Thank you.
Note: “tabs” permission is not needed in Chrome for changeInfo.url to work. That’s why I was confused in the first place.

2 Likes