-
Notifications
You must be signed in to change notification settings - Fork 542
Break out "Custom DevTools sample" from "Create DevTools extension" #3616
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
Draft
mikehoffms
wants to merge
12
commits into
main
Choose a base branch
from
user/mikehoffms/devtools-extension
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6ba16f0
touch article
mikehoffms f2f7875
move pngs
mikehoffms 8931999
My tasks page
mikehoffms 8a30f69
finish Sample article
mikehoffms e60ed8e
alt text
mikehoffms 5504798
del 4 old rows
mikehoffms ec28cd2
arrange code into code file
mikehoffms 03c5c44
linkfix
mikehoffms 59a4713
Console step
mikehoffms 4432ef5
png in short section
mikehoffms e22cfa8
dedup close/reopen
mikehoffms c5c217d
Merge branch 'main' into user/mikehoffms/devtools-extension
mikehoffms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes
Binary file added
BIN
+43.7 KB
...xtensions/developer-guide/devtools-extension-images/custom-tab-activity-bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-49 KB
.../developer-guide/devtools-extension-images/devtools-extension-show-greeting.png
Binary file not shown.
Binary file removed
BIN
-43.2 KB
...guide/devtools-extension-images/devtools-extension-show-position-in-console.png
Binary file not shown.
Binary file removed
BIN
-50.3 KB
.../developer-guide/devtools-extension-images/devtools-extension-show-position.png
Binary file not shown.
Binary file removed
BIN
-46.1 KB
...veloper-guide/devtools-extension-images/devtools-extension-with-memory-info.png
Binary file not shown.
Binary file removed
BIN
-40.6 KB
...ons/developer-guide/devtools-extension-images/devtools-extension-with-panel.png
Binary file not shown.
Binary file removed
BIN
-76.5 KB
...nsions/developer-guide/devtools-extension-images/devtools-main-toolbar-tabs.png
Binary file not shown.
Binary file removed
BIN
-65.5 KB
...eveloper-guide/devtools-extension-images/edge-extensions-page-reload-button.png
Binary file not shown.
Binary file removed
BIN
-53.9 KB
...e/extensions/developer-guide/devtools-extension-images/edge-extensions-page.png
Binary file not shown.
Binary file removed
BIN
-44.6 KB
.../extensions/developer-guide/devtools-extension-images/solution-sample-panel.png
Binary file not shown.
570 changes: 66 additions & 504 deletions
570
microsoft-edge/extensions/developer-guide/devtools-extension.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+175 KB
...osoft-edge/extensions/samples/custom-devtools-tool-code-images/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+764 Bytes
microsoft-edge/extensions/samples/custom-devtools-tool-code-images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
461 changes: 461 additions & 0 deletions
461
microsoft-edge/extensions/samples/custom-devtools-tool-code.md
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+38.8 KB
microsoft-edge/extensions/samples/custom-devtools-tool-images/alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+401 Bytes
microsoft-edge/extensions/samples/custom-devtools-tool-images/console-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.6 KB
...dge/extensions/samples/custom-devtools-tool-images/console-tool-coordinates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+522 Bytes
microsoft-edge/extensions/samples/custom-devtools-tool-images/custom-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.7 KB
...edge/extensions/samples/custom-devtools-tool-images/custom-tab-activity-bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.9 KB
...edge/extensions/samples/custom-devtools-tool-images/custom-tool-coordinates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.4 KB
microsoft-edge/extensions/samples/custom-devtools-tool-images/custom-tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+94.8 KB
...ft-edge/extensions/samples/custom-devtools-tool-images/edge-extensions-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+300 Bytes
...soft-edge/extensions/samples/custom-devtools-tool-images/load-unpacked-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.8 KB
microsoft-edge/extensions/samples/custom-devtools-tool-images/memory-updating.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.2 KB
...ft-edge/extensions/samples/custom-devtools-tool-images/modified-custom-tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+184 Bytes
microsoft-edge/extensions/samples/custom-devtools-tool-images/more-tools-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+69.9 KB
microsoft-edge/extensions/samples/custom-devtools-tool-images/panel-html.png
Oops, something went wrong.
Binary file added
BIN
+96.2 KB
...-edge/extensions/samples/custom-devtools-tool-images/reload-modified-sample.png
Oops, something went wrong.
Binary file added
BIN
+609 Bytes
...-edge/extensions/samples/custom-devtools-tool-images/settings-and-more-icon.png
Oops, something went wrong.
Binary file added
BIN
+397 Bytes
...oft-edge/extensions/samples/custom-devtools-tool-images/show-in-folder-icon.png
Oops, something went wrong.
298 changes: 298 additions & 0 deletions
298
microsoft-edge/extensions/samples/custom-devtools-tool.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,298 @@ | ||
| --- | ||
| title: "Sample: Custom DevTools tool" | ||
| description: Microsoft Edge extension adding a Custom tool in DevTools, including Activity Bar tab and panel. Call DevTools API; send message to any inspected page; send message from inspected page to DevTools. | ||
| author: MSEdgeTeam | ||
| ms.author: msedgedevrel | ||
| ms.topic: conceptual | ||
| ms.service: microsoft-edge | ||
| ms.subservice: extensions | ||
| ms.date: 10/27/2025 | ||
| --- | ||
| # Sample: Custom DevTools tool | ||
|
|
||
| The DevTools Extension sample is a Microsoft Edge extension that adds a **Custom** tool in Microsoft Edge DevTools, including a tab in the **Activity Bar**, and a panel below the tab. | ||
|
|
||
| * The **Custom** DevTools tool calls the DevTools API to display memory information. | ||
|
|
||
| * The webpage under inspection, and the **Custom** DevTools tool, send messages back and forth, in two-way communication. | ||
|
|
||
| See also: | ||
| * [Overview of DevTools](../../devtools/overview.md)<!-- long jump --> | ||
| * [Create a DevTools extension, adding a custom tool tab and panel](../developer-guide/devtools-extension.md) | ||
| * [Code for Custom DevTools tool](../samples/custom-devtools-tool-code.md) | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Preview of the sample | ||
|
|
||
| The "DevTools Extension" sample adds a **Custom** tool tab and panel in DevTools within Microsoft Edge: | ||
|
|
||
|  | ||
|
|
||
|
|
||
| <!-- ------------------------------ --> | ||
| #### Display memory information | ||
|
|
||
| The **Custom** tool calls the DevTools API (`chrome.system.memory.getInfo((data)`) to retrieve and display memory information. | ||
|
|
||
|
|
||
| <!-- ------------------------------ --> | ||
| #### Send message from DevTools to inspected page | ||
|
|
||
| The **Custom** tool in DevTools has a button that sends a message to the inspected webpage. The inspected webpage then displays a JavaScript alert dialog: | ||
|
|
||
|  | ||
|
|
||
|
|
||
| <!-- ------------------------------ --> | ||
| #### Send message from inspected page to DevTools | ||
|
|
||
| Clicking around within the inspected webpage sends a message to DevTools. The sample uses a content script to send a message (the clicked coordinates) from the inspected webpage (any webpage) to the **Custom** DevTools tool and the **Console** tool in DevTools. | ||
|
|
||
| The **Custom** tool displays the coordinates information from the message: | ||
|
|
||
|  | ||
|
|
||
| The **Console** tool displays the coordinates information from the message: | ||
|
|
||
|  | ||
|
|
||
| Download, install, use, and modify the sample, per the below sections. | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Step 1: Download the sample | ||
|
|
||
| If not done yet, download the "main" branch of the Demos repo, or clone (or fork and clone) the repo. Downloading the repo is simplest, and is described below. | ||
|
|
||
| Download the "main" branch of the Demos repo, as follows: | ||
|
|
||
| 1. In Microsoft Edge, go to the [MicrosoftEdge / Demos](https://github.com/MicrosoftEdge/Demos) repo. | ||
|
|
||
| 1. Click the down arrow in the **Code** button, and then select **Download ZIP**. | ||
|
|
||
| 1. In Microsoft Edge, the **Downloads** dialog shows `Demos-main.zip`. "-main" is added, meaning a static snapshot of the "main" branch of the repo. | ||
|
|
||
| 1. Hover to the right of `Demos-main.zip`, and then click the **Show in folder**  button. | ||
|
|
||
| File Explorer opens, displaying the **Downloads** folder. | ||
|
|
||
| 1. Right-click `Demos-main.zip`, and then select **Extract all**. | ||
|
|
||
| The **Extract Compressed (Zipped) Folders** dialog opens. | ||
|
|
||
| 1. Click the **Extract** button. | ||
|
|
||
| The **% complete** dialog opens, and then finishes. | ||
|
|
||
| 1. Move the `Demos-main` folder to a GitHub repos location, such as `C:\Users\localAccount\GitHub`. | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Step 2: Install the extension to add the tool in DevTools | ||
|
|
||
| 1. In Microsoft Edge, select **Settings and more** (), hover over **Extensions**, and then select **Manage extensions**. | ||
|
|
||
| The **Extensions** tab and page opens (`edge://extensions`). | ||
|
|
||
| 1. Click  **Load unpacked**. | ||
|
|
||
| The **Select the extension directory** dialog opens. | ||
|
|
||
| 1. Navigate to the `/Demos-main/devtools-extension` folder, such as `C:\Users\localAccount\GitHub\Demos-main\devtools-extension\`, and then click the **Select Folder** button.<!-- actually used forked cloned /Demos/ dir, a working branch, which has latest version of sample --> | ||
|
|
||
| The **Custom DevTools Tool** card is displayed: | ||
|
|
||
|  | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Step 3: Select the Custom tool in DevTools | ||
|
|
||
| 1. In Microsoft Edge, go to a webpage, such as the [To Do app](https://microsoftedge.github.io/Demos/demo-to-do/), in a new window or tab. | ||
|
|
||
| The **Custom** DevTools tool requires a webpage, not an empty tab. | ||
|
|
||
| 1. Right-click the webpage, and then select **Inspect**. | ||
|
|
||
| DevTools opens. | ||
|
|
||
| 1. In the **Activity Bar** of DevTools, click the **Custom** () tool's tab. | ||
|
|
||
| The **Custom** tool tab and panel are displayed: | ||
|
|
||
|  | ||
|
|
||
| If the **Custom** () tool's tab isn't visible, do any of the following: | ||
|
|
||
| * Click the **More tools** () button, and then select  **Custom**. | ||
|
|
||
| * Make DevTools wider, and then click the **Custom** () tool's tab. | ||
|
|
||
| The custom DevTools page has several sections: | ||
|
|
||
| * Memory display information. | ||
|
|
||
| * A button to send a message from DevTools to the inspected webpage, to make the page display a JavaScript `alert` dialog. | ||
|
|
||
| * A **Coordinates** display area, to send a message from the inspected webpage to the DevTools **Console** and **Custom** tools. | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Step 4: View memory information from a DevTools API call | ||
|
|
||
| * In the **Custom** tool, next to **Available Memory Capacity**, observe the once-per-second updating of the value: | ||
|
|
||
|  | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Step 5: Send message from DevTools to inspected page | ||
|
|
||
| 1. In the **Custom** tool, click the **Say Hello** button. | ||
|
|
||
| A JavaScript `alert` dialog opens, displaying the message: "Hello from the DevTools extension!" | ||
|
|
||
|  | ||
|
|
||
| DevTools sends a message to the inspected webpage, causing JavaScript to display an alert. | ||
|
|
||
| 1. Click the **OK** button. | ||
|
|
||
| The dialog closes. | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Step 6: Send message from inspected page to DevTools | ||
|
|
||
| 1. In the inspected webpage, click various spots. | ||
|
|
||
| In the **Custom** tool, next to **Coordinates**, the coordinates are displayed and updated while you click around: | ||
|
|
||
|  | ||
|
|
||
| 1. In DevTools, in the **Activity Bar**, select the **Console** () tool. | ||
|
|
||
| 1. In the inspected webpage, click various spots. | ||
|
|
||
| The clicked coordinates are displayed in the **Console**: | ||
|
|
||
|  | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Step 7: Modify the Custom tool | ||
|
|
||
| 1. If not done already, install [Visual Studio Code](https://code.visualstudio.com). | ||
|
|
||
| 1. Open Visual Studio Code. | ||
|
|
||
| 1. Click the **File** menu, and then click **Open Folder**. | ||
|
|
||
| The **Open Folder** dialog opens. | ||
|
|
||
| 1. Navigate to the `/Demos-main/devtools-extension/` folder, such as `C:\Users\localAccount\GitHub\Demos-main\devtools-extension\`, and then click the **Select Folder** button.<!-- actually used forked cloned /Demos/ dir, a working branch, which has latest version of sample --> | ||
|
|
||
| A dialog opens, asking whether to open the repo in the parent folder. | ||
|
|
||
| 1. Click the **Yes** button. | ||
|
|
||
| In the **Explorer** pane, the `/devtools-extension/` folder is displayed. | ||
|
|
||
| 1. Click `panel.html`. | ||
|
|
||
| `panel.html` is opened for editing: | ||
|
|
||
|  | ||
|
|
||
| 1. Add "My" to the `<h2>` heading; change from: | ||
|
|
||
| ```html | ||
| <h2>Custom DevTools Tool</h2> | ||
| ``` | ||
|
|
||
| to: | ||
|
|
||
| ```html | ||
| <h2>My Custom DevTools Tool</h2> | ||
| ``` | ||
|
|
||
| 1. Save `panel.html`. | ||
|
|
||
| 1. In the **Explorer** pane, click `manifest.json`. | ||
|
|
||
| `manifest.json` is opened for editing. | ||
|
|
||
| 1. Add "My" to the `name`; change from: | ||
|
|
||
| ```json | ||
| "name": "Custom DevTools Tool", | ||
| ``` | ||
|
|
||
| to: | ||
|
|
||
| ```json | ||
| "name": "My Custom DevTools Tool", | ||
| ``` | ||
|
|
||
| 1. Save `manifest.json`. | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Step 8: Reload the modified Custom tool | ||
|
|
||
| 1. In Microsoft Edge, select **Settings and more** (), hover over **Extensions**, and then select **Manage extensions**. | ||
|
|
||
| The **Extensions** tab and page opens (`edge://extensions`). | ||
|
|
||
| 1. In the **Custom DevTools Tool** card, click the **Reload** link. | ||
|
|
||
| The card now shows **My Custom DevTools Tool** as the name of the extension: | ||
|
|
||
|  | ||
|
|
||
| An **Errors** link might appear in the card, displaying "Uncaught Error: Extension context invalidated", because the sample was modified while still in use. If you want to avoid this error, you can click **Remove** in the **Custom DevTools Tool** card, and then click **Load unpacked**. | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## Step 9: Use the modified Custom tool | ||
|
|
||
| 1. Go to a webpage, such as the [To Do app](https://microsoftedge.github.io/Demos/demo-to-do/), in a new window or tab. | ||
|
|
||
| The **Custom** DevTools tool requires a webpage, not an empty tab. | ||
|
|
||
| 1. Right-click the webpage, and then select **Inspect**. | ||
|
|
||
| DevTools opens. | ||
|
|
||
| 1. In the **Activity Bar** of DevTools, click the **Custom** () tool's tab. | ||
|
|
||
| The **Custom** tool is displayed, with the word **My** added to the heading in the panel: | ||
|
|
||
|  | ||
|
|
||
| If the title still says **Custom DevTools Tool** instead of **My Custom DevTools Tool**, close and reopen DevTools. | ||
|
|
||
| If the **Custom** () tool's tab isn't visible, do any of the following: | ||
|
|
||
| * Click the **More tools** () button, and then select  **Custom**. | ||
|
|
||
| * Make DevTools wider, and then click the **Custom** () tool's tab. | ||
|
|
||
| This is the end of the steps to use and modify the DevTools Extension sample. Next, you can study [Code for Custom DevTools tool](../samples/custom-devtools-tool-code.md). | ||
|
|
||
|
|
||
| <!-- ====================================================================== --> | ||
| ## See also | ||
| <!-- all links in article --> | ||
|
|
||
| * [Overview of DevTools](../../devtools/overview.md) | ||
| * [Create a DevTools extension, adding a custom tool tab and panel](../developer-guide/devtools-extension.md) | ||
| * [Code for Custom DevTools tool](../samples/custom-devtools-tool-code.md) | ||
|
|
||
| GitHub: | ||
| * [MicrosoftEdge / Demos](https://github.com/MicrosoftEdge/Demos) repo. | ||
| * [To Do app](https://microsoftedge.github.io/Demos/demo-to-do/) | ||
|
|
||
| Tools: | ||
| * [Visual Studio Code](https://code.visualstudio.com) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LINK to https://developer.chrome.com/docs/extensions/reference/api/system/memory