< Get id tab > full example βΌ
(Truth: the clearest full definitions: examples have.)
<manifest .json >
{"manifest_version":2, "name":"My Cool Extension", "version":"0.1", "content_scripts":[{"matches":["<all_urls>"], "js":["content.js"] } ], "background":{"scripts":["bg.js"]} }
<B.G. .js >
chrome.runtime.onMessage.addListener((msg, sender_info, Reply)=> { Reply(sender_info); });
<content .js >
chrome.runtime.sendMessage('', (r)=> { console.log('content.js', 'r.tab.id', r.tab.id); });
Update the extension, go to the tab, refresh the page, wait, check <content .js > oks, wait, check cb oks, wait, check <console.log> oks, for example:

Check βΌ
Full patch:
<B.G. .js >
console.log('bg.js, start'); chrome.runtime.onMessage.addListener((msg, sender_info, Reply)=> { console.log('bg.js, start, cb chrome.runtime.onMessage.addListener'); console.log('bg.js', 'sender_info', sender_info); console.log('bg.js', 'sender_info.id', sender_info.id); console.log('bg.js', 'sender_info.url', sender_info.url); console.log('bg.js', 'sender_info.frameId', sender_info.frameId); console.log('bg.js', 'sender_info.tlsChannelId', sender_info.tlsChannelId); console.log('bg.js', 'sender_info.tab', sender_info.tab); console.log('bg.js', 'sender_info.tab.url', sender_info.tab.url); console.log('bg.js', 'sender_info.tab.favIconUrl', sender_info.tab.favIconUrl); console.log('bg.js', 'sender_info.tab.title', sender_info.tab.title); console.log('bg.js', 'sender_info.tab.incognito', sender_info.tab.incognito); console.log('bg.js', 'sender_info.tab.status', sender_info.tab.status); console.log('bg.js', 'sender_info.tab.width', sender_info.tab.width); console.log('bg.js', 'sender_info.tab.height', sender_info.tab.height); console.log('bg.js', 'sender_info.tab.id', sender_info.tab.id); console.log('bg.js', 'sender_info.tab.windowId', sender_info.tab.windowId); console.log('bg.js', 'sender_info.tab.sessionId', sender_info.tab.sessionId); console.log('bg.js', 'sender_info.tab.openerTabId', sender_info.tab.openerTabId); console.log('bg.js', 'sender_info.tab.pinned', sender_info.tab.pinned); console.log('bg.js', 'sender_info.tab.audible', sender_info.tab.audible); console.log('bg.js', 'sender_info.tab.mutedInfo', sender_info.tab.mutedInfo); console.log('bg.js', 'sender_info.tab.mutedInfo.muted', sender_info.tab.mutedInfo.muted); console.log('bg.js', 'sender_info.tab.mutedInfo.extensionId', sender_info.tab.mutedInfo.extensionId); console.log('bg.js', 'sender_info.tab.mutedInfo.reason', sender_info.tab.mutedInfo.reason); console.log('bg.js', 'sender_info.tab.highlighted', sender_info.tab.highlighted); console.log('bg.js', 'sender_info.tab.active', sender_info.tab.active); console.log('bg.js', 'sender_info.tab.discarded', sender_info.tab.discarded); console.log('bg.js', 'sender_info.tab.autoDiscardable', sender_info.tab.autoDiscardable); Reply(sender_info); console.log('bg.js, end, cb chrome.runtime.onMessage.addListener'); }); console.log('bg.js, end');
<content .js >
console.log('content.js, start'); chrome.runtime.sendMessage('', (r)=> { console.log('content.js, start, cb chrome.runtime.sendMessage'); console.log('content.js', 'r', r); console.log('content.js', 'r.id', r.id); console.log('content.js', 'r.url', r.url); console.log('content.js', 'r.frameId', r.frameId); console.log('content.js', 'r.tlsChannelId', r.tlsChannelId); console.log('content.js', 'r.tab', r.tab); console.log('content.js', 'r.tab.url', r.tab.url); console.log('content.js', 'r.tab.favIconUrl', r.tab.favIconUrl); console.log('content.js', 'r.tab.title', r.tab.title); console.log('content.js', 'r.tab.incognito', r.tab.incognito); console.log('content.js', 'r.tab.status', r.tab.status); console.log('content.js', 'r.tab.width', r.tab.width); console.log('content.js', 'r.tab.height', r.tab.height); console.log('content.js', 'r.tab.id', r.tab.id); console.log('content.js', 'r.tab.windowId', r.tab.windowId); console.log('content.js', 'r.tab.sessionId', r.tab.sessionId); console.log('content.js', 'r.tab.openerTabId', r.tab.openerTabId); console.log('content.js', 'r.tab.pinned', r.tab.pinned); console.log('content.js', 'r.tab.audible', r.tab.audible); console.log('content.js', 'r.tab.mutedInfo', r.tab.mutedInfo); console.log('content.js', 'r.tab.mutedInfo.muted', r.tab.mutedInfo.muted); console.log('content.js', 'r.tab.mutedInfo.extensionId', r.tab.mutedInfo.extensionId); console.log('content.js', 'r.tab.mutedInfo.reason', r.tab.mutedInfo.reason); console.log('content.js', 'r.tab.highlighted', r.tab.highlighted); console.log('content.js', 'r.tab.active', r.tab.active); console.log('content.js', 'r.tab.discarded', r.tab.discarded); console.log('content.js', 'r.tab.autoDiscardable', r.tab.autoDiscardable); console.log('content.js, end, cb chrome.runtime.sendMessage'); }); console.log('content.js, end');