docs.rodeo

MDN Web Docs mirror

devtools.panels.create()

{{AddonSidebar}} 

Adds a new panel to the devtools.

This function takes: a title, a URL to an icon file, and a URL to an HTML file. It creates a new panel in the devtools, whose content is specified by the HTML file. It returns a Promise that resolves to an ExtensionPanel object representing the new panel.

Syntax

let creating = browser.devtools.panels.create(
  title,       // string
  iconPath,    // string
  pagePath     // string
)

Parameters

Return value

A Promise that will be fulfilled with an ExtensionPanel object representing the new panel.

Browser compatibility

{{Compat}} 

Examples

Create a new panel, and add listeners to its onShown and onHidden events:

function handleShown() {
  console.log("panel is being shown");
}

function handleHidden() {
  console.log("panel is being hidden");
}

browser.devtools.panels
  .create(
    "My Panel", // title
    "/icons/star.png", // icon
    "/devtools/panel/panel.html", // content
  )
  .then((newPanel) => {
    newPanel.onShown.addListener(handleShown);
    newPanel.onHidden.addListener(handleHidden);
  });

{{WebExtExamples}} 

[!NOTE] This API is based on Chromium’s chrome.devtools.panels API.

In this article

View on MDN