2d.drawImage.negativedest.worker.js (1374B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.drawImage.negativedest 3 // Description:Negative destination width/height represents the correct rectangle 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 promise_test(async t => { 10 var canvas = new OffscreenCanvas(100, 50); 11 var ctx = canvas.getContext('2d'); 12 13 ctx.fillStyle = '#f00'; 14 ctx.fillRect(0, 0, 100, 50); 15 const response = await fetch('/images/ggrr-256x256.png'); 16 const blob = await response.blob(); 17 const bitmap = await createImageBitmap(blob); 18 ctx.drawImage(bitmap, 100, 78, 50, 50, 0, 50, 50, -50); 19 ctx.drawImage(bitmap, 100, 128, 50, -50, 100, 50, -50, -50); 20 _assertPixelApprox(canvas, 1,1, 0,255,0,255, 2); 21 _assertPixelApprox(canvas, 1,48, 0,255,0,255, 2); 22 _assertPixelApprox(canvas, 98,1, 0,255,0,255, 2); 23 _assertPixelApprox(canvas, 98,48, 0,255,0,255, 2); 24 _assertPixelApprox(canvas, 48,1, 0,255,0,255, 2); 25 _assertPixelApprox(canvas, 48,48, 0,255,0,255, 2); 26 _assertPixelApprox(canvas, 51,1, 0,255,0,255, 2); 27 _assertPixelApprox(canvas, 51,48, 0,255,0,255, 2); 28 _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); 29 _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); 30 }, "Negative destination width/height represents the correct rectangle"); 31 done();