Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing developer tools contexts in runtime.getContexts() API #670

Open
sohailrajdev97 opened this issue Aug 14, 2024 · 2 comments
Open
Labels
supportive: chrome Supportive from Chrome supportive: firefox Supportive from Firefox supportive: safari Supportive from Safari

Comments

@sohailrajdev97
Copy link

sohailrajdev97 commented Aug 14, 2024

Exposing developer tools contexts in runtime.getContexts() API

WECG proposal for runtime.getContexts()

https://github.com/w3c/webextensions/blob/main/proposals/runtime_get_contexts.md

Background

Extensions can customize the browser developer tools. When an extension customises the developer tools, it can run code in the following contexts:

  1. Developer tools page: This is a background page which is spawned as soon as developer tools is opened. Its lifetime is tied to the developer tools.
  2. Developer tools panel: This is a panel which the extension can add to the developer tools by calling devtools.panels.create() from the developer tools page (1).
  3. Developer tools sidebar pane: This is a side pane which the extension can add to a particular panel (2) by calling devtools.panels.<panel>.createSidebarPane() from the developer tools page (1).
drawing

image

image

Proposal

All the above contexts host extension content (HTML and JavaScript). These should be available in the results of runtime.getContexts() API. runtime.getContexts() asynchronously returns a list of ExtensionContext objects. Following is a description of how ExtensionContext’s fields would be populated for developer tools contexts.

  • contextType: Three new context types would be added (one for each context described above)
    1. DEVTOOLS_PAGE for developer tools page.
    2. DEVTOOLS_PANEL for developer tools panel.
    3. DEVTOOLS_SIDEBAR_PANE for developer tools sidebar pane.
  • tabId: -1 as these contexts are not associated with a browser tab.
  • windowId
    • If developer tools are docked, the ID of the parent window (to which it is docked).
    • If developer tools are undocked, the ID of the window hosting developer tools.

Other fields (contextId, documentId, frameId, documentUrl, documentOrigin, incognito) should be populated as expected. No special handling is needed for them.

Current support

  1. Firefox 129 does not return these contexts via the API call.
  2. Chrome 129 returns these contexts with a “TAB” context type, which is incorrect.

Compatibility issues

Chrome already returns developer tools contexts via the API; some extensions might be using that information. Currently the contexts are returned with the “TAB” context type and that is a bug.

Creating this issue to get group's feedback. We will create a follow-up PR to modify the runtime.getContexts() proposal after we have consensus within the group.

@github-actions github-actions bot added needs-triage: chrome Chrome needs to assess this issue for the first time needs-triage: firefox Firefox needs to assess this issue for the first time needs-triage: safari Safari needs to assess this issue for the first time labels Aug 14, 2024
@xeenon xeenon added supportive: safari Supportive from Safari and removed needs-triage: safari Safari needs to assess this issue for the first time labels Aug 15, 2024
@Rob--W Rob--W added follow-up: chrome Needs a response from a Chrome representative supportive: firefox Supportive from Firefox and removed needs-triage: chrome Chrome needs to assess this issue for the first time needs-triage: firefox Firefox needs to assess this issue for the first time labels Aug 15, 2024
@oliverdunk
Copy link
Member

Thanks again for filing this @sohailrajdev97. On the Chrome side, we are supportive - we would prefer only a single new ContextType variant to avoid adding several. We should also work together to communicate the change to developers before it happens since it is a behavior change, even if adoption is low.

Looking forward to seeing this progress :)

@Rob--W
Copy link
Member

Rob--W commented Sep 13, 2024

I filed this bug on the Firefox side to implement DEVELOPER_TOOLS in runtime.getContexts(): https://bugzilla.mozilla.org/show_bug.cgi?id=1918719

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
supportive: chrome Supportive from Chrome supportive: firefox Supportive from Firefox supportive: safari Supportive from Safari
Projects
None yet
Development

No branches or pull requests

4 participants