tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

2d.layer.malformed-operations-with-promises.html (1729B)


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