2d.layer.malformed-operations-with-promises.html (1506B)
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.layer.malformed-operations-with-promises</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.layer.malformed-operations-with-promises</h1> 10 11 <script> 12 13 promise_test(async t => { 14 const canvas = new OffscreenCanvas(200, 200); 15 const ctx = canvas.getContext('2d'); 16 17 // Shouldn't throw on its own. 18 await canvas.convertToBlob(); 19 // Make sure the exception isn't caused by calling the function twice. 20 await canvas.convertToBlob(); 21 // Calling again inside a layer should throw. 22 ctx.beginLayer(); 23 await promise_rejects_dom(t, 'InvalidStateError', 24 canvas.convertToBlob()); 25 }, "Throws if convertToBlob is called while layers are open."); 26 27 promise_test(async t => { 28 const canvas = new OffscreenCanvas(200, 200); 29 const ctx = canvas.getContext('2d'); 30 31 // Shouldn't throw on its own. 32 await createImageBitmap(canvas); 33 // Make sure the exception isn't caused by calling the function twice. 34 await createImageBitmap(canvas); 35 // Calling again inside a layer should throw. 36 ctx.beginLayer(); 37 await promise_rejects_dom(t, 'InvalidStateError', 38 createImageBitmap(canvas)); 39 }, "Throws if createImageBitmap is called while layers are open."); 40 41 </script>