Re: [crx] chrome.tabs.highlight complains "Error during tabs.highlight: No tab at index: 696."

715 views
Skip to first unread message

Adrian Aichner

unread,
Dec 10, 2012, 3:43:33 PM12/10/12
to Terry Jones, Chromium-extensions
Hi Terry, the first argument accept a tab.index object property, not a tab.id.

Here is a working example highlighting the tab with the next higher index, so that you can notice a visible effect.

You can remove this irritating effect again by reloading the extension.

I did the experiment from  the javascript console of an extsion's generated background page.

Here is the example:

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){ console.log(JSON.stringify(tabId)); console.log(JSON.stringify(changeInfo)); console.log(JSON.stringify(tab)); if (changeInfo.status === "complete"){ chrome.tabs.highlight({tabs: [tab.index+1]}, function(win){console.log(JSON.stringify(win)); }); } });



On Thu, Dec 6, 2012 at 3:43 AM, Terry Jones <te...@fluidinfo.com> wrote:
I'm trying to use chrome.tabs.highlight for the first time. I have some code that looks like this

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
    if (!tab.active){
        chrome.tabs.highlight({tabs: [tabId]}, function(){});
    }
}

When the tab updates and is not active, the highlight call is made and in the extension background page i get an error: "Error during tabs.highlight: No tab at index: 696."  That seems very wrong, as I'm getting the tab id as an argument to the onUpdated callback. If I look at tab.id it has the same id.  I get the same error if I also include the tab windowId in the call.

I'm running Version 23.0.1271.64 Ubuntu 12.04 (165188).

I'm not 100% sure what this call is supposed to do, but I wanted to try it. I suppose being highlighted makes the tab look like the current tab (which the user might find confusing).

BTW, if I don't pass a callback to chrome.tabs.highlight, Chrome also complains - so I send a do-nothing function to keep it quiet.

Thanks for any help!

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-extensions/-/lbwYrObLNAAJ.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.

Terry Jones

unread,
Dec 10, 2012, 4:43:05 PM12/10/12
to Adrian Aichner, Chromium-extensions
> Hi Terry, the first argument accept a tab.index object property, not a
> tab.id.

Argh! Thanks Adrian. Sorry for the noise....

Terry

Terry Jones

unread,
Dec 10, 2012, 8:45:46 PM12/10/12
to Adrian Aichner, Chromium-extensions
Is highlighting a tab supposed to be different from making it active?

I just made the change suggested by Adrian, and the end result is that the
tab I'm highlighting becomes the active tab in the window. I was expecting
that the tab indicator would be highlighted in some visual way without the
tab becoming the one being viewed in its window. I get the same behavior
when I pass highlight: true in a call to chrome.tabs.update

So I'm wondering if tab highlighting is just an old idea that never really
did anything, or if I'm still missing the picture.

BTW, what I'm trying to achieve is that when a tab updates (as a result of
my extension telling it to) and is not the active tab, it is somehow
highlighted for the user. I could use a notification, but I was hoping for
something less in your face.

Thanks a lot for any help / suggestions!

Terry
Reply all
Reply to author
Forward
0 new messages