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
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) {
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';
24 xhr.onload = function() {
25 resolve(xhr.response);
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);
38 }).then(t_pass, t_fail);