2013-10-04 11:28:25 -07:00
|
|
|
|
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 893309 - Implement TrackEvent</title>
|
|
|
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2014-08-19 05:42:35 -07:00
|
|
|
var video = document.createElement("video");
|
|
|
|
isnot(video.textTracks, undefined, "HTMLMediaElement::TextTrack() property should be available.")
|
|
|
|
ok(typeof video.addTextTrack == "function", "HTMLMediaElement::AddTextTrack() function should be available.")
|
2013-10-04 11:28:25 -07:00
|
|
|
|
2014-08-19 05:42:35 -07:00
|
|
|
var trackList = video.textTracks;
|
|
|
|
is(trackList.length, 0, "Length should be 0.");
|
2014-02-13 10:28:21 -08:00
|
|
|
|
2014-08-19 05:42:35 -07:00
|
|
|
var evtTextTrack, numOfCalls = 0, tt;
|
|
|
|
trackList.onaddtrack = function(event) {
|
|
|
|
ok(event instanceof TrackEvent, "Fired event from onaddtrack should be a TrackEvent");
|
|
|
|
is(event.type, "addtrack", "Event type should be addtrack");
|
|
|
|
ok(event.isTrusted, "Event should be trusted!");
|
|
|
|
ok(!event.bubbles, "Event shouldn't bubble!");
|
|
|
|
ok(!event.cancelable, "Event shouldn't be cancelable!");
|
2013-10-04 11:28:25 -07:00
|
|
|
|
2014-08-19 05:42:35 -07:00
|
|
|
evtTextTrack = event.track;
|
|
|
|
tt = textTrack[numOfCalls].track || textTrack[numOfCalls];
|
2013-10-04 11:28:25 -07:00
|
|
|
|
2014-08-19 05:42:35 -07:00
|
|
|
ok(tt === evtTextTrack, "Text tracks should be the same");
|
|
|
|
is(evtTextTrack.label, label[numOfCalls], "Label should be set to "+ label[numOfCalls]);
|
|
|
|
is(evtTextTrack.language, language[numOfCalls], "Language should be " + language[numOfCalls]);
|
|
|
|
is(evtTextTrack.kind, kind[numOfCalls], "Kind should be " + kind[numOfCalls]);
|
2013-10-04 11:28:25 -07:00
|
|
|
|
2014-08-19 05:42:35 -07:00
|
|
|
if (++numOfCalls == 4) {
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
};
|
2013-10-04 11:28:25 -07:00
|
|
|
|
2014-08-19 05:42:35 -07:00
|
|
|
var label = ["Oasis", "Coldplay", "t.A.T.u", ""];
|
|
|
|
language = ["en-CA", "en-GB", "ru", ""];
|
|
|
|
kind = ["subtitles", "captions", "chapters", "subtitles"];
|
2014-02-13 10:28:21 -08:00
|
|
|
|
2014-08-19 05:42:35 -07:00
|
|
|
var textTrack = new Array(4);
|
|
|
|
for (var i = 0; i < 3; ++i) {
|
|
|
|
textTrack[i] = video.addTextTrack(kind[i], label[i], language[i]);
|
|
|
|
is(trackList.length, i + 1, "Length should be " + (i+1));
|
|
|
|
}
|
2014-02-13 10:28:21 -08:00
|
|
|
|
2014-08-19 05:42:35 -07:00
|
|
|
video.src = "seek.webm";
|
|
|
|
video.preload = "auto";
|
|
|
|
var trackElement = document.createElement("track");
|
|
|
|
trackElement.src = "basic.vtt";
|
|
|
|
textTrack[3] = trackElement;
|
|
|
|
|
|
|
|
document.getElementById("content").appendChild(video);
|
|
|
|
video.appendChild(trackElement);
|
|
|
|
|
|
|
|
//TODO: Tests for removetrack event to be added along with bug 882677
|
2013-10-04 11:28:25 -07:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|