mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1033144 - Part 2: Add tests for TextTrack cuechange event. r=rillian
This commit is contained in:
parent
24b291374f
commit
e8669ba74e
@ -488,6 +488,7 @@ support-files =
|
||||
seek_support.js
|
||||
seekLies.sjs
|
||||
seek_with_sound.ogg^headers^
|
||||
sequential.vtt
|
||||
short-cenc.mp4
|
||||
sine.webm
|
||||
sine.webm^headers^
|
||||
@ -841,6 +842,7 @@ tags=msg capturestream
|
||||
tags=msg capturestream
|
||||
[test_texttrack.html]
|
||||
[test_texttrackcue.html]
|
||||
[test_texttrackevents_video.html]
|
||||
[test_texttracklist.html]
|
||||
[test_texttrackregion.html]
|
||||
[test_timeupdate_small_files.html]
|
||||
|
10
dom/media/test/sequential.vtt
Normal file
10
dom/media/test/sequential.vtt
Normal file
@ -0,0 +1,10 @@
|
||||
WEBVTT
|
||||
|
||||
00:01.000 --> 00:02.000
|
||||
This
|
||||
|
||||
00:03.000 --> 00:04.000
|
||||
Is
|
||||
|
||||
00:05.000 --> 00:06.000
|
||||
A Test
|
65
dom/media/test/test_texttrackevents_video.html
Normal file
65
dom/media/test/test_texttrackevents_video.html
Normal file
@ -0,0 +1,65 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Tests for TextTrack DOM Events</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">
|
||||
</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");
|
||||
video.src = "vp9cake.webm";
|
||||
video.preload = "auto";
|
||||
video.controls = true;
|
||||
var trackElement = document.createElement("track");
|
||||
trackElement.src = "sequential.vtt";
|
||||
trackElement.kind = "subtitles";
|
||||
trackElement.default = true;
|
||||
document.getElementById("content").appendChild(video);
|
||||
video.appendChild(trackElement);
|
||||
|
||||
var trackElementCueChangeCount = 0;
|
||||
var trackCueChangeCount = 0;
|
||||
|
||||
video.addEventListener("loadedmetadata", function run_tests() {
|
||||
// Re-queue run_tests() at the end of the event loop until the track
|
||||
// element has loaded its data.
|
||||
if (trackElement.readyState == 1) {
|
||||
return setTimeout(run_tests, 0);
|
||||
}
|
||||
is(trackElement.readyState, 2, "Track::ReadyState should be set to LOADED.");
|
||||
ok('oncuechange' in trackElement.track, "Track::OnCueChange should exist.");
|
||||
|
||||
trackElement.track.oncuechange = function() {
|
||||
++trackElementCueChangeCount;
|
||||
};
|
||||
|
||||
trackElement.addEventListener("cuechange", function() {
|
||||
++trackCueChangeCount;
|
||||
});
|
||||
|
||||
video.play();
|
||||
});
|
||||
|
||||
video.addEventListener('ended', function() {
|
||||
// Should be fired 6 times, as there are 3 cues, with a change event
|
||||
// for when it is activated/deactivated (6 events total)
|
||||
is(trackElementCueChangeCount, 6, "TrackElement should fire cue change 6 times.");
|
||||
is(trackCueChangeCount, 6, "TrackElement.track should fire cue change 6 times.");
|
||||
SimpleTest.finish()
|
||||
})
|
||||
}
|
||||
);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user