tor-browser

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

test_bug1921817.html (1179B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title></title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      7 </head>
      8 <body>
      9 <script>
     10 // Bug 1924775 - ESLint doesn't yet know about `ImageDecoder`.
     11 /* globals ImageDecoder:false */
     12 
     13 async function test() {
     14  const imgResponse = await fetch("bug1921817.jpg");
     15  const decoder = new ImageDecoder({
     16    data: imgResponse.body,
     17    type: "image/jpeg",
     18  });
     19 
     20  // Should download all the data and decode metadata just fine.
     21  await decoder.completed;
     22  await decoder.tracks.ready;
     23  is(decoder.tracks.length, 1, "Should have one track");
     24  is(decoder.tracks[0].frameCount, 1, "Should have a single frame");
     25 
     26  try {
     27    await decoder.decode();
     28    ok(false, "Expected to fail to decode image")
     29  } catch (e) {
     30    is(e.code, DOMException.INVALID_STATE_ERR, "Should throw InvalidStateError");
     31  }
     32 
     33  return Promise.resolve();
     34 }
     35 
     36 async function initTest() {
     37  SimpleTest.waitForExplicitFinish();
     38  try {
     39    await test();
     40  } catch (e) {
     41    ok(false, "Unexpected error " + e);
     42  } finally {
     43    SimpleTest.finish();
     44  }
     45 }
     46 
     47 initTest();
     48 </script>
     49 </body>
     50 </html>