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