Bug 1943761 - Add class alignment to the mozsearch analysis file. r=asuth
[gecko.git] / dom / media / webvtt / test / mochitest / test_texttrack_moz.html
blobb39562b3a4e55f882cdc34d37912548b2b79c98c
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test for Bug 881976 - TextTrackList</title>
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="text/javascript" src="manifest.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
8 </head>
9 <body>
10 <video id="v" src="seek.webm" preload="metadata">
11 <script type="text/javascript">
12 /**
13 * This test is used to ensure the text track list we got from video is as same
14 * as the one in the text track.
16 var video = document.getElementById("v");
18 async function runTest() {
19 addTrackViaAddTrackAPI();
20 await addTrackViaTrackElement();
21 SimpleTest.finish();
24 SimpleTest.waitForExplicitFinish();
25 onload = runTest;
27 /**
28 * The following are test helper functions.
30 function addTrackViaAddTrackAPI() {
31 // Check if adding a text track manually sets the TextTrackList correctly.
32 video.addTextTrack("subtitles", "", "");
33 // TextTrack.textTrackList is an extension available only to privileged code,
34 // so we need to access it through the SpecialPowers object.
35 is(SpecialPowers.unwrap(SpecialPowers.wrap(video.textTracks[0]).textTrackList),
36 video.textTracks,
37 "The Track's TextTrackList should be the Video's TextTrackList.");
40 async function addTrackViaTrackElement() {
41 // Check if loading a Track via a TrackElement sets the TextTrackList correctly.
42 let trackElement = document.createElement("track");
43 trackElement.src = "basic.vtt";
44 trackElement.kind = "subtitles";
45 trackElement.default = true;
46 video.appendChild(trackElement);
48 info(`wait until the track finishes loading`);
49 await once(trackElement, "load");
51 is(trackElement.readyState, HTMLTrackElement.LOADED,
52 "Track::ReadyState should be set to LOADED.");
53 is(SpecialPowers.unwrap(SpecialPowers.wrap(trackElement.track).textTrackList),
54 video.textTracks,
55 "TrackElement's Track's TextTrackList should be the Video's TextTrackList.");
58 </script>
59 </body>
60 </html>