diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 0000000..55cf05b --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,16 @@ + + +
+ + + + + + +content script DOM accessThis is a web page for testing the kind of access content scripts get to the web pages they run inside. +The page includes a page script, which does three things: +
+ +
+var p = document.createElement("p");
+p.textContent = "This paragraph was added by a page script.";
+p.setAttribute("id", "page-script-para");
+document.body.appendChild(p);
+
+ +window.foo = "This global variable was added by a page script"; ++
+window.confirm = function() {
+ alert("The page script has also redefined 'confirm'");
+}
+
+ If you now install the content-scripts extension, and reload the page, you'll now see two columns of buttons underneath this text.
+ +Each column contains three buttons:
+The exact same code is running in each column. But the left-hand column is running in the page script, while the right-hand button is running in the content script. So you'll see the following:
+ +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.
+ + + + + + diff --git a/index.md b/index.md new file mode 100644 index 0000000..0d6905d --- /dev/null +++ b/index.md @@ -0,0 +1,3 @@ +--- +layout: default +---