Bug 1794662 [wpt PR 36401] - Batch-remove unused arguments in _assertPixel and _asser...
[gecko.git] / testing / web-platform / tests / html / canvas / offscreen / drawing-images-to-the-canvas / 2d.drawImage.alpha.html
blob505c3fde5d1148b028e8bdfbdbffed60fdd425dc
1 <!DOCTYPE html>
2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
3 <title>OffscreenCanvas test: 2d.drawImage.alpha</title>
4 <meta name="timeout" content="long">
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="/html/canvas/resources/canvas-tests.js"></script>
9 <h1>2d.drawImage.alpha</h1>
10 <p class="desc"></p>
13 <script>
14 var t = async_test("");
15 var t_pass = t.done.bind(t);
16 var t_fail = t.step_func(function(reason) {
17 throw reason;
18 });
19 t.step(function() {
21 var canvas = new OffscreenCanvas(100, 50);
22 var ctx = canvas.getContext('2d');
24 ctx.fillStyle = '#0f0';
25 ctx.fillRect(0, 0, 100, 50);
26 ctx.globalAlpha = 0;
27 var promise = new Promise(function(resolve, reject) {
28 var xhr = new XMLHttpRequest();
29 xhr.open("GET", '/images/red.png');
30 xhr.responseType = 'blob';
31 xhr.send();
32 xhr.onload = function() {
33 resolve(xhr.response);
35 });
36 promise.then(function(response) {
37 createImageBitmap(response).then(bitmap => {
38 ctx.drawImage(bitmap, 0, 0);
39 _assertPixelApprox(canvas, 50,25, 0,255,0,255, 2);
40 }, t_fail);
41 }).then(t_pass, t_fail);
43 });
44 </script>