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.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=399925
5 -->
6 <head>
7 <title>Test for Bug 399925</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="text/javascript" src="imgutils.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=399925">Mozilla Bug 399925</a>
14 <p id="display"></p>
15 <div id="content" style="display: none">
16 <img src="bug399925.gif" id="gif" />
17 <canvas id="canvas" width="100" height="100"> </canvas>
18 </div>
19 <pre id="test">
20 <script class="testbody" type="text/javascript">
22 /** Test for Bug 399925. **/
23 var pngResults = new Array();
24 var oldTimeoutPref;
25 var oldDiscardPref;
26 SimpleTest.waitForExplicitFinish();
27 window.onload = runTest;
29 function runTest()
30 {
31 // Get the old discard timeout
32 oldTimeoutPref = getImagePref(DISCARD_TIMEOUT_PREF);
34 // We're testing discarding here, so we should make sure it's flipped on
35 oldDiscardPref = getImagePref(DISCARD_ENABLED_PREF);
37 // Enable Discarding
38 setImagePref(DISCARD_ENABLED_PREF, true);
40 // Sets the discard timer to 500ms so we don't have to wait so long. The
41 // actual time is nondeterministic, but is bounded by 2 * timer = 1 second.
42 setImagePref(DISCARD_TIMEOUT_PREF, 1000);
44 // Create the image _after_ setting the discard timer pref
45 var image = new Image();
46 image.setAttribute("id", "gif");
47 image.src = "bug399925.gif";
48 document.getElementById("content").appendChild(image);
50 // draw the canvas once
51 drawCanvas();
53 // Set the timeout to draw it after discard
54 setTimeout('drawCanvas(); allDone();', 3000);
55 }
57 function drawCanvas()
58 {
59 var canvas = document.getElementById('canvas');
60 var context = canvas.getContext('2d');
61 var gif = document.getElementById('gif');
63 context.drawImage(gif, 0, 0);
64 ok(true, "we got through the drawImage call without an exception being thrown");
65 pngResults.push(canvas.toDataURL);
66 }
68 function allDone()
69 {
70 is(pngResults[0], pngResults[1], "got different rendered results");
71 setImagePref(DISCARD_TIMEOUT_PREF, oldTimeoutPref);
72 setImagePref(DISCARD_ENABLED_PREF, oldDiscardPref);
73 SimpleTest.finish();
74 }
76 </script>
77 </pre>
78 </body>
79 </html>