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 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=389366
5 -->
6 <head>
7 <title>Test for Bug 389366</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 </head>
11 <body>
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=389366">Mozilla Bug 389366</a>
13 <p id="display"></p>
14 <div id="content" style="display: none">
15 <h4>Canvas testcase</h4>
17 Canvas, with pixel set to #ff0000 at 50% opacity:<br>
18 <canvas id="canvas1" width="10" height="10"></canvas>
19 <br>
20 <canvas id="canvas2" width="10" height="10"></canvas>
22 </div>
23 <pre id="test">
24 <script class="testbody" type="text/javascript">
26 SimpleTest.waitForExplicitFinish();
28 function test()
29 {
30 // Draw to canvas1
31 var canvas1 = document.getElementById("canvas1");
32 var ctx1 = canvas1.getContext("2d");
34 ctx1.globalAlpha = 0.502;
35 ctx1.fillStyle = "#FF0000";
36 ctx1.fillRect(0, 0, 10, 10);
38 var data1 = ctx1.getImageData(0,0,1,1).data;
39 isDeeply(data1, [255, 0, 0, 128], "expected half-transparent red canvas 1");
41 // half-transparent red 10x10 square
42 var imgData = ctx1.createImageData(10, 10);
43 var rgba = [ 255, 0, 0, 128 ];
44 for (i = 0; i < 50; ++i) {
45 for (j = 0; j < 4; ++j) {
46 imgData.data[(i * 4) + j] = rgba[j];
47 }
48 }
50 var canvas2 = document.getElementById("canvas2");
51 var ctx2 = canvas2.getContext("2d");
52 ctx2.putImageData(imgData, 0, 0);
54 var data2 = ctx2.getImageData(0,0,1,1).data;
55 isDeeply(data2, [255, 0, 0, 128], "expected half-transparent red canvas 2");
57 SimpleTest.finish();
58 }
60 addLoadEvent(test);
62 </script>
63 </pre>
64 </body>
65 </html>