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 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=456151 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 456151</title> |
michael@0 | 8 | <script type="application/javascript" src="/MochiKit/MochiKit.js"></script> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=456151">Mozilla Bug 456151</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content" style="display: none"> |
michael@0 | 17 | |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script type="application/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | /** Test for Bug 456151 **/ |
michael@0 | 23 | var intercepted = false; |
michael@0 | 24 | |
michael@0 | 25 | // Set up our new addEventListener |
michael@0 | 26 | var proto = HTMLParagraphElement.prototype; |
michael@0 | 27 | proto.oldAdd = proto.addEventListener; |
michael@0 | 28 | proto.addEventListener = function(ev, list, capt) { |
michael@0 | 29 | intercepted = true; |
michael@0 | 30 | this.oldAdd(ev, list, capt); |
michael@0 | 31 | } |
michael@0 | 32 | proto.oldRemove = proto.removeEventListener; |
michael@0 | 33 | proto.removeEventListener = function(ev, list, capt) { |
michael@0 | 34 | intercepted = true; |
michael@0 | 35 | this.oldRemove(ev, list, capt); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | var called = false; |
michael@0 | 39 | |
michael@0 | 40 | var func = function() { called = true; }; |
michael@0 | 41 | $("display").addEventListener("click", func, false); |
michael@0 | 42 | is(intercepted, true, "Should have interecepted addEventListener call"); |
michael@0 | 43 | |
michael@0 | 44 | sendMouseEvent({type: "click"}, "display"); |
michael@0 | 45 | is(called, true, "Should have called event listener"); |
michael@0 | 46 | |
michael@0 | 47 | interecepted = false; |
michael@0 | 48 | called = false; |
michael@0 | 49 | |
michael@0 | 50 | $("display").removeEventListener("click", func, false); |
michael@0 | 51 | is(intercepted, true, "Should have interecepted removeEventListener call"); |
michael@0 | 52 | |
michael@0 | 53 | sendMouseEvent({type: "click"}, "display"); |
michael@0 | 54 | is(called, false, "Should have removed event listener"); |
michael@0 | 55 | |
michael@0 | 56 | // And now some simple sanity tests |
michael@0 | 57 | var recursion = false; |
michael@0 | 58 | var x = document.createElement("span"); |
michael@0 | 59 | HTMLSpanElement.prototype.addEventListener = |
michael@0 | 60 | function(a, b, c) { |
michael@0 | 61 | return x.addEventListener(a,b,c); |
michael@0 | 62 | } |
michael@0 | 63 | try { |
michael@0 | 64 | x.addEventListener("click", function() { called = true; }, false); |
michael@0 | 65 | } catch (e) { |
michael@0 | 66 | recursion = e.message.match(/recursion/); |
michael@0 | 67 | } |
michael@0 | 68 | SimpleTest.isDeeply(recursion, ["recursion"], "Caught infinite recursion"); |
michael@0 | 69 | |
michael@0 | 70 | </script> |
michael@0 | 71 | </pre> |
michael@0 | 72 | </body> |
michael@0 | 73 | </html> |