summaryrefslogtreecommitdiffstats
path: root/dom/media/webvtt/test/mochitest/test_bug883173.html
blob: 6e95f4e3cab543ffdc59a449b40627c70650c07c (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
38
39
<!DOCTYPE HTML>
<html>
<head>
  <title>Test for Bug 883173 - TextTrackCue(List) Sorting</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<video id="v" src="seek.webm" preload="metadata">
  <track src="bug883173.vtt" kind="subtitles" id="default" default>
</video>
<script type="text/javascript">
/**
 * This test is used to ensure that the cues in the cue list should be sorted by
 * cues' start time and end time, not the present order in the file.
 */
function runTest() {
  let trackElement = document.getElementById("default");
  is(trackElement.readyState, 2, "Track::ReadyState should be set to LOADED.");

  let expected = [[1, 3], [1, 2], [2, 4], [2, 3], [3, 4]];
  let cueList = trackElement.track.cues;
  is(cueList.length, expected.length, "Cue list length should be 5.");

  for (let i = 0; i < expected.length; i++) {
    is(cueList[i].startTime, expected[i][0],
       `Cue's start time should be ${expected[i][0]}`);
    is(cueList[i].endTime, expected[i][1],
       `Cue's end time should be ${expected[i][1]}`);
  }

  SimpleTest.finish();
}

SimpleTest.waitForExplicitFinish();
onload = runTest;
</script>
</body>
</html>