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.
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Overriding postMessage and dispatchEvent bindings</title>
5 <script type="application/javascript">
6 window.postMessage = function (evt)
7 {
8 window.parent.postMessage("FAIL overridden postMessage called", "*");
9 };
11 var count = 0;
13 function receiveMessage(evt)
14 {
15 count++;
16 if (count == 1)
17 {
18 window.dispatchEvent = function(evt)
19 {
20 window.parent.postMessage("FAIL", "*");
21 throw "dispatchEvent threw";
22 };
23 }
25 window.parent.postMessage(evt.data, "http://mochi.test:8888");
26 }
28 function setup()
29 {
30 var target = document.getElementById("location");
31 target.textContent = location.hostname + ":" + (location.port || 80);
32 }
34 window.addEventListener("message", receiveMessage, false);
36 window.addEventListener("load", setup, false);
37 </script>
38 </head>
39 <body>
40 <h1 id="location">No location!</h1>
41 </body>
42 </html>