aboutsummaryrefslogtreecommitdiff
path: root/tools/addon-sdk-1.12/data/test-page-worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/addon-sdk-1.12/data/test-page-worker.js')
-rw-r--r--tools/addon-sdk-1.12/data/test-page-worker.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/addon-sdk-1.12/data/test-page-worker.js b/tools/addon-sdk-1.12/data/test-page-worker.js
new file mode 100644
index 0000000..d59ccae
--- /dev/null
+++ b/tools/addon-sdk-1.12/data/test-page-worker.js
@@ -0,0 +1,29 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+// get title directly
+self.postMessage(["assertEqual", document.title, "Page Worker test",
+ "Correct page title accessed directly"]);
+
+// get <p> directly
+let p = document.getElementById("paragraph");
+self.postMessage(["assert", !!p, "<p> can be accessed directly"]);
+self.postMessage(["assertEqual", p.firstChild.nodeValue,
+ "Lorem ipsum dolor sit amet.",
+ "Correct text node expected"]);
+
+// Modify page
+let div = document.createElement("div");
+div.setAttribute("id", "block");
+div.appendChild(document.createTextNode("Test text created"));
+document.body.appendChild(div);
+
+// Check back the modification
+div = document.getElementById("block");
+self.postMessage(["assert", !!div, "<div> can be accessed directly"]);
+self.postMessage(["assertEqual", div.firstChild.nodeValue,
+ "Test text created", "Correct text node expected"]);
+self.postMessage(["done"]);
+