The code is meant to output the current tab object for the page the user is viewing to the console but it just outputs undefined. It\'s run from within a browser action page
Since chrome.tabs is only available in background or popup script and background script is not active in any tab, chrome.tabs.getCurrent() always return undefined.
Instead, we can retrieve the active Tab object from the second argument of any message listener callback. For example,
browser.runtime.onMessage.addListener((message, sender) => {
console.log('Active Tab ID: ', sender.tab.id);
});