1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/tests/mochitest/dom-level0/idn_child.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,101 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<head> 1.7 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 1.8 + <title>Child window on a site whose "base" domain contains IDN</title> 1.9 + <script type="application/javascript"> 1.10 +function run() 1.11 +{ 1.12 + var target = document.getElementById("location"); 1.13 + target.textContent = location.hostname + ":" + (location.port || 80); 1.14 +} 1.15 + 1.16 +function receiveMessage(evt) 1.17 +{ 1.18 + if (evt.origin !== "http://mochi.test:8888") 1.19 + return; 1.20 + 1.21 + var message = evt.data + "-response"; 1.22 + 1.23 + var domain = document.domain; 1.24 + if (/test$/.test(domain)) 1.25 + { 1.26 + // XXX should really be IDN (bug 414090) 1.27 + //if (domain !== "sub1.exaмple.test") 1.28 + // message += " wrong-initial-domain(" + domain + ")"; 1.29 + // for now expect the punycode value 1.30 + if (domain !== "sub1.xn--exaple-kqf.test") 1.31 + message += " wrong-initial-domain(" + domain + ")"; 1.32 + } 1.33 + else 1.34 + { 1.35 + if (domain !== "sub1.παράδειγμα.δοκιμή") 1.36 + message += " wrong-initial-domain(" + domain + ")"; 1.37 + } 1.38 + 1.39 + switch (location.search) 1.40 + { 1.41 + case "?idn-whitelist": 1.42 + message += idnTest("παράδειγμα.δοκιμή"); 1.43 + break; 1.44 + 1.45 + case "?punycode-whitelist": 1.46 + message += punycodeTest("xn--hxajbheg2az3al.xn--jxalpdlp"); 1.47 + break; 1.48 + 1.49 + case "?idn-nowhitelist": 1.50 + message += idnTest("exaмple.test"); 1.51 + break; 1.52 + 1.53 + case "?punycode-nowhitelist": 1.54 + message += punycodeTest("xn--exaple-kqf.test"); 1.55 + break; 1.56 + 1.57 + default: 1.58 + message += " unexpected-query(" + location.search + ")"; 1.59 + break; 1.60 + } 1.61 + 1.62 + evt.source.postMessage(message, evt.origin); 1.63 +} 1.64 + 1.65 +function idnTest(newDomain) 1.66 +{ 1.67 + var errors = ""; 1.68 + 1.69 + try 1.70 + { 1.71 + document.domain = newDomain; 1.72 + } 1.73 + catch (e) 1.74 + { 1.75 + errors += " error-thrown-setting-to-idn(" + String(e).split("").join(",") + ")"; 1.76 + } 1.77 + 1.78 + return errors; 1.79 +} 1.80 + 1.81 +function punycodeTest(newDomain) 1.82 +{ 1.83 + var errors = ""; 1.84 + 1.85 + try 1.86 + { 1.87 + document.domain = newDomain; 1.88 + } 1.89 + catch (e) 1.90 + { 1.91 + errors += " error-thrown-setting-to-punycode(" + String(e).split("").join(",") + ")"; 1.92 + } 1.93 + 1.94 + return errors; 1.95 +} 1.96 + 1.97 +window.addEventListener("message", receiveMessage, false); 1.98 +window.addEventListener("load", run, false); 1.99 + </script> 1.100 +</head> 1.101 +<body> 1.102 +<h1 id="location">Somewhere!</h1> 1.103 +</body> 1.104 +</html>