Bug 1794662 [wpt PR 36401] - Batch-remove unused arguments in _assertPixel and _asser...
[gecko.git] / testing / web-platform / tests / html / canvas / offscreen / compositing / 2d.composite.image.copy.worker.js
blobba3399a2b11f7d07269784bc8fd12cd2b9ca9a21
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
2 // OffscreenCanvas test in a worker:2d.composite.image.copy
3 // Description:
4 // Note:
6 importScripts("/resources/testharness.js");
7 importScripts("/html/canvas/resources/canvas-tests.js");
9 var t = async_test("");
10 var t_pass = t.done.bind(t);
11 var t_fail = t.step_func(function(reason) {
12     throw reason;
13 });
14 t.step(function() {
16 var canvas = new OffscreenCanvas(100, 50);
17 var ctx = canvas.getContext('2d');
20 ctx.fillStyle = 'rgba(0, 255, 255, 0.5)';
21 ctx.fillRect(0, 0, 100, 50);
22 ctx.globalCompositeOperation = 'copy';
23 var promise = new Promise(function(resolve, reject) {
24     var xhr = new XMLHttpRequest();
25     xhr.open("GET", '/images/yellow75.png');
26     xhr.responseType = 'blob';
27     xhr.send();
28     xhr.onload = function() {
29         resolve(xhr.response);
30     };
31 });
32 promise.then(function(response) {
33     createImageBitmap(response).then(bitmap => {
34         ctx.drawImage(bitmap, 0, 0);
35         _assertPixelApprox(canvas, 50,25, 255,255,0,191, 5);
36     }, t_fail);
37 }).then(t_pass, t_fail);
39 });
40 done();