Bug 1794662 [wpt PR 36401] - Batch-remove unused arguments in _assertPixel and _asser...
[gecko.git] / testing / web-platform / tests / html / canvas / offscreen / fill-and-stroke-styles / 2d.pattern.paint.repeat.coord2.worker.js
blob29c6f8f006deb3c1f877a68273fd89b1cf9bab38
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py.
2 // OffscreenCanvas test in a worker:2d.pattern.paint.repeat.coord2
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');
19 var promise = new Promise(function(resolve, reject) {
20     var xhr = new XMLHttpRequest();
21     xhr.open("GET", '/images/grgr-256x256.png');
22     xhr.responseType = 'blob';
23     xhr.send();
24     xhr.onload = function() {
25         resolve(xhr.response);
26     };
27 });
28 promise.then(function(response) {
29     createImageBitmap(response).then(bitmap => {
30         var pattern = ctx.createPattern(bitmap, 'no-repeat');
31         ctx.fillStyle = pattern;
32         ctx.fillRect(0, 0, 100, 50);
33         _assertPixel(canvas, 1,1, 0,255,0,255);
34         _assertPixel(canvas, 98,1, 0,255,0,255);
35         _assertPixel(canvas, 1,48, 0,255,0,255);
36         _assertPixel(canvas, 98,48, 0,255,0,255);
37     }, t_fail);
38 }).then(t_pass, t_fail);
40 });
41 done();