summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/embedded-content/media-elements/track/track-element/track-cue-rendering-after-controls-added.html
blob: 23c27e418ec45505e157d89e8aa7ed9c7caf755d (plain)
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
<!DOCTYPE html>
<html class="reftest-wait">
<script src="/common/reftest-wait.js"></script>
<link rel="match" href="track-cue-rendering-after-controls-added-ref.html">
<title>Text track cue layout after controls are added</title>
<style>
::cue {
  font-size: 50px;
}
</style>
<!-- Width should be large enough to display all of the media controls. -->
<video style="border:1px solid gray; width: 500px;">
  <source src="/media/white.webm" type="video/webm">
  <source src="/media/white.mp4" type="video/mp4">
</video>
<script>
// Add a cue that will overlap with the video controls.
var video = document.querySelector("video");
var track = video.addTextTrack("captions");
track.addCue(new VTTCue(0, 1, "text"));
track.mode = "showing";

video.onloadeddata = function() {
  // Double nesting of requestAnimationFrame to
  // make sure cue layout and paint happens.
  window.requestAnimationFrame(function() {
    window.requestAnimationFrame(function() {
      video.controls = true;
      // Wait for the relayout before screenshot.
      window.requestAnimationFrame(function() {
        takeScreenshot();
      });
    });
  });
};
</script>
</html>