// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. // OffscreenCanvas test in a worker:2d.state.saverestore.globalAlpha // Description: // Note: importScripts("/resources/testharness.js"); importScripts("/html/canvas/resources/canvas-tests.js"); test(t => { const canvas = new OffscreenCanvas(300, 150); const ctx = canvas.getContext('2d'); const old = ctx.globalAlpha; ctx.save(); ctx.globalAlpha = 0.5; ctx.restore(); _assertSame(ctx.globalAlpha, old, "ctx.globalAlpha", "old"); }, "save()/restore() restores globalAlpha, for a canvas of size (300, 150)."); test(t => { const canvas = new OffscreenCanvas(300, 150); const ctx = canvas.getContext('2d'); ctx.globalAlpha = 0.5; const old = ctx.globalAlpha; // We're not interested in failures caused by get(set(x)) != x (e.g. // from rounding), so compare against `old` instead of 0.5. ctx.save(); _assertSame(ctx.globalAlpha, old, "ctx.globalAlpha", "old"); ctx.restore(); }, "save() does not modify globalAlpha, for a canvas of size (300, 150)."); test(t => { const canvas = new OffscreenCanvas(0, 0); const ctx = canvas.getContext('2d'); const old = ctx.globalAlpha; ctx.save(); ctx.globalAlpha = 0.5; ctx.restore(); _assertSame(ctx.globalAlpha, old, "ctx.globalAlpha", "old"); }, "save()/restore() restores globalAlpha, for a canvas of size (0, 0)."); test(t => { const canvas = new OffscreenCanvas(0, 0); const ctx = canvas.getContext('2d'); ctx.globalAlpha = 0.5; const old = ctx.globalAlpha; // We're not interested in failures caused by get(set(x)) != x (e.g. // from rounding), so compare against `old` instead of 0.5. ctx.save(); _assertSame(ctx.globalAlpha, old, "ctx.globalAlpha", "old"); ctx.restore(); }, "save() does not modify globalAlpha, for a canvas of size (0, 0)."); done();