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"/>
10 <video id=
"v" src=
"seek.webm" preload=
"metadata">
11 <script type=
"text/javascript">
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();
24 SimpleTest
.waitForExplicitFinish();
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
),
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
),
55 "TrackElement's Track's TextTrackList should be the Video's TextTrackList.");