2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
3 <title>OffscreenCanvas test:
2d.drawImage.clip
</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.clip
</h1>
14 var t
= async_test("");
15 var t_pass
= t
.done
.bind(t
);
16 var t_fail
= t
.step_func(function(reason
) {
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
.rect(-10, -10, 1, 1);
28 var promise
= new Promise(function(resolve
, reject
) {
29 var xhr
= new XMLHttpRequest();
30 xhr
.open("GET", '/images/red.png');
31 xhr
.responseType
= 'blob';
33 xhr
.onload = function() {
34 resolve(xhr
.response
);
37 promise
.then(function(response
) {
38 createImageBitmap(response
).then(bitmap
=> {
39 ctx
.drawImage(bitmap
, 0, 0);
40 _assertPixelApprox(canvas
, 50,25, 0,255,0,255, 2);
42 }).then(t_pass
, t_fail
);