content/canvas/test/file_drawImage_document_domain.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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>

mercurial