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=731419 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 731419 - Draw an ostensibly discarded image to a canvas</title> |
michael@0 | 8 | <script type="application/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 | |
michael@0 | 12 | <body> |
michael@0 | 13 | |
michael@0 | 14 | <!-- |
michael@0 | 15 | Load an image in an iframe, then draw that image to a canvas. Then set the |
michael@0 | 16 | iframe to display:none (after bug 731419, this causes the image's decoded |
michael@0 | 17 | data to be discarded) and draw the image to a canvas again. We should draw |
michael@0 | 18 | the same image data both times. |
michael@0 | 19 | --> |
michael@0 | 20 | |
michael@0 | 21 | <script> |
michael@0 | 22 | |
michael@0 | 23 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 24 | |
michael@0 | 25 | var data1; |
michael@0 | 26 | |
michael@0 | 27 | function drawImage() |
michael@0 | 28 | { |
michael@0 | 29 | var canvas = document.getElementById('canvas'); |
michael@0 | 30 | var ctx = canvas.getContext('2d'); |
michael@0 | 31 | var iframeDoc = document.getElementById('iframe').contentDocument; |
michael@0 | 32 | |
michael@0 | 33 | ctx.clearRect(0, 0, canvas.height, canvas.width); |
michael@0 | 34 | ctx.drawImage(iframeDoc.getElementById('image'), 0, 0); |
michael@0 | 35 | return canvas.toDataURL(); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function iframeLoad() |
michael@0 | 39 | { |
michael@0 | 40 | data1 = drawImage(); |
michael@0 | 41 | document.getElementById('iframe').style.display = 'none'; |
michael@0 | 42 | |
michael@0 | 43 | // Spin the event loop a few times to give the image in the display:none |
michael@0 | 44 | // iframe a chance to be discarded. |
michael@0 | 45 | SimpleTest.executeSoon(function() { |
michael@0 | 46 | SimpleTest.executeSoon(function() { |
michael@0 | 47 | SimpleTest.executeSoon(function() { |
michael@0 | 48 | step2(); |
michael@0 | 49 | }); |
michael@0 | 50 | }); |
michael@0 | 51 | }); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function step2() |
michael@0 | 55 | { |
michael@0 | 56 | is(drawImage(), data1, "Same image before and after iframe display:none"); |
michael@0 | 57 | SimpleTest.finish(); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | </script> |
michael@0 | 61 | |
michael@0 | 62 | <canvas id='canvas'></canvas> |
michael@0 | 63 | |
michael@0 | 64 | <iframe id='iframe' onload='iframeLoad()' src='data:text/html,<img id="image" |
michael@0 | 65 | src="data:image/png;base64, |
michael@0 | 66 | iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADRElEQVQ4EQXBTWgcZQCA4ff7ZmZ3 |
michael@0 | 67 | NpvNZLObTWpCuoZGIxWJplAKbVUKavUiHrQHaRG1XrV4SNuD4MFcRDwUoR4qEq2gFUlBEWmtppYi |
michael@0 | 68 | acSmMakxtfkx/5tNdmd35/8bn0cAzJ7IXwKGH/q8NDF48vy+7vk/3tzVXDs8nj9cAAiDcD70gwVi |
michael@0 | 69 | vvvr4tsjAAAAAmD2RD4GOL34wge21XHsnHWh9/aUjX1pC4C1UpXrP08zN7vMvvujPx3P/PD+0VH3 |
michael@0 | 70 | BoAcTspXAbK9iuGe78+csy70ZnsVvh+xWQ8p1QI8dNK7CiT9CmeO28/4ZsuVX9/IvQwgmzLaU9LS |
michael@0 | 71 | AGh/3KJ5jw6A6ynyL7Xx7UCORiwQGRN0g7C4m4FX9poNV35681ShU6ZbxKDRLJVuZQl9RdSQRB4c |
michael@0 | 72 | OtDGoQNtPGHBuh0SaAa+ZvLjHYt8fwfZrpTl2cFp2ZwVDyQzSgLgVIndGN/tIP/c61y/WWb14gaV |
michael@0 | 73 | asTWioPSDabnfCqVkK7BHKHtPK0n06oFGQHgewJtbw8AujGNkYTNpTJxbYfaygqR0piYkaRkhMya |
michael@0 | 74 | eI2oX9dTQRIFmtrmz7EGpS9vESZjAN7tfo/UL2PouoZwbfxIo9jaoLWlzI7jEPmhLjVEbXs5IPAE |
michael@0 | 75 | jx5M0Z5RZDJwqjCENFN8XBtmOP0FXq1O6NR5snsRtsv4C+voCdHQpcfVtTn/xUKXTrMlyfck6BCC |
michael@0 | 76 | a02fkDZDqirF5JVrRA8ewagu8NbADN6az9btMoTqjnasKDTHjp5PSM3I5DQy7UliZbCz7bCwFDD/ |
michael@0 | 77 | b52h3BCviVHOHv2bvmydyvwOM5MSmch9Ji4/SxMNcaNJTw707zdJmBqeo+G5BuO/V6AzQ5Oo01MI |
michael@0 | 78 | KBaTOOis3rPZrKeqrbn2hwXA10fY7zvicqeZKPQ8YpKxJCgIpEQXisBVhG6MYcQ0pGJp2XWnSpx8 |
michael@0 | 79 | 52o0ogF8c5/ltMlGIlYHo0qQrq9HxHWFvx3RqCoCFzwn4L+tiIVV5Y5MhWc/mlDnATQAgMkynbMb |
michael@0 | 80 | opoN4z2hUAlPBdpO6FNp+JTtkPVaHE7NYX94K/xqrBT/BvwDIAAAgALQAfT1aWJwtyYea9VEXoAo |
michael@0 | 81 | RfHGYhTfvRfF48BdYB3YAPgfnOuE39kFlREAAAAASUVORK5CYII=">'></iframe> |
michael@0 | 82 | |
michael@0 | 83 | </body> |
michael@0 | 84 | </html> |
michael@0 | 85 |