gecko-dev/content/media/test/seek11.js
Chris Pearce a7d0ccd23a Bug 564720 - Refactor media tests to be backend independent were possible. r=roc
--HG--
rename : content/media/test/test_play.html => content/media/test/test_play_events.html
rename : content/media/test/test_progress2.html => content/media/test/test_progress.html
rename : content/media/test/test_onloadedmetadata.html => content/media/test/test_replay_metadata.html
rename : content/media/test/test_wav_trunc_seek.html => content/media/test/test_seek_out_of_range.html
rename : content/media/test/test_bug495319.html => content/media/test/test_timeupdate_small_files.html
rename : content/media/test/test_bug486646.html => content/media/test/test_video_to_canvas.html
2010-05-31 10:02:06 +12:00

48 lines
1.0 KiB
JavaScript

function test_seek11(v, seekTime, is, ok, finish) {
// Test for bug 476973, multiple seeks to the same position shouldn't cause problems.
var seekedNonZero = false;
var completed = false;
var target = 0;
function startTest() {
if (completed)
return false;
target = v.duration / 2;
v.currentTime = target;
v.currentTime = target;
return false;
}
function startSeeking() {
if (!seekedNonZero) {
v.currentTime = target;
}
}
function seekEnded() {
if (completed)
return false;
if (v.currentTime > 0) {
ok(v.currentTime > target - 0.1 && v.currentTime < target + 0.1,
"Seek to wrong destination " + v.currentTime);
seekedNonZero = true;
v.currentTime = 0.0;
} else {
ok(seekedNonZero, "Successfully seeked to nonzero");
ok(true, "Seek back to zero was successful");
completed = true;
finish();
}
return false;
}
v.addEventListener("loadedmetadata", startTest, false);
v.addEventListener("seeking", startSeeking, false);
v.addEventListener("seeked", seekEnded, false);
}