2d.layer.malformed-operations-with-promises.worker.js (1352B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.layer.malformed-operations-with-promises 3 // Description: 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 promise_test(async t => { 10 const canvas = new OffscreenCanvas(200, 200); 11 const ctx = canvas.getContext('2d'); 12 13 // Shouldn't throw on its own. 14 await canvas.convertToBlob(); 15 // Make sure the exception isn't caused by calling the function twice. 16 await canvas.convertToBlob(); 17 // Calling again inside a layer should throw. 18 ctx.beginLayer(); 19 await promise_rejects_dom(t, 'InvalidStateError', 20 canvas.convertToBlob()); 21 }, "Throws if convertToBlob is called while layers are open."); 22 23 promise_test(async t => { 24 const canvas = new OffscreenCanvas(200, 200); 25 const ctx = canvas.getContext('2d'); 26 27 // Shouldn't throw on its own. 28 await createImageBitmap(canvas); 29 // Make sure the exception isn't caused by calling the function twice. 30 await createImageBitmap(canvas); 31 // Calling again inside a layer should throw. 32 ctx.beginLayer(); 33 await promise_rejects_dom(t, 'InvalidStateError', 34 createImageBitmap(canvas)); 35 }, "Throws if createImageBitmap is called while layers are open."); 36 37 done();