When I'm trying get tab information from within chrome.tabs.onActivated
event callback when a tab switched via mouse click I get undefined
result and error message
Unchecked runtime.lastError: Tabs cannot be edited right now (user may be dragging a tab).
With 100ms delay or switch tab with CTRL+TAB or if a tab clicked while window was not in focus it works fine:
background.js
chrome.tabs.onActivated.addListener( info =>
{
chrome.tabs.get(info.tabId, tab => console.log("get", tab));
chrome.tabs.query({active: true, windowId: info.windowId}, tab => console.log("query", tab));
chrome.tabs.getSelected(tab => console.log("getSelected", tab));
setTimeout(()=>
{
chrome.tabs.get(info.tabId, tab => console.log("setTimeout get", tab));
chrome.tabs.query({active: true, windowId: info.windowId}, tab => console.log("setTimeout query", tab));
chrome.tabs.getSelected(tab => console.log("setTimeout getSelected", tab));
}, 100);
});
manifest.json
{
"background": {
"persistent": true,
"scripts": [ "background.js" ]
},
"description": "tab info within chrome.tabs.onActivated event",
"manifest_version": 2,
"name": "test",
"permissions": [ "tabs" ],
"version": "0.0.1"
}
Is this a bug or something?
Testing in Chrome 91.0.4472.77 64bit and MS Edge 91.0.864.41 64bit