Open Bug 1796933 Opened 2 years ago Updated 2 months ago

browser.permissions is not available in dev panel

Categories

(WebExtensions :: General, enhancement, P3)

Firefox 105
enhancement

Tracking

(firefox106 affected, firefox107 affected, firefox108 affected)

Tracking Status
firefox106 --- affected
firefox107 --- affected
firefox108 --- affected

People

(Reporter: me, Unassigned)

References

Details

(Whiteboard: [wecg][addons-jira])

Steps to reproduce:

  1. I created an extension a devtools_page key, which creates a panel via chrome.devtools.panels.create
  2. In the panel.html page, I want to run browser.permissions.request

Actual results:

browser.permissions is undefined

Expected results:

browser.permissions should be defined like it is in every other non-web extension context.

This is somewhat related to 1493396 and 1382953, except here the whole API is completely missing.

Find a repro here, it works in Chrome: https://gist.github.com/fregante/d87ffc87dc648a790d5d85a7cda72a67

Related report on GitHub: https://github.com/pixiebrix/pixiebrix-extension/issues/680

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

Product: Firefox → WebExtensions

Hello,

I’m from QA and I’m attempting to reproduce the issue in order to confirm it. I’ve run into an issue and would require further details.

I’ve downloaded the archive with the extension contents from the gist you mentioned, unpacked it and loaded the manifest.json file in about:debugging. Nothing seems to happen. I cannot get to the devtools_page you mentioned nor the panel.html page by any means I’ve tried.

Could you please provide some more detailed steps to reproduce the issue? Thank you !

Flags: needinfo?(me)

I cannot get to the devtools_page you mentioned

You will find a new tab in the developer tools. More detailed steps:

  1. Open developer tools
  2. Open panel named "New demo panel"
  3. Click the button named "Request"
  4. Expect permissions.request() modal, but instead see error on the page

Refer to MDN for extended details: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Extending_the_developer_tools#creating_panels

Flags: needinfo?(me)

Hello and thank you for the additional details !

I reproduced the issue on the latest Nightly (108.0a1/20221025094808), Beta (107.0b4/20221023190001) and Release (106.0.1/20221019185550) under Windows 10 x64 and Ubuntu 16.04 LTS.

After clicking the “Request” button, an error is displayed (TypeError: browser.permissions is undefined) instead of a permissions.request() modal, as mentioned in Comment 3.

Status: UNCONFIRMED → NEW
Ever confirmed: true

The feature request here is reasonable, since the extension devtools panel inside the devtools is some sort of UI, perceived to be associated with an extension and/or devtools UI.

There are two things needed to enable permissions.request functionality:

  1. To expose the API to the devtools, the permissions.json schema file should include "allowedContexts": ["devtools"] at the namespace (after https://searchfox.org/mozilla-central/rev/73ff5f1ac45202c4621a1bcee4b35d20027e71ad/toolkit/components/extensions/schemas/permissions.json#3) and in each of the individual methods.
  2. A place to anchor permission prompts. In the mentioned bugs (bug 1382953 and bug 1493396), the permission prompt was anchored to the tab. The devtools panel can be docked into a tab, but it could also be a stand-alone window.

So even if the API is exposed, it would likely not do much at the moment due to the second point.

Ideas and patches are welcome.

Severity: -- → N/A
Type: defect → enhancement
Priority: -- → P3

+1, I'm not sure how to proceed with this for migrating my Cookie-Editor extension to manifest v3 since host_permissions is now optional.

A place to anchor permission prompts

Could the permission prompt be displayed as a modal in the devtools panel?

Component: Untriaged → General
Whiteboard: [wecg][addons-jira]

In favor of exposing not just the permissions API, but all privileged extension APIs to devtools panels / devtools_page.

You need to log in before you can comment on or make changes to this bug.