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