2d.line.cap.square.html (1696B)
1 <!DOCTYPE html> 2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> 3 <meta charset="UTF-8"> 4 <title>OffscreenCanvas test: 2d.line.cap.square</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/html/canvas/resources/canvas-tests.js"></script> 8 9 <h1>2d.line.cap.square</h1> 10 <p class="desc">lineCap 'square' is rendered correctly</p> 11 12 13 <script> 14 var t = async_test("lineCap 'square' is rendered correctly"); 15 var t_pass = t.done.bind(t); 16 var t_fail = t.step_func(function(reason) { 17 throw reason; 18 }); 19 t.step(function() { 20 21 var canvas = new OffscreenCanvas(100, 50); 22 var ctx = canvas.getContext('2d'); 23 24 ctx.fillStyle = '#0f0'; 25 ctx.fillRect(0, 0, 100, 50); 26 27 ctx.lineCap = 'square'; 28 ctx.lineWidth = 20; 29 30 ctx.fillStyle = '#f00'; 31 ctx.strokeStyle = '#0f0'; 32 ctx.fillRect(15, 5, 20, 40); 33 ctx.beginPath(); 34 ctx.moveTo(25, 15); 35 ctx.lineTo(25, 35); 36 ctx.stroke(); 37 38 ctx.fillStyle = '#0f0'; 39 ctx.strokeStyle = '#f00'; 40 ctx.beginPath(); 41 ctx.moveTo(75, 15); 42 ctx.lineTo(75, 35); 43 ctx.stroke(); 44 ctx.fillRect(65, 5, 20, 40); 45 46 _assertPixel(canvas, 25,4, 0,255,0,255); 47 _assertPixel(canvas, 25,5, 0,255,0,255); 48 _assertPixel(canvas, 25,6, 0,255,0,255); 49 _assertPixel(canvas, 25,44, 0,255,0,255); 50 _assertPixel(canvas, 25,45, 0,255,0,255); 51 _assertPixel(canvas, 25,46, 0,255,0,255); 52 53 _assertPixel(canvas, 75,4, 0,255,0,255); 54 _assertPixel(canvas, 75,5, 0,255,0,255); 55 _assertPixel(canvas, 75,6, 0,255,0,255); 56 _assertPixel(canvas, 75,44, 0,255,0,255); 57 _assertPixel(canvas, 75,45, 0,255,0,255); 58 _assertPixel(canvas, 75,46, 0,255,0,255); 59 t.done(); 60 61 }); 62 </script>