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
.
var evaluating = browser.devtools.panels.setExpression(
表达式
,
// string
rootTitle
// string
)
表达式
string
. The expression to evaluate.
rootTitle
可选
string. The title of the root of the tree in which results are displayed.
A
Promise
that will be fulfilled with no arguments, once the expression has been evaluated.
BCD tables only load in the browser
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);
注意:
This API is based on Chromium's
chrome.devtools.panels
API。
最后修改: , 由 MDN 贡献者