summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/dom-level0
diff options
context:
space:
mode:
Diffstat (limited to 'dom/tests/mochitest/dom-level0')
-rw-r--r--dom/tests/mochitest/dom-level0/child_ip_address.html39
-rw-r--r--dom/tests/mochitest/dom-level0/file_crossdomainprops_inner.html11
-rw-r--r--dom/tests/mochitest/dom-level0/file_location.html10
-rw-r--r--dom/tests/mochitest/dom-level0/file_separate_post_message_queue.html39
-rw-r--r--dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html19
-rw-r--r--dom/tests/mochitest/dom-level0/framed_location.html11
-rw-r--r--dom/tests/mochitest/dom-level0/idn_child.html97
-rw-r--r--dom/tests/mochitest/dom-level0/iframe1_location_setters.html1
-rw-r--r--dom/tests/mochitest/dom-level0/iframe2_location_setters.html1
-rw-r--r--dom/tests/mochitest/dom-level0/iframe3_location_setters.html1
-rw-r--r--dom/tests/mochitest/dom-level0/innerWidthHeight_script.html31
-rw-r--r--dom/tests/mochitest/dom-level0/mochitest.ini43
-rw-r--r--dom/tests/mochitest/dom-level0/test_background_loading_iframes.html69
-rw-r--r--dom/tests/mochitest/dom-level0/test_crossdomainprops.html36
-rw-r--r--dom/tests/mochitest/dom-level0/test_innerWidthHeight_script.html35
-rw-r--r--dom/tests/mochitest/dom-level0/test_location.html73
-rw-r--r--dom/tests/mochitest/dom-level0/test_location_framed.html31
-rw-r--r--dom/tests/mochitest/dom-level0/test_location_getters.html29
-rw-r--r--dom/tests/mochitest/dom-level0/test_location_sandboxed.html33
-rw-r--r--dom/tests/mochitest/dom-level0/test_location_setters.html79
-rw-r--r--dom/tests/mochitest/dom-level0/test_separate_post_message_queue.html31
-rw-r--r--dom/tests/mochitest/dom-level0/test_setting_document.domain_idn.html153
-rw-r--r--dom/tests/mochitest/dom-level0/test_setting_document.domain_to_shortened_ipaddr.html43
23 files changed, 915 insertions, 0 deletions
diff --git a/dom/tests/mochitest/dom-level0/child_ip_address.html b/dom/tests/mochitest/dom-level0/child_ip_address.html
new file mode 100644
index 0000000000..24c1f0ba30
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/child_ip_address.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Child window at 127.0.0.1</title>
+ <script type="application/javascript">
+function run()
+{
+ var target = document.getElementById("location");
+ target.textContent = location.hostname + ":" + (location.port || 80);
+
+ var message = "child-response";
+
+ var domain = document.domain;
+ if (domain !== "127.0.0.1")
+ message += " wrong-initial-domain(" + domain + ")";
+
+ try
+ {
+ document.domain = "0.0.1";
+ domain = document.domain;
+ message += " ip-address-shortened-to(" + domain + ")";
+ }
+ catch (e)
+ {
+ domain = document.domain;
+ if (domain !== "127.0.0.1")
+ message += " ip-address-mutated-on-throw(" + domain + ")";
+ }
+
+ window.parent.postMessage(message, "http://mochi.test:8888");
+}
+
+window.addEventListener("load", run);
+ </script>
+</head>
+<body>
+<h1 id="location">Somewhere!</h1>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/file_crossdomainprops_inner.html b/dom/tests/mochitest/dom-level0/file_crossdomainprops_inner.html
new file mode 100644
index 0000000000..8ffaa87a97
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/file_crossdomainprops_inner.html
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script>
+ var myVar = 10;
+ </script>
+</head>
+<body>
+inner
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/file_location.html b/dom/tests/mochitest/dom-level0/file_location.html
new file mode 100644
index 0000000000..3a74b32d18
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/file_location.html
@@ -0,0 +1,10 @@
+<html>
+ <script>
+ try {
+ parent.SimpleTest.ok(!("existingprop" in location), "got a new location object in the iframe");
+ } catch (e) {
+ }
+
+ location.iframeprop = 42;
+ </script>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/file_separate_post_message_queue.html b/dom/tests/mochitest/dom-level0/file_separate_post_message_queue.html
new file mode 100644
index 0000000000..ce1494e3d2
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/file_separate_post_message_queue.html
@@ -0,0 +1,39 @@
+<script>
+
+let runnable1 = {
+ run() {
+ window.opener.callOrder.push("Runnable1");
+ }
+}
+
+let runnable2 = {
+ run() {
+ window.opener.callOrder.push("Runnable2");
+ }
+}
+
+let runnable3 = {
+ run() {
+ window.opener.callOrder.push("Runnable3");
+ }
+}
+
+window.onmessage = function () {
+ window.opener.callOrder.push("PostMessage");
+ if (window.loadCount == 1) {
+ window.loadCount += 1;
+ location.reload();
+ } else {
+ window.opener.onDone();
+ }
+};
+
+// Pushed to normal queue
+SpecialPowers.Services.tm.dispatchToMainThread(runnable1);
+// Pushed to idle queue
+window.postMessage("bar", "*");
+// Pushed to normal queue
+SpecialPowers.Services.tm.dispatchToMainThread(runnable2);
+// Pushed to normal queue
+SpecialPowers.Services.tm.dispatchToMainThread(runnable3);
+</script>
diff --git a/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html b/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html
new file mode 100644
index 0000000000..27cc47ca72
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html
@@ -0,0 +1,19 @@
+<html>
+ <body>
+ <script>
+ var onloadFiredAt;
+
+ let start = performance.now();
+ while (performance.now() - start < 5000);
+
+ window.onload = function() {
+ onloadFiredAt = performance.now();
+ }
+
+ window.addEventListener('message', function(event) {
+ window.parent.postMessage(onloadFiredAt, "*");
+ })
+
+ </script>
+ </body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/framed_location.html b/dom/tests/mochitest/dom-level0/framed_location.html
new file mode 100644
index 0000000000..a2b65906f3
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/framed_location.html
@@ -0,0 +1,11 @@
+<script>
+ window.parent.postMessage({
+ "hash": window.location.hash,
+ "host": window.location.host,
+ "hostname": window.location.hostname,
+ "origin": window.location.origin,
+ "pathname": window.location.pathname,
+ "port": window.location.port,
+ "protocol": window.location.protocol,
+ }, "*");
+</script>
diff --git a/dom/tests/mochitest/dom-level0/idn_child.html b/dom/tests/mochitest/dom-level0/idn_child.html
new file mode 100644
index 0000000000..7a44d790ea
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/idn_child.html
@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Child window on a site whose "base" domain contains IDN</title>
+ <script type="application/javascript">
+function run()
+{
+ var target = document.getElementById("location");
+ target.textContent = location.hostname + ":" + (location.port || 80);
+}
+
+function receiveMessage(evt)
+{
+ if (evt.origin !== "http://mochi.test:8888")
+ return;
+
+ var message = evt.data + "-response";
+
+ var domain = document.domain;
+ if (/test$/.test(domain))
+ {
+ if (domain !== "sub1.xn--exaple-kqf.test")
+ message += " wrong-initial-domain(" + domain + ")";
+ }
+ else
+ {
+ if (domain !== "sub1.xn--hxajbheg2az3al.xn--jxalpdlp")
+ message += " wrong-initial-domain(" + domain + ")";
+ }
+
+ switch (location.search)
+ {
+ case "?idn-whitelist":
+ message += idnTest("παράδειγμα.δοκιμή");
+ break;
+
+ case "?punycode-whitelist":
+ message += punycodeTest("xn--hxajbheg2az3al.xn--jxalpdlp");
+ break;
+
+ case "?idn-nowhitelist":
+ message += idnTest("exaмple.test");
+ break;
+
+ case "?punycode-nowhitelist":
+ message += punycodeTest("xn--exaple-kqf.test");
+ break;
+
+ default:
+ message += " unexpected-query(" + location.search + ")";
+ break;
+ }
+
+ evt.source.postMessage(message, evt.origin);
+}
+
+function idnTest(newDomain)
+{
+ var errors = "";
+
+ try
+ {
+ document.domain = newDomain;
+ }
+ catch (e)
+ {
+ errors += " error-thrown-setting-to-idn(" + String(e).split("").join(",") + ")";
+ }
+
+ return errors;
+}
+
+function punycodeTest(newDomain)
+{
+ var errors = "";
+
+ try
+ {
+ document.domain = newDomain;
+ }
+ catch (e)
+ {
+ errors += " error-thrown-setting-to-punycode(" + String(e).split("").join(",") + ")";
+ }
+
+ return errors;
+}
+
+window.addEventListener("message", receiveMessage);
+window.addEventListener("load", run);
+ </script>
+</head>
+<body>
+<h1 id="location">Somewhere!</h1>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/iframe1_location_setters.html b/dom/tests/mochitest/dom-level0/iframe1_location_setters.html
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/iframe1_location_setters.html
@@ -0,0 +1 @@
+1
diff --git a/dom/tests/mochitest/dom-level0/iframe2_location_setters.html b/dom/tests/mochitest/dom-level0/iframe2_location_setters.html
new file mode 100644
index 0000000000..0cfbf08886
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/iframe2_location_setters.html
@@ -0,0 +1 @@
+2
diff --git a/dom/tests/mochitest/dom-level0/iframe3_location_setters.html b/dom/tests/mochitest/dom-level0/iframe3_location_setters.html
new file mode 100644
index 0000000000..00750edc07
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/iframe3_location_setters.html
@@ -0,0 +1 @@
+3
diff --git a/dom/tests/mochitest/dom-level0/innerWidthHeight_script.html b/dom/tests/mochitest/dom-level0/innerWidthHeight_script.html
new file mode 100644
index 0000000000..08f90111df
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/innerWidthHeight_script.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta name="viewport" content="width=320,height=320" />
+ <title>Bug 602580 - Test layout viewport and visual viewport sizes with meta tags and changed innerWidth</title>
+ <script class="testbody" type="text/javascript">
+ function runSubTest()
+ {
+ /* CSS viewport is set the by the meta tag in this document. */
+ window.opener.is(document.documentElement.clientWidth, 320, "CSS viewport width is meta viewport width");
+ window.opener.is(document.documentElement.clientHeight, 320, "CSS viewport height is meta viewport height");
+
+ /* Visual viewport values can be changed by setting window.innerWidth and innerHeight. */
+ var oldWidth = window.innerWidth;
+ var oldHeight = window.innerHeight;
+
+ window.innerWidth = 300;
+ window.opener.is(window.innerWidth, 300, "visual viewport width returns set value");
+ window.innerWidth = oldWidth;
+
+ window.innerHeight = 300;
+ window.opener.is(window.innerHeight, 300, "visual viewport height returns set value");
+ window.innerHeight = oldHeight;
+
+ window.opener.finish();
+ }
+ </script>
+</head>
+<body onload="runSubTest()">
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/mochitest.ini b/dom/tests/mochitest/dom-level0/mochitest.ini
new file mode 100644
index 0000000000..8758c63f45
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/mochitest.ini
@@ -0,0 +1,43 @@
+[DEFAULT]
+support-files =
+ child_ip_address.html
+ file_crossdomainprops_inner.html
+ file_location.html
+ file_separate_post_message_queue.html
+ framed_location.html
+ idn_child.html
+ innerWidthHeight_script.html
+ iframe1_location_setters.html
+ iframe2_location_setters.html
+ iframe3_location_setters.html
+ file_test_background_loading_iframes.html
+
+[test_crossdomainprops.html]
+skip-if =
+ http3
+[test_innerWidthHeight_script.html]
+[test_location.html]
+skip-if =
+ http3
+[test_location_framed.html]
+skip-if =
+ http3
+[test_location_getters.html]
+skip-if =
+ http3
+[test_location_sandboxed.html]
+skip-if =
+ http3
+[test_location_setters.html]
+skip-if =
+ http3
+[test_setting_document.domain_idn.html]
+skip-if =
+ http3
+[test_setting_document.domain_to_shortened_ipaddr.html]
+skip-if =
+ http3
+[test_separate_post_message_queue.html]
+[test_background_loading_iframes.html]
+skip-if =
+ http3
diff --git a/dom/tests/mochitest/dom-level0/test_background_loading_iframes.html b/dom/tests/mochitest/dom-level0/test_background_loading_iframes.html
new file mode 100644
index 0000000000..62488557ec
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_background_loading_iframes.html
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for background loading iframes</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<pre id="test">
+
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+
+var myLoadTime;
+var receivedPostMessage = [];
+
+window.addEventListener('message', function(event) {
+ receivedPostMessage.push(parseInt(event.data));
+ if (receivedPostMessage.length == 3) {
+ if (!myLoadTime){
+ ok(false, "Child iframes are loaded earlier than the parent document");
+ } else {
+ receivedPostMessage.forEach(function(iframeLoadTime, index) {
+ ok(iframeLoadTime, "Iframe load time should not be null");
+ ok(iframeLoadTime >= myLoadTime, "Parent document should be loaded earlier than child iframes");
+ })
+ }
+ SimpleTest.finish();
+ }
+})
+
+window.onload = function() {
+ myLoadTime = performance.now();
+}
+
+SpecialPowers.pushPrefEnv({"set":[["dom.background_loading_iframe", true]]}).then(async function () {
+ await SpecialPowers.promiseTimeout(0);
+
+ var iframe1 = document.createElement("iframe");
+ var iframe2 = document.createElement("iframe");
+ var iframe3 = document.createElement("iframe");
+
+ iframe1.src = "http://example.org:80/tests/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html";
+ iframe2.src = "http://example.org:80/tests/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html";
+ iframe3.src = "http://example.org:80/tests/dom/tests/mochitest/dom-level0/file_test_background_loading_iframes.html";
+
+ iframe1.onload = function() {
+ iframe1.contentWindow.postMessage("test", "*");
+ }
+
+ iframe2.onload = function() {
+ iframe2.contentWindow.postMessage("test", "*");
+ }
+
+ iframe3.onload = function() {
+ iframe3.contentWindow.postMessage("test", "*");
+ }
+
+ document.body.append(iframe1);
+ document.body.append(iframe2);
+ document.body.append(iframe3);
+
+});
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_crossdomainprops.html b/dom/tests/mochitest/dom-level0/test_crossdomainprops.html
new file mode 100644
index 0000000000..e0ee42f081
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_crossdomainprops.html
@@ -0,0 +1,36 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for Cross domain access to properties</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body onload="runTest()">
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<iframe name="frame1" src="file_crossdomainprops_inner.html"></iframe>
+<iframe name="frame2" src="http://example.com/tests/dom/tests/mochitest/dom-level0/file_crossdomainprops_inner.html"></iframe>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+function runTest() {
+ ok(frames.frame1.myVar == 10, "access same domain inner window variable");
+ var otherDomainVar = null;
+ try {
+ otherDomainVar = frames.frame2.myVar;
+ }
+ catch (e) {
+ otherDomainVar = -1;
+ }
+ is(otherDomainVar, -1, "access other domain inner window variable");
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_innerWidthHeight_script.html b/dom/tests/mochitest/dom-level0/test_innerWidthHeight_script.html
new file mode 100644
index 0000000000..eff351dabb
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_innerWidthHeight_script.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Bug 602580 - Test getting and setting innerWidth and Height after using setCSSViewport</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+ <!--
+ This acts funny when run in the normal content frame
+ so instead We load it in a separate window.
+ -->
+</head>
+<body onload="startTest()">
+ <script class="testbody" type="text/javascript">
+ SimpleTest.waitForExplicitFinish();
+ var newWin = null;
+ function runTest() {
+ newWin = window.open("innerWidthHeight_script.html", '_new', 'width=600,height=400');
+ }
+
+ function finish() {
+ newWin.close();
+ SimpleTest.finish();
+ }
+
+ function startTest() {
+ SpecialPowers.pushPrefEnv({"set": [
+ ["dom.disable_window_move_resize", false],
+ ["ui.useOverlayScrollbars", 1],
+ ["dom.meta-viewport.enabled", true],
+ ["dom.window_position_size_properties_replaceable.enabled", false],
+ ]}, runTest);
+ }
+ </script>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_location.html b/dom/tests/mochitest/dom-level0/test_location.html
new file mode 100644
index 0000000000..52106395fd
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_location.html
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for location object behaviors</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+var count = 0;
+var firstlocation;
+var lastlocation;
+
+function runTest() {
+ ++count;
+ if (count == 1) {
+ firstlocation = $('ifr').contentWindow.location;
+ firstlocation.existingprop = 'fail';
+ firstlocation.href = 'file_location.html';
+ return;
+ }
+
+ if (count == 2) {
+ lastlocation = $('ifr').contentWindow.location;
+ is(lastlocation.iframeprop, 42, 'can read the new prop');
+ ok(firstlocation !== lastlocation, 'got a new location object');
+ // firstlocation should still work.
+ ok(firstlocation.href.indexOf('file_location.html'), 'can read location.href');
+ firstlocation.href = 'http://example.com/tests/dom/tests/mochitest/dom-level0/file_location.html';
+ return;
+ }
+
+ if (count == 3) {
+ var permissionDenied = false;
+ try {
+ var foo = $('ifr').contentWindow.location.href == '';
+ } catch (e) {
+ permissionDenied = /Permission denied/.test(e.message);
+ }
+ ok(permissionDenied, 'correctly threw a permission denied security error when reading location.href');
+
+ permissionDenied = false;
+ try {
+ var foo = $('ifr').contentWindow.location.iframeprop == 42;
+ } catch (e) {
+ permissionDenied = /Permission denied/.test(e.message);
+ }
+ ok(permissionDenied, 'correctly threw a permission denied security error an expando on location');
+
+ firstlocation.href = 'http://mochi.test:8888/tests/dom/tests/mochitest/dom-level0/file_location.html';
+ return;
+ }
+
+ is(lastlocation.iframeprop, 42, 'can still read old values of the location object');
+ ok(lastlocation !== $('ifr').contentWindow.location, 'location objects are distinct');
+ ok(firstlocation.href.indexOf('file_location.html'), 'can read location.href');
+
+ SimpleTest.finish();
+}
+
+</script>
+</pre>
+<iframe id="ifr" onload="runTest()"></iframe>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_location_framed.html b/dom/tests/mochitest/dom-level0/test_location_framed.html
new file mode 100644
index 0000000000..35663cf193
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_location_framed.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>MessageEvent tests</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+ <p id="display"></p>
+ <pre id="test">
+ <script>
+ SimpleTest.waitForExplicitFinish();
+
+ window.addEventListener('message', function (e) {
+ console.log(e);
+ console.dir(e);
+ var loc = e.data;
+ is(loc.hash, '', 'Unexpected hash.');
+ is(loc.host, 'mochi.test:8888', 'Unexpected host.');
+ is(loc.hostname, 'mochi.test', 'Unexpected hostname.');
+ is(loc.origin, 'http://mochi.test:8888', 'Unexpected origin.');
+ is(loc.pathname, '/tests/dom/tests/mochitest/dom-level0/framed_location.html', 'Unexpected pathname.');
+ is(loc.port, '8888', 'Unexpected port.');
+ is(loc.protocol, 'http:', 'Unexpected protocol.');
+ SimpleTest.finish();
+ });
+ </script>
+ <iframe src="framed_location.html"></iframe>
+ </pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_location_getters.html b/dom/tests/mochitest/dom-level0/test_location_getters.html
new file mode 100644
index 0000000000..1f1ce1215b
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_location_getters.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>MessageEvent tests</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body onload="test()">
+ <p id="display"></p>
+ <pre id="test">
+ <script>
+ SimpleTest.waitForExplicitFinish();
+
+ function test()
+ {
+ var loc = window.location;
+ is(loc.hash, '', 'Unexpected hash.');
+ is(loc.host, 'mochi.test:8888', 'Unexpected host.');
+ is(loc.hostname, 'mochi.test', 'Unexpected hostname.');
+ is(loc.origin, 'http://mochi.test:8888', 'Unexpected origin.');
+ is(loc.pathname, '/tests/dom/tests/mochitest/dom-level0/test_location_getters.html', 'Unexpected pathname.');
+ is(loc.port, '8888', 'Unexpected port.');
+ is(loc.protocol, 'http:', 'Unexpected protocol.');
+ SimpleTest.finish();
+ }
+ </script>
+ </pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_location_sandboxed.html b/dom/tests/mochitest/dom-level0/test_location_sandboxed.html
new file mode 100644
index 0000000000..3872bad793
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_location_sandboxed.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>MessageEvent tests</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+ <p id="display"></p>
+ <pre id="test">
+ <script>
+ SimpleTest.waitForExplicitFinish();
+
+ window.addEventListener('message', function (e) {
+ console.log(e);
+ console.dir(e);
+ var loc = e.data;
+ is(loc.hash, '', 'Unexpected hash.');
+ is(loc.host, 'mochi.test:8888', 'Unexpected host.');
+ is(loc.hostname, 'mochi.test', 'Unexpected hostname.');
+ // Is this correct? It matches WebKit, but it seems wrong:
+ // https://bugs.webkit.org/show_bug.cgi?id=106488
+ is(loc.origin, 'http://mochi.test:8888', 'Unexpected origin.');
+ is(loc.pathname, '/tests/dom/tests/mochitest/dom-level0/framed_location.html', 'Unexpected pathname.');
+ is(loc.port, '8888', 'Unexpected port.');
+ is(loc.protocol, 'http:', 'Unexpected protocol.');
+ SimpleTest.finish();
+ });
+ </script>
+ <iframe sandbox="allow-scripts" src="framed_location.html"></iframe>
+ </pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_location_setters.html b/dom/tests/mochitest/dom-level0/test_location_setters.html
new file mode 100644
index 0000000000..e97ada110a
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_location_setters.html
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=639720
+-->
+<head>
+ <title>Test for Bug 639720</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=639720">Mozilla Bug 639720</a>
+<p id="display">
+ <iframe id="f"></iframe>
+</p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 639720 **/
+SimpleTest.waitForExplicitFinish();
+
+var BASE_URI = "http://mochi.test:8888/tests/dom/tests/mochitest/dom-level0/";
+var tests = [
+ { url: BASE_URI + "iframe1_location_setters.html" },
+ { url: BASE_URI + "iframe2_location_setters.html",
+ useDocument: true },
+ { prepURL: "http://www.example.com",
+ url: BASE_URI + "iframe3_location_setters.html" }
+];
+
+var currentTest = 0;
+
+function checkTest() {
+ is($("f").contentWindow.location.href, tests[currentTest].url,
+ "href of content window's location should match url of current test");
+ ++currentTest;
+ runNextTest();
+}
+
+function runCurrentTest() {
+ var test = tests[currentTest];
+ $("f").onload = checkTest;
+ if (test.useDocument) {
+ $("f").contentDocument.location = test.url;
+ } else {
+ $("f").contentWindow.location = test.url;
+ }
+ is(typeof($("f").contentWindow.location), "object",
+ "Location should not have become string");
+}
+
+function prepComplete() {
+ runCurrentTest();
+}
+
+function runNextTest() {
+ if (currentTest == tests.length) {
+ SimpleTest.finish();
+ return;
+ }
+
+ var test = tests[currentTest];
+ if ("prepURL" in test) {
+ $("f").onload = prepComplete;
+ $("f").src = test.prepURL;
+ return;
+ }
+
+ runCurrentTest();
+}
+
+addLoadEvent(runNextTest);
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_separate_post_message_queue.html b/dom/tests/mochitest/dom-level0/test_separate_post_message_queue.html
new file mode 100644
index 0000000000..357faa6b09
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_separate_post_message_queue.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for using separate event queue for post messages during page load behaviors</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+var tab;
+var callOrder = [];
+function onDone() {
+ tab.close();
+ isDeeply(callOrder, ["Runnable1", "Runnable2", "Runnable3", "PostMessage",
+ "Runnable1", "Runnable2", "Runnable3", "PostMessage"], "Runnables should be fired prior to PostMessage");
+ SimpleTest.finish();
+}
+
+SpecialPowers.pushPrefEnv({"set":[["dom.separate_event_queue_for_post_message.enabled", true]]}, function () {
+ tab = window.open('file_separate_post_message_queue.html');
+ tab.loadCount = 1;
+});
+
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_setting_document.domain_idn.html b/dom/tests/mochitest/dom-level0/test_setting_document.domain_idn.html
new file mode 100644
index 0000000000..b6e8c05462
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_setting_document.domain_idn.html
@@ -0,0 +1,153 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Setting document.domain and IDN</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+
+<!--
+
+This test checks that the value of document.domain is always punycode,
+no matter if the TLD is whitelisted or not.
+Prior to bug 945240 that was not true.
+
+-->
+
+<div>
+<h2>Whitelisted</h2>
+<iframe name="idnKidWhitelist" src="http://sub1.παράδειγμα.δοκιμή/tests/dom/tests/mochitest/dom-level0/idn_child.html?idn-whitelist"></iframe>
+<iframe name="punycodeKidWhitelist" src="http://sub1.παράδειγμα.δοκιμή/tests/dom/tests/mochitest/dom-level0/idn_child.html?punycode-whitelist"></iframe>
+</div>
+
+<div>
+<h2>Not whitelisted</h2>
+<iframe name="idnKidNoWhitelist" src="http://sub1.exaмple.test/tests/dom/tests/mochitest/dom-level0/idn_child.html?idn-nowhitelist"></iframe>
+<iframe name="punycodeKidNoWhitelist" src="http://sub1.exaмple.test/tests/dom/tests/mochitest/dom-level0/idn_child.html?punycode-nowhitelist"></iframe>
+</div>
+
+<pre id="test">
+<script class="testbody" type="application/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+var gotIDNNoWhitelist = false;
+var gotPunycodeNoWhitelist = false;
+var gotIDNWhitelist = false;
+var gotPunycodeWhitelist = false;
+
+var whitelistRegex =
+ new RegExp("^http://sub1\\.παράδειγμα\\.δοκιμή/tests/dom/tests/" +
+ "mochitest/dom-level0/idn_child\\.html\\?(.+)$");
+
+var noWhitelistRegex =
+ new RegExp("^http://sub1\\.exaмple\\.test/tests/dom/tests/" +
+ "mochitest/dom-level0/idn_child\\.html\\?(.+)$");
+
+var state = 0;
+
+var messages =
+ [
+ "idn-whitelist",
+ "punycode-whitelist",
+ "idn-nowhitelist",
+ "punycode-nowhitelist",
+ ];
+
+
+function receiveMessage(evt)
+{
+ var origin = evt.origin;
+ var match;
+ if (/test$/.test(origin))
+ {
+ is(evt.origin, "http://sub1.xn--exaple-kqf.test", "wrong sender");
+ }
+ else
+ {
+ is(evt.origin, "http://sub1.xn--hxajbheg2az3al.xn--jxalpdlp", "wrong sender");
+ }
+
+ is(messages[state] + "-response", evt.data.split(" ")[0],
+ "unexpected data: " + evt.data);
+
+ switch (messages[state])
+ {
+ case "idn-whitelist":
+ gotIDNWhitelist = true;
+ ok(evt.source === window.frames.idnKidWhitelist, "wrong source");
+ is(evt.data, "idn-whitelist-response", "wrong response for IDN");
+ break;
+
+ case "punycode-whitelist":
+ gotPunycodeWhitelist = true;
+ ok(evt.source === window.frames.punycodeKidWhitelist, "wrong source");
+ is(evt.data, "punycode-whitelist-response", "wrong response for punycode");
+ break;
+
+ case "idn-nowhitelist":
+ gotIDNNoWhitelist = true;
+ ok(evt.source === window.frames.idnKidNoWhitelist, "wrong source");
+ is(evt.data, "idn-nowhitelist-response", "wrong response for IDN");
+ break;
+
+ case "punycode-nowhitelist":
+ gotPunycodeNoWhitelist = true;
+ ok(evt.source === window.frames.punycodeKidNoWhitelist, "wrong source");
+ is(evt.data, "punycode-nowhitelist-response", "wrong response for punycode");
+ break;
+
+ default:
+ ok(false, "unreached");
+ break;
+ }
+
+ state++;
+}
+
+function* rungen() {
+ var target = window.frames.idnKidWhitelist;
+ target.postMessage("idn-whitelist", "http://sub1.παράδειγμα.δοκιμή");
+ receiveMessage(yield);
+
+ ok(gotIDNWhitelist, "IDN whitelist message not received");
+
+ var target = window.frames.punycodeKidWhitelist;
+ target.postMessage("punycode-whitelist", "http://sub1.παράδειγμα.δοκιμή");
+
+ receiveMessage(yield);
+
+ ok(gotPunycodeWhitelist, "punycode whitelist message not received");
+
+ var target = window.frames.idnKidNoWhitelist;
+ target.postMessage("idn-nowhitelist", "http://sub1.exaмple.test");
+
+ receiveMessage(yield);
+
+ ok(gotIDNNoWhitelist, "IDN no-whitelist message not received");
+
+ var target = window.frames.punycodeKidNoWhitelist;
+ target.postMessage("punycode-nowhitelist",
+ "http://sub1.exaмple.test");
+
+ receiveMessage(yield);
+
+ ok(gotPunycodeNoWhitelist,
+ "punycode no-whitelist message not received");
+
+ SimpleTest.finish();
+}
+
+var gen = rungen();
+window.addEventListener("message", (m) => gen.next(m));
+window.addEventListener("load", () => gen.next());
+</script>
+</pre>
+</body>
+</html>
diff --git a/dom/tests/mochitest/dom-level0/test_setting_document.domain_to_shortened_ipaddr.html b/dom/tests/mochitest/dom-level0/test_setting_document.domain_to_shortened_ipaddr.html
new file mode 100644
index 0000000000..a80532fe57
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_setting_document.domain_to_shortened_ipaddr.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>document.domain can't be meaningfully set on pages at IP address hosts</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+
+<iframe id="childframe" name="child"></iframe>
+
+<pre id="test">
+<script class="testbody" type="application/javascript">
+
+SimpleTest.waitForExplicitFinish();
+
+function receiveMessage(evt)
+{
+ is(evt.origin, "http://127.0.0.1:8888", "wrong sender");
+ ok(evt.source === window.frames.child, "wrong sender");
+
+ is(evt.data, "child-response", "got wrong response");
+
+ SimpleTest.finish();
+}
+window.addEventListener("message", receiveMessage);
+
+// By default, proxies don't apply to 127.0.0.1.
+// We need them to for this test (at least on android), though:
+SpecialPowers.pushPrefEnv({set: [
+ ["network.proxy.allow_hijacking_localhost", true]
+]}).then(function() {
+ var iframe = document.getElementById("childframe");
+ iframe.src = "http://127.0.0.1:8888/tests/dom/tests/mochitest/dom-level0/child_ip_address.html";
+});
+</script>
+</pre>
+</body>
+</html>