2d.imageData.get.unaffected.worker.js (1112B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.imageData.get.unaffected 3 // Description:getImageData() is not affected by context state 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 var t = async_test("getImageData() is not affected by context state"); 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() { 15 16 var canvas = new OffscreenCanvas(100, 50); 17 var ctx = canvas.getContext('2d'); 18 19 ctx.fillStyle = '#0f0'; 20 ctx.fillRect(0, 0, 50, 50) 21 ctx.fillStyle = '#f00'; 22 ctx.fillRect(50, 0, 50, 50) 23 ctx.save(); 24 ctx.translate(50, 0); 25 ctx.globalAlpha = 0.1; 26 ctx.globalCompositeOperation = 'destination-atop'; 27 ctx.shadowColor = '#f00'; 28 ctx.rect(0, 0, 5, 5); 29 ctx.clip(); 30 var imgdata = ctx.getImageData(0, 0, 50, 50); 31 ctx.restore(); 32 ctx.putImageData(imgdata, 50, 0); 33 _assertPixelApprox(canvas, 25,25, 0,255,0,255, 2); 34 _assertPixelApprox(canvas, 75,25, 0,255,0,255, 2); 35 t.done(); 36 }); 37 done();