tor-browser

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

HTMLCanvasElement-getImageData-noframe.html (987B)


      1 <!DOCTYPE html>
      2 <html>
      3 <body>
      4 <canvas id="canvas"></canvas>
      5 <script src=/resources/testharness.js></script>
      6 <script src=/resources/testharnessreport.js></script>
      7 <script>
      8 promise_test(async t => {
      9  const canvas = document.getElementById("canvas");
     10  const ctx = canvas.getContext("2d");
     11  const stream = canvas.captureStream();
     12  t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
     13 
     14  const video = document.createElement("video");
     15  video.srcObject = stream;
     16 
     17  ctx.getImageData(0, 0, canvas.width, canvas.height);
     18 
     19  assert_equals(video.readyState, video.HAVE_NOTHING,
     20    "Video element was just created");
     21 
     22  // Wait a bit so the video element can update readyState in case of a frame.
     23  await new Promise(r => t.step_timeout(r, 100));
     24 
     25  assert_equals(video.readyState, video.HAVE_NOTHING,
     26    "Video element did not get a frame from the canvas");
     27 }, "CanvasRenderingContext2D.getImageData() does not lead to a frame being captured");
     28 </script>
     29 </body>
     30 </html>