devtools.panels.ElementsPanel.setExpression()
Evaluates an expression in the context of the inspected page, and displays the result in the extension sidebar pane.
The expression's execution context is the same as that for inspectedWindow.eval()
.
JSON objects and DOM nodes are displayed as an expandable tree, as in the JSON viewer in Firefox. You can optionally specify a rootTitle
string: this will be displayed as the title of the tree's root.
This is an asynchronous function that returns a Promise
.
Syntax
var evaluating = browser.devtools.panels.setExpression(
expression, // string
rootTitle // string
)
Parameters
Return value
A Promise
that will be fulfilled with no arguments, once the expression has been evaluated.
Browser compatibility
Report problems with this compatibility data on GitHubwebextensions-desktop | webextensions-mobile | |||||
---|---|---|---|---|---|---|
setExpression | ChromeFull supportYes
| EdgeFull support79
| FirefoxFull support57
| OperaFull supportYes | SafariNo supportNo | Firefox for AndroidNo supportNo |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Examples
This code creates a sidebar pane that displays the tagName
of the currently selected element:
function onCreated(sidebarPane) {
browser.devtools.panels.elements.onSelectionChanged.addListener(() => {
const exp = "$0 && $0.tagName";
const title = "Selected Element tagName";
sidebarPane.setExpression(exp, title);
});
}
browser.devtools.panels.elements.createSidebarPane("My pane").then(onCreated);
Acknowledgements
This API is based on Chromium's chrome.devtools.panels
API.