dom/tests/mochitest/dom-level0/idn_child.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
     5   <title>Child window on a site whose "base" domain contains IDN</title>
     6   <script type="application/javascript">
     7 function run()
     8 {
     9   var target = document.getElementById("location");
    10   target.textContent = location.hostname + ":" + (location.port || 80);
    11 }
    13 function receiveMessage(evt)
    14 {
    15   if (evt.origin !== "http://mochi.test:8888")
    16     return;
    18   var message = evt.data + "-response";
    20   var domain = document.domain;
    21   if (/test$/.test(domain))
    22   {
    23     // XXX should really be IDN (bug 414090)
    24     //if (domain !== "sub1.exaмple.test")
    25     //  message += " wrong-initial-domain(" + domain + ")";
    26     // for now expect the punycode value
    27     if (domain !== "sub1.xn--exaple-kqf.test")
    28       message += " wrong-initial-domain(" + domain + ")";
    29   }
    30   else
    31   {
    32     if (domain !== "sub1.παράδειγμα.δοκιμή")
    33       message += " wrong-initial-domain(" + domain + ")";
    34   }
    36   switch (location.search)
    37   {
    38     case "?idn-whitelist":
    39       message += idnTest("παράδειγμα.δοκιμή");
    40       break;
    42     case "?punycode-whitelist":
    43       message  += punycodeTest("xn--hxajbheg2az3al.xn--jxalpdlp");
    44       break;
    46     case "?idn-nowhitelist":
    47       message += idnTest("exaмple.test");
    48       break;
    50     case "?punycode-nowhitelist":
    51       message  += punycodeTest("xn--exaple-kqf.test");
    52       break;
    54     default:
    55       message += " unexpected-query(" + location.search + ")";
    56       break;
    57   }
    59   evt.source.postMessage(message, evt.origin);
    60 }
    62 function idnTest(newDomain)
    63 {
    64   var errors = "";
    66   try
    67   {
    68     document.domain = newDomain;
    69   }
    70   catch (e)
    71   {
    72     errors += " error-thrown-setting-to-idn(" + String(e).split("").join(",") + ")";
    73   }
    75   return errors;
    76 }
    78 function punycodeTest(newDomain)
    79 {
    80   var errors = "";
    82   try
    83   {
    84     document.domain = newDomain;
    85   }
    86   catch (e)
    87   {
    88     errors += " error-thrown-setting-to-punycode(" + String(e).split("").join(",") + ")";
    89   }
    91   return errors;
    92 }
    94 window.addEventListener("message", receiveMessage, false);
    95 window.addEventListener("load", run, false);
    96   </script>
    97 </head>
    98 <body>
    99 <h1 id="location">Somewhere!</h1>
   100 </body>
   101 </html>

mercurial