Closed Bug 1603981 Opened 6 years ago Closed 6 years ago

tabs.query should allow url match if host permission granted

Categories

(WebExtensions :: Untriaged, defect)

71 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: locketine, Unassigned)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0

Steps to reproduce:

I requested a host permission for plex.tv, and then attempted to query for tabs matching that host.

let matches = 'https://app.plex.tv/*'
browser.permissions.request({
  origins: matches
}).then(approved => {
  if (approved) {
    browser.tabs.query({
       url: matches
    })
  }
}

My extension is in the store here: https://addons.mozilla.org/en-US/firefox/addon/media-keys
To trigger the issue, open options, scroll to the bottom and set a custom url matcher.
The documentation that say this should work is here: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/executeScript

Actual results:

console error:
Error: The "tabs" permission is required to use the query API with the "url" or "title" parameters

Expected results:

I should have gotten the tabs that match the host pattern. This had been working for a while but a user of my addon reported that it stopped working about a month ago.

The priority flag is not set for this bug.
:jimm, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jmathies)

Hello,

I did not manage to reproduce this on on Windows 10 with FF Nightly 71.0a1 (20190924094348) or on FF 71.0 Release (20191202093317) - possibly not using an appropriate custom url matcher in the extensions options.
Could you please provide an example?
Also, could you please clarify - does the console error show when saving the custom url in the extension's options?

Thank you

Flags: needinfo?(locketine)

I used "https://localhost:32400/*" just now to make sure it's still reproducible.

Yes, you need to click the save button to trigger the permission request, which you then have to accept, and then the error will show up in the Extension Debugger Console. The URI for the debugger console is: about:devtools-toolbox?type=extension&id=jid1-4GP7z3tkUd3Tzg%40jetpack.

Flags: needinfo?(locketine)
Attached image "tabs" permission error

Hello and thank you for the quick reply.
Managed to reproduce this by on Windows 10 on FF Nightly 73.0a1 (20191229212642) and FF Release 71.0 (20191202093317) :

  1. Installing the extension.
  2. Going to about:addons and viewing the extension's Options.
  3. Scrolling to the Media Player domains section and adding a custom domain url (such as a local host url). Click Save.
  4. In about:addons inspect the extension and in the newly opened devtools navigate to console.
    Result:
    Attached is a screenshot of the 'Error: The "tabs" permission is required to use the query API with the "url" or "title" parameters'.

As for this working before, I've started testing the Nightly builds from December 2019 to December 2018 but I did not encounter one that did not have this issue.

You do not have the "tabs" permission, add it to your manifest. You need that to do your query.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions

Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID

(In reply to Shane Caraveo (:mixedpuppy) from comment #5)

You do not have the "tabs" permission, add it to your manifest. You need that to do your query.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions

According to the executeScript documentation, I do not not need the tabs permission if I have the host permission:

You can inject code into pages whose URL can be expressed using a match pattern: meaning, its scheme must be one of "http", "https", "file", "ftp". To do this you must have the permission for the page's URL, either explicitly as a host permission, or via the activeTab permission.

After carefully re-reading the executeScript documentation, I realize that it may be referring to executing the script on the active tab only. So the host permission only applies if I don't need to query for the tab id. That could be made more explicit if that is the intent.

I am already registering content scripts for the domain via the contentScripts.register API, and that works without errors. The only reason I was using tabs.query and executeScript was to ensure that existing tabs were affected by the changes to my extension's configuration.

Flags: needinfo?(jmathies)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: