2d.state.saverestore.shadowOffsetX.html (2023B)
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.state.saverestore.shadowOffsetX</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.state.saverestore.shadowOffsetX</h1> 10 11 <script> 12 13 test(t => { 14 const canvas = new OffscreenCanvas(300, 150); 15 const ctx = canvas.getContext('2d'); 16 17 const old = ctx.shadowOffsetX; 18 ctx.save(); 19 ctx.shadowOffsetX = 5; 20 ctx.restore(); 21 _assertSame(ctx.shadowOffsetX, old, "ctx.shadowOffsetX", "old"); 22 }, "save()/restore() restores shadowOffsetX, for a canvas of size (300, 150)."); 23 24 test(t => { 25 const canvas = new OffscreenCanvas(300, 150); 26 const ctx = canvas.getContext('2d'); 27 28 ctx.shadowOffsetX = 5; 29 const old = ctx.shadowOffsetX; 30 // We're not interested in failures caused by get(set(x)) != x (e.g. 31 // from rounding), so compare against `old` instead of 5. 32 ctx.save(); 33 _assertSame(ctx.shadowOffsetX, old, "ctx.shadowOffsetX", "old"); 34 ctx.restore(); 35 }, "save() does not modify shadowOffsetX, for a canvas of size (300, 150)."); 36 37 test(t => { 38 const canvas = new OffscreenCanvas(0, 0); 39 const ctx = canvas.getContext('2d'); 40 41 const old = ctx.shadowOffsetX; 42 ctx.save(); 43 ctx.shadowOffsetX = 5; 44 ctx.restore(); 45 _assertSame(ctx.shadowOffsetX, old, "ctx.shadowOffsetX", "old"); 46 }, "save()/restore() restores shadowOffsetX, for a canvas of size (0, 0)."); 47 48 test(t => { 49 const canvas = new OffscreenCanvas(0, 0); 50 const ctx = canvas.getContext('2d'); 51 52 ctx.shadowOffsetX = 5; 53 const old = ctx.shadowOffsetX; 54 // We're not interested in failures caused by get(set(x)) != x (e.g. 55 // from rounding), so compare against `old` instead of 5. 56 ctx.save(); 57 _assertSame(ctx.shadowOffsetX, old, "ctx.shadowOffsetX", "old"); 58 ctx.restore(); 59 }, "save() does not modify shadowOffsetX, for a canvas of size (0, 0)."); 60 61 </script>