This page demonstrates messaging between page scripts and content scripts.

To try it out, first install the WebExtension from https://github.com/mdn/webextensions-examples/tree/master/page-to-extension-messaging, then reload this page.

Clicking one button sends a message from the page script to the content script: the content script just displays an alert when it receives the message. Clicking the other button sends a message the other way.