Bug 1688868 [wpt PR 27329] - Mark some WPT tests as timeout=long, a=testonly
[gecko.git] / testing / web-platform / tests / html / canvas / offscreen / drawing-images-to-the-canvas / 2d.drawImage.path.worker.js
blob1916238531a25575ef9c6761fa6a03f3ef1d48ad
1 // META: timeout=long
2 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
3 // OffscreenCanvas test in a worker:2d.drawImage.path
4 // Description:
5 // Note:
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) {
13     throw reason;
14 });
15 t.step(function() {
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';
26     xhr.send();
27     xhr.onload = function() {
28         resolve(xhr.response);
29     };
30 });
31 promise.then(function(response) {
32     createImageBitmap(response).then(bitmap => {
33         ctx.drawImage(bitmap, 0, 0);
34         ctx.fill();
35         _assertPixelApprox(offscreenCanvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 2);
36     }, t_fail);
37 }).then(t_pass, t_fail);
39 });
40 done();