summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webmessaging/support/cross-domain-image-receive.htm
blob: 253b34bd769734b8a096647a0afb3b69c98bb4af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>

<html lang="en">
<head>
    <title>Cross-Domain image transfer test</title>
</head>
<script type="text/javascript" charset="utf-8">

function receiver(e) {
    var dstCanvas = document.createElement('canvas');
    dstCanvas.width = e.data.image.width
    dstCanvas.height = e.data.image.height
    var dstCtx = dstCanvas.getContext('2d');
    dstCtx.drawImage(e.data.image, 0, 0)
    var imgData = dstCtx.getImageData(0, 0, dstCanvas.height, dstCanvas.width);

    result = JSON.stringify(imgData.data);
    e.source.postMessage(result, "*");
}

addEventListener('message', receiver, false);
</script>
<body>
</body>
</html>