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/framed_location.html11
-rw-r--r--dom/tests/mochitest/dom-level0/idn_child.html101
-rw-r--r--dom/tests/mochitest/dom-level0/innerWidthHeight_script.html30
-rw-r--r--dom/tests/mochitest/dom-level0/mochitest.ini19
-rw-r--r--dom/tests/mochitest/dom-level0/test_crossdomainprops.html36
-rw-r--r--dom/tests/mochitest/dom-level0/test_innerWidthHeight_script.html31
-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.html78
-rw-r--r--dom/tests/mochitest/dom-level0/test_setting_document.domain_idn.html211
-rw-r--r--dom/tests/mochitest/dom-level0/test_setting_document.domain_to_shortened_ipaddr.html35
16 files changed, 778 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 000000000..fdca1c213
--- /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, false);
+ </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 000000000..8ffaa87a9
--- /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 000000000..3a74b32d1
--- /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/framed_location.html b/dom/tests/mochitest/dom-level0/framed_location.html
new file mode 100644
index 000000000..a2b65906f
--- /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 000000000..61243b322
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/idn_child.html
@@ -0,0 +1,101 @@
+<!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))
+ {
+ // XXX should really be IDN (bug 414090)
+ //if (domain !== "sub1.exaмple.test")
+ // message += " wrong-initial-domain(" + domain + ")";
+ // for now expect the punycode value
+ if (domain !== "sub1.xn--exaple-kqf.test")
+ message += " wrong-initial-domain(" + domain + ")";
+ }
+ else
+ {
+ if (domain !== "sub1.παράδειγμα.δοκιμή")
+ 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, false);
+window.addEventListener("load", run, false);
+ </script>
+</head>
+<body>
+<h1 id="location">Somewhere!</h1>
+</body>
+</html>
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 000000000..7406086ad
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/innerWidthHeight_script.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta name="viewport" content="width=320,height=320" />
+ <title>Bug 602580 - Test getting and setting innerWidth and Height after using setCSSViewport</title>
+ <script class="testbody" type="text/javascript">
+ function runSubTest()
+ {
+ var oldWidth = window.innerWidth;
+ var oldHeight = window.innerHeight;
+
+ /* Test that return values are now from viewport */
+ window.opener.is(window.innerWidth, 320, "innerWidth is css viewport width");
+ window.opener.is(window.innerHeight, 320, "innerHeight is css viewport height");
+
+ window.innerWidth = 300;
+ window.opener.is(window.innerWidth, 300, "innerWidth returns value that was set");
+ window.innerWidth = oldWidth;
+
+ window.innerHeight = 300;
+ window.opener.is(window.innerHeight, 300, "innerHeight returns value that was set");
+ 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 000000000..595fcd281
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/mochitest.ini
@@ -0,0 +1,19 @@
+[DEFAULT]
+support-files =
+ child_ip_address.html
+ file_crossdomainprops_inner.html
+ file_location.html
+ framed_location.html
+ idn_child.html
+ innerWidthHeight_script.html
+
+[test_crossdomainprops.html]
+[test_innerWidthHeight_script.html]
+skip-if = toolkit == 'android' # Bug 1075071 - Permafail on Android
+[test_location.html]
+[test_location_framed.html]
+[test_location_getters.html]
+[test_location_sandboxed.html]
+[test_location_setters.html]
+[test_setting_document.domain_idn.html]
+[test_setting_document.domain_to_shortened_ipaddr.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 000000000..b18bb07d9
--- /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 type="text/javascript" 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 000000000..55b38b527
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_innerWidthHeight_script.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Bug 602580 - Test getting and setting innerWidth and Height after using setCSSViewport</title>
+ <script type="text/javascript" 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],
+ ["dom.meta-viewport.enabled", true ]]}, 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 000000000..49bbb0491
--- /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 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>
+<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 000000000..9d57ec943
--- /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 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>
+ 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 000000000..f5f44835d
--- /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 type="text/javascript" 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 000000000..d22e2dd33
--- /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 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>
+ 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 000000000..eb159c7ff
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_location_setters.html
@@ -0,0 +1,78 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=639720
+-->
+<head>
+ <title>Test for Bug 639720</title>
+ <script type="application/javascript" 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 tests = [
+ { url: "data:text/plain,1" },
+ { url: "data:text/plain,2",
+ useDocument: true },
+ { prepURL: "http://www.example.com",
+ url: "data:text/plain,3" }
+];
+
+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_setting_document.domain_idn.html b/dom/tests/mochitest/dom-level0/test_setting_document.domain_idn.html
new file mode 100644
index 000000000..b2e36dbbf
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_setting_document.domain_idn.html
@@ -0,0 +1,211 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Setting document.domain and IDN</title>
+ <script type="application/javascript" 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 testing all gets a bit complicated here; the problem is that our
+document.domain implementation will do a suffix comparison of the value to which
+it's being set against the current URI's base domain (where "base domain" is
+defined as the effective TLD plus one; see nsIEffectiveTLDService.idl). Seems
+simple enough, right? Wrong.
+
+The problem, as usual, is IDN. Our current, wholly-inadequate solution to
+preventing Unicode domain-name spoofing is done at the level of the URL
+implementation, not at the presentation level. However, the value of the
+base domain for the current URI is always calculated in punycode; if the
+provided domain is one which is whitelisted, we'll get an IDN name and the
+suffix-comparison will fail. Nice great big mess, huh?
+
+Anyway: "test" currently fits the bill as a TLD which is not whitelisted, while
+"δοκιμή" (the Greek IDN TLD for "test") fits the bill as a TLD which is
+whitelisted. RFC 2606 reserves "test" for DNS testing, so nobody's going to
+clamor for it to be whitelisted any time soon. The latter is as of February
+2008 undergoing testing for IDN TLDs, and it's at least temporarily whitelisted
+for now. Once the testing period ends the latter's probably going to be
+un-whitelisted, so we're going to have to do a careful bit of stepping to ensure
+that in the future this test tests what it was intended to test (and, until
+bug 414090 is fixed, that it doesn't break when the Greek TLD is
+un-whitelisted).
+
+After bug 722299 the IDN whitelist is expected to go away (bug
+843689), but bug 414090 still applies, mutatis mutandis. The test has
+been changed to use exaмple.test instead (with a Cyrillic м), which
+will fail the mixed-script tests and use punycode.
+-->
+
+<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))
+ {
+ // XXX bug 414090
+ // The value of MessageEvent.origin with postMessage *should* always be IDN;
+ // unfortunately, given our current setup for dealing with Unicode-based
+ // domain-name spoofing, whether a domain is in the safe-for-IDN whitelist
+ // affects the value of this property (likewise for window.location,
+ // document.location, document.domain, and probably a slew of other
+ // things). :-(
+ //
+ // These two tests should illustrate what currently happens and what should
+ // happen once bug 414090 is fixed.
+ todo_is(evt.origin, "http://sub1.exaмple.test", "wrong sender");
+ todo_isnot(evt.origin, "http://sub1.xn--exaple-kqf.test", "wrong sender");
+ }
+ else
+ {
+ // We're receiving data from the Greek IDN name; since that TLD is
+ // whitelisted for now, the domain we get isn't going to be punycoded.
+ is(evt.origin, "http://sub1.παράδειγμα.δοκιμή", "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 run()
+{
+ var target = window.frames.idnKidWhitelist;
+ target.postMessage("idn-whitelist", "http://sub1.παράδειγμα.δοκιμή");
+
+ // Double-timeouts account for 1) delay for message to be received by target
+ // window and 2) delay for response from target window to be received by this
+ // window.
+
+ setTimeout(function()
+ {
+ setTimeout(function()
+ {
+ ok(gotIDNWhitelist, "IDN whitelist message not received");
+
+ var target = window.frames.punycodeKidWhitelist;
+ target.postMessage("punycode-whitelist", "http://sub1.παράδειγμα.δοκιμή");
+
+ setTimeout(function()
+ {
+ setTimeout(function()
+ {
+ ok(gotPunycodeWhitelist, "punycode whitelist message not received");
+
+ var target = window.frames.idnKidNoWhitelist;
+ target.postMessage("idn-nowhitelist", "http://sub1.exaмple.test");
+
+ setTimeout(function()
+ {
+ setTimeout(function()
+ {
+ ok(gotIDNNoWhitelist, "IDN no-whitelist message not received");
+
+ var target = window.frames.punycodeKidNoWhitelist;
+ target.postMessage("punycode-nowhitelist",
+ "http://sub1.exaмple.test");
+
+ setTimeout(function()
+ {
+ setTimeout(function()
+ {
+ ok(gotPunycodeNoWhitelist,
+ "punycode no-whitelist message not received");
+
+ SimpleTest.finish();
+ }, 0);
+ }, 0);
+ }, 0);
+ }, 0);
+ }, 0);
+ }, 0);
+ }, 0);
+ }, 0);
+}
+
+window.addEventListener("message", receiveMessage, false);
+window.addEventListener("load", run, false);
+</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 000000000..5af14b8cf
--- /dev/null
+++ b/dom/tests/mochitest/dom-level0/test_setting_document.domain_to_shortened_ipaddr.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>document.domain can't be meaningfully set on pages at IP address hosts</title>
+ <script type="application/javascript" 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 name="child" src="http://127.0.0.1:8888/tests/dom/tests/mochitest/dom-level0/child_ip_address.html"></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, false);
+</script>
+</pre>
+</body>
+</html>