content/canvas/test/file_drawImage_document_domain.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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