summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/general/browser_web_channel_iframe.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /browser/base/content/test/general/browser_web_channel_iframe.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/base/content/test/general/browser_web_channel_iframe.html')
-rw-r--r--browser/base/content/test/general/browser_web_channel_iframe.html96
1 files changed, 96 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_web_channel_iframe.html b/browser/base/content/test/general/browser_web_channel_iframe.html
new file mode 100644
index 000000000..7900e7530
--- /dev/null
+++ b/browser/base/content/test/general/browser_web_channel_iframe.html
@@ -0,0 +1,96 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>web_channel_test (iframe)</title>
+</head>
+<body>
+<script>
+ var REDIRECTED_IFRAME_SRC_ROOT = "http://example.org/browser/browser/base/content/test/general/browser_web_channel_iframe.html";
+
+ window.onload = function() {
+ var testName = window.location.search.replace(/^\?/, "");
+ switch (testName) {
+ case "iframe":
+ test_iframe();
+ break;
+ case "iframe_pre_redirect":
+ test_iframe_pre_redirect();
+ break;
+ case "iframe_post_redirect":
+ test_iframe_post_redirect();
+ break;
+ default:
+ throw new Error(`INVALID TEST NAME ${testName}`);
+ }
+ };
+
+ function test_iframe() {
+ var firstMessage = new window.CustomEvent("WebChannelMessageToChrome", {
+ detail: JSON.stringify({
+ id: "twoway",
+ message: {
+ command: "one",
+ },
+ })
+ });
+
+ window.addEventListener("WebChannelMessageToContent", function(e) {
+ var secondMessage = new window.CustomEvent("WebChannelMessageToChrome", {
+ detail: JSON.stringify({
+ id: "twoway",
+ message: {
+ command: "two",
+ detail: e.detail.message,
+ },
+ }),
+ });
+
+ if (!e.detail.message.error) {
+ window.dispatchEvent(secondMessage);
+ }
+ }, true);
+
+ window.dispatchEvent(firstMessage);
+ }
+
+
+ function test_iframe_pre_redirect() {
+ var firstMessage = new window.CustomEvent("WebChannelMessageToChrome", {
+ detail: JSON.stringify({
+ id: "pre_redirect",
+ message: {
+ command: "redirecting",
+ },
+ }),
+ });
+ window.dispatchEvent(firstMessage);
+ document.location = REDIRECTED_IFRAME_SRC_ROOT + "?iframe_post_redirect";
+ }
+
+ function test_iframe_post_redirect() {
+ window.addEventListener("WebChannelMessageToContent", function(e) {
+ var echoMessage = new window.CustomEvent("WebChannelMessageToChrome", {
+ detail: JSON.stringify({
+ id: "post_redirect",
+ message: e.detail.message,
+ }),
+ });
+
+ window.dispatchEvent(echoMessage);
+ }, true);
+
+ // Let the test parent know the page has loaded and is ready to echo events
+ var loadedMessage = new window.CustomEvent("WebChannelMessageToChrome", {
+ detail: JSON.stringify({
+ id: "post_redirect",
+ message: {
+ command: "loaded",
+ },
+ }),
+ });
+ window.dispatchEvent(loadedMessage);
+ }
+</script>
+</body>
+</html>