2d.state.saverestore.fillStyle.worker.js (1842B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.state.saverestore.fillStyle 3 // Description: 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 test(t => { 10 const canvas = new OffscreenCanvas(300, 150); 11 const ctx = canvas.getContext('2d'); 12 13 const old = ctx.fillStyle; 14 ctx.save(); 15 ctx.fillStyle = "#ff0000"; 16 ctx.restore(); 17 _assertSame(ctx.fillStyle, old, "ctx.fillStyle", "old"); 18 }, "save()/restore() restores fillStyle, for a canvas of size (300, 150)."); 19 20 test(t => { 21 const canvas = new OffscreenCanvas(300, 150); 22 const ctx = canvas.getContext('2d'); 23 24 ctx.fillStyle = "#ff0000"; 25 const old = ctx.fillStyle; 26 // We're not interested in failures caused by get(set(x)) != x (e.g. 27 // from rounding), so compare against `old` instead of "#ff0000". 28 ctx.save(); 29 _assertSame(ctx.fillStyle, old, "ctx.fillStyle", "old"); 30 ctx.restore(); 31 }, "save() does not modify fillStyle, for a canvas of size (300, 150)."); 32 33 test(t => { 34 const canvas = new OffscreenCanvas(0, 0); 35 const ctx = canvas.getContext('2d'); 36 37 const old = ctx.fillStyle; 38 ctx.save(); 39 ctx.fillStyle = "#ff0000"; 40 ctx.restore(); 41 _assertSame(ctx.fillStyle, old, "ctx.fillStyle", "old"); 42 }, "save()/restore() restores fillStyle, for a canvas of size (0, 0)."); 43 44 test(t => { 45 const canvas = new OffscreenCanvas(0, 0); 46 const ctx = canvas.getContext('2d'); 47 48 ctx.fillStyle = "#ff0000"; 49 const old = ctx.fillStyle; 50 // We're not interested in failures caused by get(set(x)) != x (e.g. 51 // from rounding), so compare against `old` instead of "#ff0000". 52 ctx.save(); 53 _assertSame(ctx.fillStyle, old, "ctx.fillStyle", "old"); 54 ctx.restore(); 55 }, "save() does not modify fillStyle, for a canvas of size (0, 0)."); 56 57 done();