Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
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=497665 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 497665</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 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 11 | </head> |
michael@0 | 12 | <body> |
michael@0 | 13 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=497665">Mozilla Bug 497665</a> |
michael@0 | 14 | <p id="display"></p> |
michael@0 | 15 | <pre id="test"> |
michael@0 | 16 | <script type="application/javascript"> |
michael@0 | 17 | |
michael@0 | 18 | var image1first, image2first, image1second, image2second, image1third, image2third; |
michael@0 | 19 | |
michael@0 | 20 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 21 | |
michael@0 | 22 | function checkFirst() |
michael@0 | 23 | { |
michael@0 | 24 | var iframeelem = document.getElementById('test-iframe'); |
michael@0 | 25 | var canvas = document.getElementById('canvas'); |
michael@0 | 26 | var ctx = canvas.getContext('2d'); |
michael@0 | 27 | |
michael@0 | 28 | var firstimg = iframeelem.contentDocument.getElementById('image1'); |
michael@0 | 29 | var secondimg = iframeelem.contentDocument.getElementById('image2'); |
michael@0 | 30 | ctx.drawImage(firstimg, 0, 0); |
michael@0 | 31 | image1first = canvas.toDataURL(); |
michael@0 | 32 | ctx.drawImage(secondimg, 0, 0); |
michael@0 | 33 | image2first = canvas.toDataURL(); |
michael@0 | 34 | |
michael@0 | 35 | ok(image1first == image2first, "We got different images, but shouldn't have."); |
michael@0 | 36 | |
michael@0 | 37 | iframeelem.onload = checkForceReload; |
michael@0 | 38 | iframeelem.contentWindow.location.reload(true); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | function checkForceReload() |
michael@0 | 42 | { |
michael@0 | 43 | var iframeelem = document.getElementById('test-iframe'); |
michael@0 | 44 | var canvas = document.getElementById('canvas'); |
michael@0 | 45 | var ctx = canvas.getContext('2d'); |
michael@0 | 46 | |
michael@0 | 47 | var firstimg = iframeelem.contentDocument.getElementById('image1'); |
michael@0 | 48 | var secondimg = iframeelem.contentDocument.getElementById('image2'); |
michael@0 | 49 | ctx.drawImage(firstimg, 0, 0); |
michael@0 | 50 | image1second = canvas.toDataURL(); |
michael@0 | 51 | ctx.drawImage(secondimg, 0, 0); |
michael@0 | 52 | image2second = canvas.toDataURL(); |
michael@0 | 53 | |
michael@0 | 54 | ok(image1second == image2second, "We got different images after a force-reload, but shouldn't have."); |
michael@0 | 55 | |
michael@0 | 56 | // Sanity check that we actually reloaded. |
michael@0 | 57 | ok(image1first != image1second, "We got the same images after a force-reload."); |
michael@0 | 58 | |
michael@0 | 59 | iframeelem.onload = checkReload; |
michael@0 | 60 | iframeelem.contentWindow.location.reload(false); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function checkReload() |
michael@0 | 64 | { |
michael@0 | 65 | var iframeelem = document.getElementById('test-iframe'); |
michael@0 | 66 | var canvas = document.getElementById('canvas'); |
michael@0 | 67 | var ctx = canvas.getContext('2d'); |
michael@0 | 68 | |
michael@0 | 69 | var firstimg = iframeelem.contentDocument.getElementById('image1'); |
michael@0 | 70 | var secondimg = iframeelem.contentDocument.getElementById('image2'); |
michael@0 | 71 | ctx.drawImage(firstimg, 0, 0); |
michael@0 | 72 | image1third = canvas.toDataURL(); |
michael@0 | 73 | ctx.drawImage(secondimg, 0, 0); |
michael@0 | 74 | image2third = canvas.toDataURL(); |
michael@0 | 75 | |
michael@0 | 76 | ok(image1third == image2third, "We got different images after a reload, but shouldn't have."); |
michael@0 | 77 | |
michael@0 | 78 | // Sanity check that we actually reloaded properly. |
michael@0 | 79 | ok(image1second != image1third, "We got the same images after a reload."); |
michael@0 | 80 | ok(image1first == image1third, "We didn't loop back to the first image."); |
michael@0 | 81 | |
michael@0 | 82 | SimpleTest.finish(); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | </script> |
michael@0 | 86 | </pre> |
michael@0 | 87 | <div id="content"> <!-- style="display: none" --> |
michael@0 | 88 | <canvas id="canvas" width="100" height="100"> </canvas> |
michael@0 | 89 | <iframe id="test-iframe" src="bug497665-iframe.html" onload="checkFirst()"></iframe> |
michael@0 | 90 | </div> |
michael@0 | 91 | </body> |
michael@0 | 92 | </html> |