moronizzz
moronizzz

Reputation: 3

chrome.tabs.query: Property 'currentWindow': Unexpected

I installed the extension timeStats for my Chromium (18.0.1025.151) browser, but it is not working correctly. In the process of debugging i found the problem - during the execution of the method 'chrome.tabs.query' a message is: "Property 'currentWindow': Unexpected property.", although the documentation for this parameter is described: http://code.google.com/chrome/extensions/tabs.html#method-query

This is a bug or possible fix the error?

some code:

if (isWindowActive && !isWindowMinimized)
{
    chrome.idle.queryState(parseInt(options.idle_time), function(state) {
        //problem below
        chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
        //problem above
            var tabId = tabs[0].id;
            if (state=='active')
            {
                setBadgeColorActive(chrome.windows.WINDOW_ID_CURRENT);
                //if browser active update the info
                if (isLoaded)
                {
                    update(true);
                }
            }
            //set icon gray
            else
            {
                chrome.browserAction.setBadgeBackgroundColor({color: badgeIdle, tabId: tabId});
                chrome.browserAction.setTitle( {title: chrome.i18n.getMessage("freezed")+" "+options.idle_time+" "+chrome.i18n.getMessage("seconds_lcase"), tabId: tabId });
            }
        });
    });
}

Upvotes: 0

Views: 2279

Answers (1)

Konrad Dzwinel
Konrad Dzwinel

Reputation: 37903

You are testing this on quite old version of Chromium (18) and docs you mentioned in your question are referring to version 20 of Chromium. If you check changes to extensions APIs you will find that:

Google Chrome 19

(...)

The chrome.tabs query() method now has the currentWindow and lastFocusedWindow parameters.

(...)

So currentWindow was not available prior version 19.


BONUS:

If you depend on currentWindow be sure to set minimum_chrome_version to 19 in manifest.json.

Upvotes: 2

Related Questions