tor-browser

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

2d.layer.malformed-operations.worker.js (3052B)


      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
      3 // Description:
      4 // Note:
      5 
      6 importScripts("/resources/testharness.js");
      7 importScripts("/html/canvas/resources/canvas-tests.js");
      8 
      9 test(t => {
     10  const canvas = new OffscreenCanvas(200, 200);
     11  const ctx = canvas.getContext('2d');
     12 
     13  // Shouldn't throw on its own.
     14  ctx.createPattern(canvas, 'repeat');
     15  // Make sure the exception isn't caused by calling the function twice.
     16  ctx.createPattern(canvas, 'repeat');
     17  // Calling again inside a layer should throw.
     18  ctx.beginLayer();
     19  assert_throws_dom("InvalidStateError",
     20                    () => ctx.createPattern(canvas, 'repeat'));
     21 }, "Throws if createPattern is called while layers are open.");
     22 
     23 test(t => {
     24  const canvas = new OffscreenCanvas(200, 200);
     25  const ctx = canvas.getContext('2d');
     26 
     27  const canvas2 = new OffscreenCanvas(200, 200);
     28  const ctx2 = canvas2.getContext('2d');
     29  // Shouldn't throw on its own.
     30  ctx2.drawImage(canvas, 0, 0);
     31  // Make sure the exception isn't caused by calling the function twice.
     32  ctx2.drawImage(canvas, 0, 0);
     33  // Calling again inside a layer should throw.
     34  ctx.beginLayer();
     35  assert_throws_dom("InvalidStateError",
     36                    () => ctx2.drawImage(canvas, 0, 0));
     37 }, "Throws if drawImage is called while layers are open.");
     38 
     39 test(t => {
     40  const canvas = new OffscreenCanvas(200, 200);
     41  const ctx = canvas.getContext('2d');
     42 
     43  // Shouldn't throw on its own.
     44  ctx.getImageData(0, 0, 200, 200);
     45  // Make sure the exception isn't caused by calling the function twice.
     46  ctx.getImageData(0, 0, 200, 200);
     47  // Calling again inside a layer should throw.
     48  ctx.beginLayer();
     49  assert_throws_dom("InvalidStateError",
     50                    () => ctx.getImageData(0, 0, 200, 200));
     51 }, "Throws if getImageData is called while layers are open.");
     52 
     53 test(t => {
     54  const canvas = new OffscreenCanvas(200, 200);
     55  const ctx = canvas.getContext('2d');
     56 
     57  const canvas2 = new OffscreenCanvas(200, 200);
     58  const ctx2 = canvas2.getContext('2d')
     59  const data = ctx2.getImageData(0, 0, 1, 1);
     60  // Shouldn't throw on its own.
     61  ctx.putImageData(data, 0, 0);
     62  // Make sure the exception isn't caused by calling the function twice.
     63  ctx.putImageData(data, 0, 0);
     64  // Calling again inside a layer should throw.
     65  ctx.beginLayer();
     66  assert_throws_dom("InvalidStateError",
     67                    () => ctx.putImageData(data, 0, 0));
     68 }, "Throws if putImageData is called while layers are open.");
     69 
     70 test(t => {
     71  const canvas = new OffscreenCanvas(200, 200);
     72  const ctx = canvas.getContext('2d');
     73 
     74  // Shouldn't throw on its own.
     75  canvas.transferToImageBitmap();
     76  // Make sure the exception isn't caused by calling the function twice.
     77  canvas.transferToImageBitmap();
     78  // Calling again inside a layer should throw.
     79  ctx.beginLayer();
     80  assert_throws_dom("InvalidStateError",
     81                    () => canvas.transferToImageBitmap());
     82 }, "Throws if transferToImageBitmap is called while layers are open.");
     83 
     84 done();