Description
Use the chrome.devtools.panels API to integrate your extension into Developer Tools window UI: create your own panels, access existing panels, and add sidebars.
Each extension panel and sidebar is displayed as a separate HTML page. All extension pages displayed
in the Developer Tools window have access to all parts of the chrome.devtools API, as well as all
other extension APIs.
You can use the devtools.panels.setOpenResourceHandler method to install a callback function
that handles user requests to open a resource (typically, a click a resource link in the
Developer Tools window). At most one of the installed handlers gets called; users can specify (using
the Developer Tools Settings dialog) either the default behavior or an extension to handle resource
open requests. If an extension calls setOpenResourceHandler() multiple times, only the last
handler is retained.
See DevTools APIs summary for general introduction to using Developer Tools APIs.
Manifest
Example
The following code adds a panel contained in Panel.html, represented by FontPicker.png on the
Developer Tools toolbar and labeled as Font Picker:
chrome.devtools.panels.create("Font Picker",
                              "FontPicker.png",
                              "Panel.html",
                              function(panel) { ... });
The following code adds a sidebar pane contained in Sidebar.html and titled Font Properties to
the Elements panel, then sets its height to 8ex:
chrome.devtools.panels.elements.createSidebarPane("Font Properties",
  function(sidebar) {
    sidebar.setPage("Sidebar.html");
    sidebar.setHeight("8ex");
  }
);
The screenshot illustrates the effect this example would have on Developer Tools window:
 
  To try this API, install the devtools panels API example from the chrome-extension-samples repository.
Types
Button
A button created by the extension.
Properties
- 
    onClickedEvent<functionvoidvoid> Fired when the button is clicked. The onClicked.addListenerfunction looks like:(callback: function) => {...} - 
    callbackfunction The callbackparameter looks like:() => void 
 
- 
    
- 
    updatevoid Updates the attributes of the button. If some of the arguments are omitted or null, the corresponding attributes are not updated.The updatefunction looks like:(iconPath?: string, tooltipText?: string, disabled?: boolean) => {...} - 
    iconPathstring optional Path to the new icon of the button. 
- 
    tooltipTextstring optional Text shown as a tooltip when user hovers the mouse over the button. 
- 
    disabledboolean optional Whether the button is disabled. 
 
- 
    
ElementsPanel
Represents the Elements panel.
Properties
- 
    onSelectionChangedEvent<functionvoidvoid> Fired when an object is selected in the panel. The onSelectionChanged.addListenerfunction looks like:(callback: function) => {...} - 
    callbackfunction The callbackparameter looks like:() => void 
 
- 
    
- 
    createSidebarPanevoid Creates a pane within panel's sidebar. The createSidebarPanefunction looks like:(title: string, callback?: function) => {...} - 
    titlestring Text that is displayed in sidebar caption. 
- 
    callbackfunction optional The callbackparameter looks like:(result: ExtensionSidebarPane) => void - 
    resultAn ExtensionSidebarPane object for created sidebar pane. 
 
- 
    
 
- 
    
ExtensionPanel
Represents a panel created by an extension.
Properties
- 
    onHiddenEvent<functionvoidvoid> Fired when the user switches away from the panel. The onHidden.addListenerfunction looks like:(callback: function) => {...} - 
    callbackfunction The callbackparameter looks like:() => void 
 
- 
    
- 
    onSearchEvent<functionvoidvoid> Fired upon a search action (start of a new search, search result navigation, or search being canceled). The onSearch.addListenerfunction looks like:(callback: function) => {...} - 
    callbackfunction The callbackparameter looks like:(action: string, queryString?: string) => void - 
    actionstring 
- 
    queryStringstring optional 
 
- 
    
 
- 
    
- 
    onShownEvent<functionvoidvoid> Fired when the user switches to the panel. The onShown.addListenerfunction looks like:(callback: function) => {...} - 
    callbackfunction The callbackparameter looks like:(window: Window) => void - 
    windowWindow 
 
- 
    
 
- 
    
- 
    createStatusBarButtonvoid Appends a button to the status bar of the panel. The createStatusBarButtonfunction looks like:(iconPath: string, tooltipText: string, disabled: boolean) => {...} - 
    iconPathstring Path to the icon of the button. The file should contain a 64x24-pixel image composed of two 32x24 icons. The left icon is used when the button is inactive; the right icon is displayed when the button is pressed. 
- 
    tooltipTextstring Text shown as a tooltip when user hovers the mouse over the button. 
- 
    disabledboolean Whether the button is disabled. 
 - 
            returns
 
