From 0a5ae065ed283a71eaf66992e58fa94a617fc050 Mon Sep 17 00:00:00 2001 From: Sohail Rajdev Date: Mon, 19 Aug 2024 16:02:27 +0530 Subject: [PATCH 1/4] Add developer tools contexts in runtime.getContexts() proposal --- proposals/runtime_get_contexts.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/proposals/runtime_get_contexts.md b/proposals/runtime_get_contexts.md index 3eed22fa..98175695 100644 --- a/proposals/runtime_get_contexts.md +++ b/proposals/runtime_get_contexts.md @@ -105,6 +105,8 @@ extension.ContextType = { OFFSCREEN_DOCUMENT: 'OFFSCREEN_DOCUMENT', // A side panel or sidebar context. SIDE_PANEL: 'SIDE_PANEL', + // A developer tools context. + DEVELOPER_TOOLS: 'DEVELOPER_TOOLS', }; ``` @@ -236,6 +238,22 @@ This is an artifact of existing APIs and precedence. Since many existing APIs use the constant integer values, we want to be consistent with those. However, for newly-introduced fields, we use the more intuitive `undefined` state. + +### Developer Tools Contexts + +Extensions can use the +[Dev Tools API](https://developer.chrome.com/docs/extensions/mv3/devtools/) to +extend the browser's developer tools. When doing so, these extensions can run +different types of contexts (page, panel, sidebar). `runtime.getContexts()` +returns these contexts with the `DEVELOPER_TOOLS` context type. + +- These contexts have a `tabId` of -1 as these contexts are not hosted inside +a tab. +- If developer tools are docked to a tab, the `windowId` will be the ID of the +window containing the tab. +- If developer tools are undocked, the `windowId` will the ID of the developer +tools window. + ## Future Work ### Messaging APIs Support `ContextId`s as Target @@ -278,17 +296,6 @@ like to add these contexts in the future. With the content script additions, we may add new fields to `ExtensionContext`, such as `scriptUrl` (to indicate the content script's source). -### Dev Tools Contexts - -Extensions can use the -[Dev Tools API](https://developer.chrome.com/docs/extensions/mv3/devtools/] to -extend the browser's developer tools. When doing so, these extensions can have -a panel (an extension view) within the developer tools console. These views -are a little different than others, though -- in Chromium, they commit to a -different origin (one with a devtools:-scheme). These are also not currently -returned from `chrome.extension.getViews()`. In the future, we will expand -`runtime.getContexts()` with devtools context types to accommodate these. - ## Footnotes 1: Non-main threads in a From e2992262d726c7823098615902b7db62a165770d Mon Sep 17 00:00:00 2001 From: Sohail Rajdev Date: Wed, 28 Aug 2024 18:39:55 +0530 Subject: [PATCH 2/4] Update link --- proposals/runtime_get_contexts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposals/runtime_get_contexts.md b/proposals/runtime_get_contexts.md index 98175695..86b53f81 100644 --- a/proposals/runtime_get_contexts.md +++ b/proposals/runtime_get_contexts.md @@ -242,8 +242,8 @@ for newly-introduced fields, we use the more intuitive `undefined` state. ### Developer Tools Contexts Extensions can use the -[Dev Tools API](https://developer.chrome.com/docs/extensions/mv3/devtools/) to -extend the browser's developer tools. When doing so, these extensions can run +[Dev Tools API](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/devtools) +to extend the browser's developer tools. When doing so, these extensions can run different types of contexts (page, panel, sidebar). `runtime.getContexts()` returns these contexts with the `DEVELOPER_TOOLS` context type. From 2622ae025e1b6a0c495bf485a111fe4196d68987 Mon Sep 17 00:00:00 2001 From: Sohail Rajdev Date: Wed, 28 Aug 2024 19:09:58 +0530 Subject: [PATCH 3/4] Document frameId --- proposals/runtime_get_contexts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposals/runtime_get_contexts.md b/proposals/runtime_get_contexts.md index 86b53f81..be7f0fa3 100644 --- a/proposals/runtime_get_contexts.md +++ b/proposals/runtime_get_contexts.md @@ -247,8 +247,8 @@ to extend the browser's developer tools. When doing so, these extensions can run different types of contexts (page, panel, sidebar). `runtime.getContexts()` returns these contexts with the `DEVELOPER_TOOLS` context type. -- These contexts have a `tabId` of -1 as these contexts are not hosted inside -a tab. +- These contexts have `tabId` and `frameId` as -1 as these contexts are not +hosted inside a tab. - If developer tools are docked to a tab, the `windowId` will be the ID of the window containing the tab. - If developer tools are undocked, the `windowId` will the ID of the developer From 33a9bb32e4bf4f24d01201bc726a5d4da7afdc49 Mon Sep 17 00:00:00 2001 From: Sohail Rajdev Date: Fri, 30 Aug 2024 11:15:50 +0530 Subject: [PATCH 4/4] Mention the fields which do not need special handling --- proposals/runtime_get_contexts.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/proposals/runtime_get_contexts.md b/proposals/runtime_get_contexts.md index be7f0fa3..8268ab65 100644 --- a/proposals/runtime_get_contexts.md +++ b/proposals/runtime_get_contexts.md @@ -254,6 +254,9 @@ window containing the tab. - If developer tools are undocked, the `windowId` will the ID of the developer tools window. +Other fields (`contextId`, `documentId`, `documentUrl`, `documentOrigin`, +`incognito`) are populated as expected. No special handling is done for them. + ## Future Work ### Messaging APIs Support `ContextId`s as Target