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 | <canvas id="c" width="1" height="1"></canvas> |
michael@0 | 3 | <img id="img" src="image_green-1x1.png"> |
michael@0 | 4 | <script> |
michael@0 | 5 | window.onmessage = function(ev) { |
michael@0 | 6 | if (ev.data != "start") { |
michael@0 | 7 | parent.postMessage({ msg: "unknown_message", data: ev.data }, "*"); |
michael@0 | 8 | return; |
michael@0 | 9 | } |
michael@0 | 10 | |
michael@0 | 11 | // Set document.domain to itself, so we trigger the |
michael@0 | 12 | // "set effective script origin" cases. |
michael@0 | 13 | document.domain = document.domain |
michael@0 | 14 | var ctx = document.getElementById("c").getContext("2d"); |
michael@0 | 15 | ctx.drawImage(document.getElementById("img"), 0, 0); |
michael@0 | 16 | try { |
michael@0 | 17 | var data = ctx.getImageData(0, 0, 1, 1).data; |
michael@0 | 18 | parent.postMessage( |
michael@0 | 19 | { |
michael@0 | 20 | msg: "color", |
michael@0 | 21 | data: "rgba(" + data[0] + ", " + data[1] + ", " + data[2] + ", " + data[3]/255 + ")" |
michael@0 | 22 | }, |
michael@0 | 23 | "*"); |
michael@0 | 24 | } catch (e) { |
michael@0 | 25 | parent.postMessage({ msg: "exception", data: e.toString() }, "*"); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | parent.postMessage({ msg: "done" }, "*"); |
michael@0 | 29 | } |
michael@0 | 30 | </script> |