OLD | NEW |
(Empty) | |
| 1 // DO NOT EDIT! This test has been generated by tools/gentest.py. |
| 2 // OffscreenCanvas test in a worker:2d.line.join.bevel |
| 3 // Description:lineJoin 'bevel' is rendered correctly |
| 4 // Note: |
| 5 |
| 6 importScripts("/resources/testharness.js"); |
| 7 importScripts("/common/canvas-tests.js"); |
| 8 |
| 9 var t = async_test("lineJoin 'bevel' is rendered correctly"); |
| 10 t.step(function() { |
| 11 |
| 12 var offscreenCanvas = new OffscreenCanvas(100, 50); |
| 13 var ctx = offscreenCanvas.getContext('2d'); |
| 14 |
| 15 ctx.fillStyle = '#0f0'; |
| 16 ctx.fillRect(0, 0, 100, 50); |
| 17 var tol = 1; // tolerance to avoid antialiasing artifacts |
| 18 ctx.lineJoin = 'bevel'; |
| 19 ctx.lineWidth = 20; |
| 20 ctx.fillStyle = '#f00'; |
| 21 ctx.strokeStyle = '#0f0'; |
| 22 ctx.fillRect(10, 10, 20, 20); |
| 23 ctx.fillRect(20, 20, 20, 20); |
| 24 ctx.beginPath(); |
| 25 ctx.moveTo(30, 20); |
| 26 ctx.lineTo(40-tol, 20); |
| 27 ctx.lineTo(30, 10+tol); |
| 28 ctx.fill(); |
| 29 ctx.beginPath(); |
| 30 ctx.moveTo(10, 20); |
| 31 ctx.lineTo(30, 20); |
| 32 ctx.lineTo(30, 40); |
| 33 ctx.stroke(); |
| 34 ctx.fillStyle = '#0f0'; |
| 35 ctx.strokeStyle = '#f00'; |
| 36 ctx.beginPath(); |
| 37 ctx.moveTo(60, 20); |
| 38 ctx.lineTo(80, 20); |
| 39 ctx.lineTo(80, 40); |
| 40 ctx.stroke(); |
| 41 ctx.fillRect(60, 10, 20, 20); |
| 42 ctx.fillRect(70, 20, 20, 20); |
| 43 ctx.beginPath(); |
| 44 ctx.moveTo(80, 20); |
| 45 ctx.lineTo(90+tol, 20); |
| 46 ctx.lineTo(80, 10-tol); |
| 47 ctx.fill(); |
| 48 _assertPixel(offscreenCanvas, 34,16, 0,255,0,255, "34,16", "0,255,0,255"); |
| 49 _assertPixel(offscreenCanvas, 34,15, 0,255,0,255, "34,15", "0,255,0,255"); |
| 50 _assertPixel(offscreenCanvas, 35,15, 0,255,0,255, "35,15", "0,255,0,255"); |
| 51 _assertPixel(offscreenCanvas, 36,15, 0,255,0,255, "36,15", "0,255,0,255"); |
| 52 _assertPixel(offscreenCanvas, 36,14, 0,255,0,255, "36,14", "0,255,0,255"); |
| 53 _assertPixel(offscreenCanvas, 84,16, 0,255,0,255, "84,16", "0,255,0,255"); |
| 54 _assertPixel(offscreenCanvas, 84,15, 0,255,0,255, "84,15", "0,255,0,255"); |
| 55 _assertPixel(offscreenCanvas, 85,15, 0,255,0,255, "85,15", "0,255,0,255"); |
| 56 _assertPixel(offscreenCanvas, 86,15, 0,255,0,255, "86,15", "0,255,0,255"); |
| 57 _assertPixel(offscreenCanvas, 86,14, 0,255,0,255, "86,14", "0,255,0,255"); |
| 58 |
| 59 t.done(); |
| 60 |
| 61 }); |
| 62 done(); |
OLD | NEW |