DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (c68fe15a81fc)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test cloneElementVisually</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="https://example.com:443/tests/dom/media/test/cloneElementVisually_helpers.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>
<body>
<div id="content">
  <h1>Original</h1>
  <video id="original"></video>
  <h1>MediaStream</h1>
  <video id="streamTarget"></video>
  <h1>Clone</h1>
</div>
<div id="results">
  <h1>Results</h1>
  <canvas id="left"></canvas>
  <canvas id="right"></canvas>
</div>

<script type="application/javascript">

/* import-globals-from cloneElementVisually_helpers.js */

/**
 * Test that we can clone a video that is playing a MediaStream.
 */
add_task(async () => {
  await setup();

  let originalVideo = document.getElementById("original");
  let stream = originalVideo.mozCaptureStream();
  let streamTarget = document.getElementById("streamTarget");
  originalVideo.setAttribute("loop", true);
  let playingPromise = waitForEventOnce(originalVideo, "playing");
  await originalVideo.play();
  await playingPromise;

  streamTarget.srcObject = stream;
  playingPromise = waitForEventOnce(streamTarget, "playing");
  await streamTarget.play();
  await playingPromise

  await withNewClone(originalVideo, async clone => {
    SpecialPowers.wrap(streamTarget).cloneElementVisually(clone);

    // Waiting for the original and stream target videos to send
    // timeupdate events seems to be sufficient to ensure that the
    // stream target video is actually showing some frames.
    await Promise.all([
      waitForEventOnce(originalVideo, "timeupdate"),
      waitForEventOnce(streamTarget, "timeupdate"),
    ]);

    originalVideo.pause();
    await waitForEventOnce(originalVideo, "pause");

    ok(await assertVideosMatch(streamTarget, clone),
       "Should match MediaStream");
  });

  // Capturing a stream from a video "taints" it which prevents testing
  // shutdown decoder behaviour. To avoid interfering with future tests,
  // we replace the video.
  let newVideo = originalVideo.cloneNode();
  originalVideo.parentNode.replaceChild(newVideo, originalVideo);
});

</script>

</body>
</html>