mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-07 04:05:49 +00:00
63 lines
2.3 KiB
HTML
63 lines
2.3 KiB
HTML
|
|
<!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();
|
|
SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
|
|
function() {
|
|
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.")
|
|
|
|
var trackList = video.textTracks;
|
|
is(trackList.length, 0, "Length should be 0.");
|
|
|
|
var evtTextTrack, numOfCalls = 0;
|
|
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!");
|
|
|
|
evtTextTrack = event.track;
|
|
ok(textTrack[numOfCalls] === 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]);
|
|
|
|
if (++numOfCalls == 3) {
|
|
SimpleTest.finish();
|
|
}
|
|
};
|
|
|
|
var label = ["Oasis", "Coldplay", "t.A.T.u"];
|
|
language = ["en-CA", "en-GB", "ru" ];
|
|
kind = ["subtitles", "captions", "chapters"];
|
|
|
|
var textTrack = new Array(3);
|
|
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));
|
|
}
|
|
|
|
//TODO: Tests for removetrack event to be added along with bug 882677
|
|
}
|
|
);
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|
|
|