2d.shadow.gradient.transparent.2.worker.js (1231B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.shadow.gradient.transparent.2 3 // Description:Shadows are not drawn for transparent parts of gradient fills 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 var t = async_test("Shadows are not drawn for transparent parts of gradient fills"); 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 var gradient = ctx.createLinearGradient(0, 0, 100, 0); 20 gradient.addColorStop(0, '#f00'); 21 gradient.addColorStop(0.499, '#f00'); 22 gradient.addColorStop(0.5, 'rgba(0,0,0,0)'); 23 gradient.addColorStop(1, 'rgba(0,0,0,0)'); 24 ctx.fillStyle = '#f00'; 25 ctx.fillRect(0, 0, 50, 50); 26 ctx.fillStyle = '#0f0'; 27 ctx.fillRect(50, 0, 50, 50); 28 ctx.shadowOffsetY = 50; 29 ctx.shadowColor = '#0f0'; 30 ctx.fillStyle = gradient; 31 ctx.fillRect(0, -50, 100, 50); 32 33 _assertPixel(canvas, 25,25, 0,255,0,255); 34 _assertPixel(canvas, 50,25, 0,255,0,255); 35 _assertPixel(canvas, 75,25, 0,255,0,255); 36 t.done(); 37 }); 38 done();