chrome.devtools.panels
For information on how to use experimental APIs, see the chrome.experimental.* APIs page.
Use the chrome.devtools.panels
module to integrate
your extension into Developer Tools window UI: create your own panels, access
existing panels, and add sidebars.
See DevTools APIs summary for
general introduction to using Developer Tools APIs.
Overview
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
modules in chrome.devtools
API, as well as to
chrome.extension API. Other extension APIs are not
available to the pages within Developer Tools window, but you may invoke them
by sending a request to the background page of your extension, similarly to how
it's done in the content scripts.
You can use the setOpenResourceHandler()
method to install a
callback function that handles user requests to open a resource (typically,
a click on 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.
Examples
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");
});
This screenshot demonstrates the effect the above examples would have on
Developer Tools window:
You can find examples that use this API in
Samples.
API reference: chrome.devtools.panels
Properties
elements
chrome.devtools.panels.elements
elements
Undocumented.
Elements panel.
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Methods
create
void
chrome.devtools.panels.create(, string
title, string
iconPath, string
pagePath, function
callback)
Undocumented.
Creates an extension panel.
Parameters
-
title
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Title that is displayed next to the extension icon in the Developer Tools toolbar.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
iconPath
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Path of the panel's icon relative to the extension directory.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
pagePath
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Path of the panel's HTML page relative to the extension directory.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- A function that is called when the panel is created.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(ExtensionPanel panel) {...};
-
panel
-
Undocumented.
- An ExtensionPanel object representing the created panel.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
setOpenResourceHandler
void
chrome.devtools.panels.setOpenResourceHandler(, function
callback)
Undocumented.
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
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- A function that is called when the user clicks on a valid resource link in Developer Tools window. Note that if the user clicks an invalid URL or an XHR, this function is not called.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(object Resource) {...};
-
Resource
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- A Resource object for the resource that was clicked.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Events
event name
chrome.bookmarksonEvent.addListener(function(Type param1, Type param2) {...}, Type opt_param1, Type opt_param2);
Undocumented.
A description from the json schema def of the event goes here.
Extra parameters to addListener
Listener returns
Types
ElementsPanel
paramName
(
optional
enumerated
Type
array of
object
)
Undocumented.
Represents the Elements panel.
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Methods of ElementsPanel
createSidebarPane
void
elementsPanel.createSidebarPane(, string
title, function
callback)
Undocumented.
Creates a pane within panel's sidebar.
Parameters
-
title
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Text that is displayed in sidebar caption.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- A callback invoked when the sidebar is created.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(ExtensionSidebarPane result) {...};
-
result
-
Undocumented.
- An ExtensionSidebarPane object for created sidebar pane.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Events of ElementsPanel
onSelectionChanged
elementsPanel.onSelectionChanged.addListener(function() {...});
Undocumented.
Fired when an object is selected in the panel.
Extra parameters to addListener
Listener returns
ExtensionPanel
paramName
(
optional
enumerated
Type
array of
object
)
Undocumented.
Represents a panel created by extension.
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Methods of ExtensionPanel
createStatusBarButton
Button
extensionPanel.createStatusBarButton(, string
iconPath, string
tooltipText, boolean
disabled)
Undocumented.
Appends a button to the status bar of the panel.
Parameters
-
iconPath
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- 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.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
tooltipText
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Text shown as a tooltip when user hovers the mouse over the button.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
disabled
(
optional
enumerated
Type
array of
boolean
)
-
Undocumented.
- Whether the button is disabled.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
-
paramName
(
optional
enumerated
Button
array of
paramType
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(ExtensionPanel panel) {...};
-
panel
-
Undocumented.
- An ExtensionPanel object representing the created panel.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Events of ExtensionPanel
onHidden
extensionPanel.onHidden.addListener(function() {...});
Undocumented.
Fired when the user switches away from the panel.
Extra parameters to addListener
Listener returns
onSearch
extensionPanel.onSearch.addListener(function(string action, string queryString) {...});
Undocumented.
Fired upon a search action (start of a new search, search result navigation, or search being canceled).
Listener parameters
-
action
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Type of search action being performed.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
queryString
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Query string (only for 'performSearch').
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Extra parameters to addListener
Listener returns
onShown
extensionPanel.onShown.addListener(function(DOMWindow window) {...});
Undocumented.
Fired when the user switches to the panel.
Listener parameters
-
window
(
optional
enumerated
Type
array of
DOMWindow
)
-
Undocumented.
- The
window
object of panel's page.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Extra parameters to addListener
Listener returns
ExtensionSidebarPane
paramName
(
optional
enumerated
Type
array of
object
)
Undocumented.
A sidebar created by the extension.
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Methods of ExtensionSidebarPane
setExpression
void
extensionSidebarPane.setExpression(, string
expression, string
rootTitle, function
callback)
Undocumented.
Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane.
Parameters
-
expression
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- 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.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
rootTitle
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- An optional title for the root of the expression tree.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- A callback invoked after the sidebar pane is updated with the expression evaluation results.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(null) {...};
-
panel
-
Undocumented.
- An ExtensionPanel object representing the created panel.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
setHeight
void
extensionSidebarPane.setHeight(, string
height)
Undocumented.
Sets the height of the sidebar.
Parameters
-
height
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- A CSS-like size specification, such as
'100px'
or '12ex'
.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(object Resource) {...};
-
Resource
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- A Resource object for the resource that was clicked.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
setObject
void
extensionSidebarPane.setObject(, string
jsonObject, string
rootTitle, function
callback)
Undocumented.
Sets a JSON-compliant object to be displayed in the sidebar pane.
Parameters
-
jsonObject
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client).
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
rootTitle
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- An optional title for the root of the expression tree.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- A callback invoked after the sidebar is updated with the object.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(null) {...};
-
Resource
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- A Resource object for the resource that was clicked.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
setPage
void
extensionSidebarPane.setPage(, string
path)
Undocumented.
Sets an HTML page to be displayed in the sidebar pane.
Parameters
-
path
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Relative path of an extension page to display within the sidebar.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(object Resource) {...};
-
Resource
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- A Resource object for the resource that was clicked.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Events of ExtensionSidebarPane
onHidden
extensionSidebarPane.onHidden.addListener(function() {...});
Undocumented.
Fired when the sidebar pane becomes hidden as a result of the user switching away from the panel that hosts the sidebar pane.
Extra parameters to addListener
Listener returns
onShown
extensionSidebarPane.onShown.addListener(function(DOMWindow window) {...});
Undocumented.
Fired when the sidebar pane becomes visible as a result of user switching to the panel that hosts it.
Listener parameters
-
window
(
optional
enumerated
Type
array of
DOMWindow
)
-
Undocumented.
- The
window
object of the sidebar page, if one was set with the setPage()
method.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Extra parameters to addListener
Listener returns
Button
paramName
(
optional
enumerated
Type
array of
object
)
Undocumented.
A button created by the extension.
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Methods of Button
update
void
button.update(, string
iconPath, string
tooltipText, boolean
disabled)
Undocumented.
Updates the attributes of the button. If some of the arguments are omitted or null
, the corresponding attributes are not updated.
Parameters
-
iconPath
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Path to the new icon of the button.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
tooltipText
(
optional
enumerated
Type
array of
string
)
-
Undocumented.
- Text shown as a tooltip when user hovers the mouse over the button.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
disabled
(
optional
enumerated
Type
array of
boolean
)
-
Undocumented.
- Whether the button is disabled.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(ExtensionPanel panel) {...};
-
panel
-
Undocumented.
- An ExtensionPanel object representing the created panel.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Events of Button
onClicked
button.onClicked.addListener(function() {...});
Undocumented.
Fired when the button is clicked.
Extra parameters to addListener
Listener returns