2d.state.saverestore.stack.worker.js (889B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.state.saverestore.stack 3 // Description:save()/restore() can be nested as a stack 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 var t = async_test("save()/restore() can be nested as a stack"); 10 var t_pass = t.done.bind(t); 11 var t_fail = t.step_func(function(reason) { 12 throw reason; 13 }); 14 t.step(function() { 15 16 var canvas = new OffscreenCanvas(100, 50); 17 var ctx = canvas.getContext('2d'); 18 19 ctx.lineWidth = 1; 20 ctx.save(); 21 ctx.lineWidth = 2; 22 ctx.save(); 23 ctx.lineWidth = 3; 24 _assertSame(ctx.lineWidth, 3, "ctx.lineWidth", "3"); 25 ctx.restore(); 26 _assertSame(ctx.lineWidth, 2, "ctx.lineWidth", "2"); 27 ctx.restore(); 28 _assertSame(ctx.lineWidth, 1, "ctx.lineWidth", "1"); 29 t.done(); 30 }); 31 done();