I have developed a Chrome extension, it works fine in Chrome 39 but gives an error in Opera developer 24 on Ubuntu 14.04 (64 bit).
Error in response to tabs.query: TypeError: Cannot read property 'id' of undefined at HTMLLIElement.click
So I tested chrome.tabs.query
on both browser consoles:
chrome.tabs.query(
{ active: true, highlighted: true, currentWindow: true },
function(thisTab) {
console.log(thisTab);
}
);
In Chrome it returns a complete Tab
object.
But in Opera it returns a blank array []
.
Why this is happening?
It seems that Opera does not include the concept of a highlighted tab, which is already pretty obscure in Chrome.
Your query is excessive anyway: in Chrome, the active tab cannot be non-highlighted.
So, for a query that works in both, use {active: true, currentWindow: true}
.