2 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
3 // OffscreenCanvas test in a worker:2d.drawImage.path
7 importScripts("/resources/testharness.js");
8 importScripts("/html/canvas/resources/canvas-tests.js");
10 var t = async_test("");
11 var t_pass = t.done.bind(t);
12 var t_fail = t.step_func(function(reason) {
17 var offscreenCanvas = new OffscreenCanvas(100, 50);
18 var ctx = offscreenCanvas.getContext('2d');
20 ctx.fillStyle = '#0f0';
21 ctx.rect(0, 0, 100, 50);
22 var promise = new Promise(function(resolve, reject) {
23 var xhr = new XMLHttpRequest();
24 xhr.open("GET", '/images/red.png');
25 xhr.responseType = 'blob';
27 xhr.onload = function() {
28 resolve(xhr.response);
31 promise.then(function(response) {
32 createImageBitmap(response).then(bitmap => {
33 ctx.drawImage(bitmap, 0, 0);
35 _assertPixelApprox(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 2);
37 }).then(t_pass, t_fail);