MDN self-hosted library · e01.org

extension.getBackgroundPage()

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
// background.js

function foo() {
  console.log("I'm defined in background.js");
}
js
// popup.js

let page = browser.extension.getBackgroundPage();
page.foo(); // -> "I'm defined in background.js"