Closed Bug 1866999 Opened 10 months ago Closed 4 months ago

WebExtensions permissions.onAdded <all_urls> returns invalid permission object

Categories

(WebExtensions :: General, defect, P3)

Firefox 120
defect

Tracking

(firefox128 fixed)

RESOLVED FIXED
128 Branch
Tracking Status
firefox128 --- fixed

People

(Reporter: clemens.mm, Assigned: zombie, NeedInfo)

References

Details

(Whiteboard: [addons-jira])

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15

Steps to reproduce:

  1. Request and grant:
    chrome.permissions.request({ permissions: [], origins ["<all_urls>"]}, (granted) => {});

  2. Add Listener:
    chrome.permissions.onAdded.addListener( (perm) => { console.log(perm); });

  3. Listener receives invalid permission object after granted:
    { permissions: ["<all_urls>"], origins ["<all_urls>"]}.

  4. "<all_urls>" inside permissions.permissions array is invalid.

Actual results:

If you request the <all_urls> host_permission the onAdded listener also adds <all_urls> to the permissions array instead of only the origins array.

If you add any other URLs the listener receives the expected permissions object.

Expected results:

The onAdded listener should receive the same permission object as requested.

You may also wanna test if the onRemoved listener has the same bug.

Some kind of workaround for now is to request ":///*" instead of "<all_urls>".

"*://*/*"

The Bugbug bot thinks this bug should belong to the 'Firefox::Site Permissions' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Site Permissions
Component: Site Permissions → General
Product: Firefox → WebExtensions

Hello,

Could you please attach an example extension with the behavior you mentioned in Comment 0? Thank you!

Flags: needinfo?(clemens.mm)
Severity: -- → S4
Priority: -- → P5
Priority: P5 → P3
Whiteboard: [addons-jira]

This issue is caused by the logic introduced in bug 1624513, specifically the _fixupAllUrlsPerms part.

We could fix this by stripping <all_urls> from permissions in normalizePermissions at https://searchfox.org/mozilla-central/rev/413b88689f3ca2a30b3c49465730c0e7d40f9188/toolkit/components/extensions/parent/ext-permissions.js#19-25

Interestingly, the internal implementation is somewhat messy, because we also strip the moz-extension:-permission at another layer: https://searchfox.org/mozilla-central/rev/413b88689f3ca2a30b3c49465730c0e7d40f9188/toolkit/components/extensions/Extension.sys.mjs#1226-1228

See Also: → 1624513
Assignee: nobody → tomica
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Pushed by tjovanovic@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/67fd3eae6ce3 <all_urls> is not an api for permission.onAdded r=robwu
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 128 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: