WebExtensions permissions.onAdded <all_urls> returns invalid permission object
Categories
(WebExtensions :: General, defect, P3)
Tracking
(firefox128 fixed)
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:
-
Request and grant:
chrome.permissions.request({ permissions: [], origins ["<all_urls>"]}, (granted) => {}); -
Add Listener:
chrome.permissions.onAdded.addListener( (perm) => { console.log(perm); }); -
Listener receives invalid permission object after granted:
{ permissions: ["<all_urls>"], origins ["<all_urls>"]}. -
"<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.
Reporter | ||
Comment 1•10 months ago
|
||
Some kind of workaround for now is to request ":///*" instead of "<all_urls>".
Reporter | ||
Comment 2•10 months ago
|
||
"*://*/*"
Comment 3•10 months ago
|
||
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.
Reporter | ||
Updated•10 months ago
|
Comment 4•10 months ago
|
||
Hello,
Could you please attach an example extension with the behavior you mentioned in Comment 0? Thank you!
Assignee | ||
Updated•10 months ago
|
Updated•10 months ago
|
Updated•10 months ago
|
Comment 5•10 months ago
|
||
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
Assignee | ||
Comment 6•5 months ago
|
||
Updated•5 months ago
|
Comment 8•4 months ago
|
||
bugherder |
Description
•