- 
    
- 
    showvoid Chrome 140+Shows the panel by activating the corresponding tab. The showfunction looks like:() => {...}
ExtensionSidebarPane
A sidebar created by the extension.
Properties
- 
    onHiddenEvent<functionvoidvoid> Fired when the sidebar pane becomes hidden as a result of the user switching away from the panel that hosts the sidebar pane. The onHidden.addListenerfunction looks like:(callback: function) => {...} - 
    callbackfunction The callbackparameter looks like:() => void 
 
- 
    
- 
    onShownEvent<functionvoidvoid> Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it. The onShown.addListenerfunction looks like:(callback: function) => {...} - 
    callbackfunction The callbackparameter looks like:(window: Window) => void - 
    windowWindow 
 
- 
    
 
- 
    
- 
    setExpressionvoid Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane. The setExpressionfunction looks like:(expression: string, rootTitle?: string, callback?: function) => {...} - 
    expressionstring An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch. 
- 
    rootTitlestring optional An optional title for the root of the expression tree. 
- 
    callbackfunction optional The callbackparameter looks like:() => void 
 
- 
    
- 
    setHeightvoid Sets the height of the sidebar. The setHeightfunction looks like:(height: string) => {...} - 
    heightstring A CSS-like size specification, such as '100px'or'12ex'.
 
- 
    
- 
    setObjectvoid Sets a JSON-compliant object to be displayed in the sidebar pane. The setObjectfunction looks like:(jsonObject: string, rootTitle?: string, callback?: function) => {...} - 
    jsonObjectstring An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client). 
- 
    rootTitlestring optional An optional title for the root of the expression tree. 
- 
    callbackfunction optional The callbackparameter looks like:() => void 
 
- 
    
- 
    setPagevoid Sets an HTML page to be displayed in the sidebar pane. The setPagefunction looks like:(path: string) => {...} - 
    pathstring Relative path of an extension page to display within the sidebar. 
 
- 
    
SourcesPanel
Represents the Sources panel.
Properties
- 
    onSelectionChangedEvent<functionvoidvoid> Fired when an object is selected in the panel. The onSelectionChanged.addListenerfunction looks like:(callback: function) => {...} - 
    callbackfunction The callbackparameter looks like:() => void 
 
- 
    
- 
    createSidebarPanevoid Creates a pane within panel's sidebar. The createSidebarPanefunction looks like:(title: string, callback?: function) => {...} - 
    titlestring Text that is displayed in sidebar caption. 
- 
    callbackfunction optional The callbackparameter looks like:(result: ExtensionSidebarPane) => void - 
    resultAn ExtensionSidebarPane object for created sidebar pane. 
 
- 
    
 
- 
    
Properties
elements
Elements panel.
Type
sources
Sources panel.
Type
themeName
The name of the color theme set in user's DevTools settings. Possible values: default (the default) and dark.
Type
string
Methods
create()
chrome.devtools.panels.create(
title: string,
iconPath: string,
pagePath: string,
callback?: function,
): void
Creates an extension panel.
Parameters
- 
    titlestring Title that is displayed next to the extension icon in the Developer Tools toolbar. 
- 
    iconPathstring Path of the panel's icon relative to the extension directory. 
- 
    pagePathstring Path of the panel's HTML page relative to the extension directory. 
- 
    callbackfunction optional The callbackparameter looks like:(panel: ExtensionPanel) => void - 
    panelAn ExtensionPanel object representing the created panel. 
 
- 
    
openResource()
chrome.devtools.panels.openResource(
url: string,
lineNumber: number,
columnNumber?: number,
callback?: function,
): void
Requests DevTools to open a URL in a Developer Tools panel.
Parameters
- 
    urlstring The URL of the resource to open. 
- 
    lineNumbernumber Specifies the line number to scroll to when the resource is loaded. 
- 
    columnNumbernumber optional Chrome 114+Specifies the column number to scroll to when the resource is loaded. 
- 
    callbackfunction optional The callbackparameter looks like:() => void 
setOpenResourceHandler()
chrome.devtools.panels.setOpenResourceHandler(
callback?: function,
): void
Specifies the function to be called when the user clicks a resource link in the Developer Tools window. To unset the handler, either call the method with no parameters or pass null as the parameter.
Parameters
- 
    callbackfunction optional The callbackparameter looks like:(resource: Resource, lineNumber: number) => void - 
    resourceA devtools.inspectedWindow.Resourceobject for the resource that was clicked.
- 
    lineNumbernumber Specifies the line number within the resource that was clicked. 
 
-