2 <canvas id=
"c" width=
"1" height=
"1"></canvas>
3 <img id=
"img" src=
"image_green-1x1.png">
5 window
.onmessage = function(ev
) {
6 if (ev
.data
!= "start") {
7 parent
.postMessage({ msg
: "unknown_message", data
: ev
.data
}, "*");
11 // Set document.domain to itself, so we trigger the
12 // "set effective script origin" cases.
13 // eslint-disable-next-line no-self-assign
14 document
.domain
= document
.domain
15 var ctx
= document
.getElementById("c").getContext("2d");
16 ctx
.drawImage(document
.getElementById("img"), 0, 0);
18 var data
= ctx
.getImageData(0, 0, 1, 1).data
;
22 data
: "rgba(" + data
[0] + ", " + data
[1] + ", " + data
[2] + ", " + data
[3]/255 + ")"
26 parent
.postMessage({ msg
: "exception", data
: e
.toString() }, "*");
29 parent
.postMessage({ msg
: "done" }, "*");