// sender: browser.runtime.id === "blue@mozilla.org"
// Send a message to the extension whose ID is "red@mozilla.org"
browser.runtime.sendMessage("red@mozilla.org", "my message");runtime.onMessageExternal / notebook
runtime.onMessageExternal
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
// recipient: browser.runtime.id === "red@mozilla.org"
function handleMessage(message, sender) {
// check that the message is from "blue@mozilla.org"
if (sender.id === "blue@mozilla.org") {
// process message
}
}
browser.runtime.onMessageExternal.addListener(handleMessage);