New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 592056 link

Starred by 7 users

Issue metadata

Status: WontFix
Owner:
Closed: Apr 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Breaking change in chrome.tabs.query extension API

Reported by goservis...@gmail.com, Mar 4 2016

Issue description

Chrome Version       : 49.0.2623.75
URLs (if applicable) : Extension background page
OS version               : OSX 10.11.3

What steps will reproduce the problem?

In an extension background page, calling chrome.tabs.query({ url: chrome.extension.getURL('') + '*' }) returns an array of all open tabs.

What is the expected result?

Up to Chrome 48, the above method would return either the extension tab as an array containing a single item, or an empty array.

Example code:

chrome.browserAction.onClicked.addListener(function (tab) {
    var extensionUrl = chrome.extension.getURL('');

    if (tab.url.indexOf(extensionUrl) !== 0) {
        // find extension tab or open new
        chrome.tabs.query({ url: extensionUrl + '*' }, function (tabs) {
            // Before Chrome 49, `tabs` would either be an empty array if the extension
            // has no open tabs, or an array with one or more tabs containing extension pages.
            // In Chrome 49, `tabs` is now an array containing all open tabs.
        });
    }
});
 
Labels: Needs-Feedback
Hm.

Is the result of chrome.extension.getURL('') + '*' a valid URL match pattern for chrome.tabs.query()? The only allowed schemes for URL match patterns are 'http', 'https', 'file', and 'ftp', according to https://developer.chrome.com/extensions/match_patterns - perhaps that generated pattern has a disallowed scheme (like 'chrome-extension') and so it's being ignored?

Reporter:
1) Does the URL you're passing to chrome.tabs.query() start with one of the allowed schemes for URL match patterns?
My extension also has this problem in Version 49.0.2623.75 m.  Calls to chrome.tabs.query with {url:'my url'} returns a list of Tabs even when the url does not match.  Before, the list would be empty.

Simply running this in the console of an extension returns two Tabs instead of none!
chrome.tabs.query({active: true, title:'missing title'}, function(a){console.log(a)});


This code used to work fine, since only a tab matching the supplied URL would be returned, or none at all. Now, multiple tabs are being returned.

          var url = chrome.extension.getURL('my_popup.html');
          chrome.tabs.query({ url: url }, function (foundTabs) {
            if (foundTabs[0]) {
              chrome.tabs.update(foundTabs[0].id, {
                active: true
              });
            } else {
              chrome.tabs.create({ url: url });
            }
          });

My report is for a Windows desktop.
As a workaround, I am trying to examine all the Tabs returned, and find my Tab... but there doesn't seem to be any useful information in the Tab object to help identify it.

(I don't have "tabs" permission in the extension's manifest, because I don't need it to find and update my tab.)

Comment 6 by nucle...@gmail.com, Mar 8 2016

Same as everyone else, I need it to avoid creating duplicate tabs of the same page. Neither do I have `tabs` permission to further check URLs on all the tabs, since that requires new permission from the user.
My workaround now is to remember the tab id when I make a tab (stored in localStorage) and attempt to reopen (chrome.tabs.update(id, {active:true}), fn) that tab later. If nothing is given to the fn, my tab must not be there, and I make a new one.

Comment 8 by nucle...@gmail.com, Mar 8 2016

I think that will fail (will focus to irrelevant tab) if user uses that same tab to navigate to another site.
Good point about the tab being used to navigate to another site! Just tried it, and it doesn't work that way, fortunately. If the tab is used for a different URL, it must get a new id or something. Before navigating, my code would refocus on that tab. After navigating, my code would create a new tab.
In any case, we're all referring to a breaking change in the API. If this
is expected, we need a viable work around to identify a tab by its URL in
order to avoid creating multiple tabs with the same URL.
Project Member

Comment 11 by sheriffbot@chromium.org, Mar 9 2016

Labels: -Needs-Feedback Needs-Review
Owner: ellyjo...@chromium.org
Status: Assigned (was: Unconfirmed)
Thank you for providing more feedback. Assigning to requester "ellyjones@chromium.org" for another review.

For more details visit https://sites.google.com/a/chromium.org/dev/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: ashej...@chromium.org
 Issue 594625  has been merged into this issue.
Is this going to be fixed? My extensions are suffering from this regression too and I don't want to ask for the "tabs" permission, since I don't really need it.

Please consider a quick fix.
Ah forgot to say that this bug is still there on 49.0.2623.110 ( 64-bit official build )
For anyone who's coming here, should know that this issue has been fixed with the latest 50.0.2661.75 (Official Build) m (a 64 bit)

@Google: would be nice if sometimes you answer to our issues...or at least update them with the current resolution status.
Status: WontFix (was: Assigned)
Sorry for the late response, glad that the issue is fixed. Please feel free to reopen if needed.

Sign in to add a comment