Bug 1276530 - Fix test_texttrackevents_video.html. r=rillian

MozReview-Commit-ID: Gn11D3I0MRb

--HG--
extra : transplant_source : %B0%83%11%19m%870%98%90%14%2A%82%D3f%B0%C1%8A%B5Cw
This commit is contained in:
bechen 2016-06-17 17:08:09 +08:00
Родитель 1b81dcec35
Коммит feac509453
1 изменённых файлов: 32 добавлений и 4 удалений

Просмотреть файл

@ -29,6 +29,8 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
var trackElementCueChangeCount = 0;
var trackCueChangeCount = 0;
var cueEnterCount = 0;
var cueExitCount = 0;
video.addEventListener("loadedmetadata", function run_tests() {
// Re-queue run_tests() at the end of the event loop until the track
@ -39,6 +41,27 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
is(trackElement.readyState, 2, "Track::ReadyState should be set to LOADED.");
ok('oncuechange' in trackElement.track, "Track::OnCueChange should exist.");
var textTrack = trackElement.track;
is(textTrack.cues.length, 3, "textTrack.cues.length should 3.");
textTrack.cues[0].onenter = function() {
++cueEnterCount;
};
textTrack.cues[0].onexit = function() {
++cueExitCount;
};
textTrack.cues[1].onenter = function() {
++cueEnterCount;
};
textTrack.cues[1].onexit = function() {
++cueExitCount;
};
textTrack.cues[2].onenter = function() {
++cueEnterCount;
};
textTrack.cues[2].onexit = function() {
++cueExitCount;
};
trackElement.track.oncuechange = function() {
++trackElementCueChangeCount;
};
@ -51,10 +74,15 @@ SpecialPowers.pushPrefEnv({"set": [["media.webvtt.enabled", true]]},
});
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.");
// Should be fired 1 to 6 times, as there are 3 cues,
// with a change event for when it is activated/deactivated
// (6 events at most).
isnot(trackElementCueChangeCount, 0, "TrackElement should fire cue change at least one time.");
ok(trackElementCueChangeCount <= 6, 'trackElementCueChangeCount should <= 6');
isnot(trackCueChangeCount, 0, "TrackElement.track should fire cue change at least one time.");
ok(trackCueChangeCount <= 6, 'trackCueChangeCount should <= 6');
is(cueEnterCount, 3, "cueEnterCount should fire three times.");
is(cueExitCount, 3, "cueExitCount should fire three times.");
SimpleTest.finish()
})
}