Bug 1928997: Update tabs icon in Unified Search popup r=desktop-theme-reviewers,daleh...
[gecko.git] / dom / canvas / test / file_drawImage_document_domain.html
bloba3d4360c5a317c2ff806d82143443abb311a7023
1 <!DOCTYPE html>
2 <canvas id="c" width="1" height="1"></canvas>
3 <img id="img" src="image_green-1x1.png">
4 <script>
5 window.onmessage = function(ev) {
6 if (ev.data != "start") {
7 parent.postMessage({ msg: "unknown_message", data: ev.data }, "*");
8 return;
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);
17 try {
18 var data = ctx.getImageData(0, 0, 1, 1).data;
19 parent.postMessage(
21 msg: "color",
22 data: "rgba(" + data[0] + ", " + data[1] + ", " + data[2] + ", " + data[3]/255 + ")"
24 "*");
25 } catch (e) {
26 parent.postMessage({ msg: "exception", data: e.toString() }, "*");
29 parent.postMessage({ msg: "done" }, "*");
31 </script>