diff --git a/dom/media/test/test_streams_element_capture.html b/dom/media/test/test_streams_element_capture.html index 092c40b29c2..353b7c1a034 100644 --- a/dom/media/test/test_streams_element_capture.html +++ b/dom/media/test/test_streams_element_capture.html @@ -9,6 +9,7 @@
 
 
diff --git a/dom/media/test/test_streams_element_capture_createObjectURL.html b/dom/media/test/test_streams_element_capture_createObjectURL.html index d33a8f080ea..b70f351603c 100644 --- a/dom/media/test/test_streams_element_capture_createObjectURL.html +++ b/dom/media/test/test_streams_element_capture_createObjectURL.html @@ -21,6 +21,11 @@ function checkDrawImage(vout) { is(imgData.data[3], 255, "Check video frame pixel has been drawn"); } +function isGreaterThanOrEqualEps(a, b, msg) { + ok(a >= b - 0.01, + "Got " + a + ", expected at least " + b + "; " + msg); +} + function startTest(test, token) { manager.started(token); @@ -36,8 +41,8 @@ function startTest(test, token) { var checkEnded = function(test, vout, stream) { return function() { is(stream.currentTime, vout.currentTime, test.name + " stream final currentTime"); if (test.duration) { - ok(Math.abs(vout.currentTime - test.duration) < 0.1, - test.name + " current time at end: " + vout.currentTime + " should be: " + test.duration); + isGreaterThanOrEqualEps(vout.currentTime, test.duration, + test.name + " current time at end"); } is(vout.readyState, vout.HAVE_CURRENT_DATA, test.name + " checking readyState"); ok(vout.ended, test.name + " checking playback has ended"); diff --git a/dom/media/test/test_streams_element_capture_reset.html b/dom/media/test/test_streams_element_capture_reset.html index 0820c1bd621..1290e4618b0 100644 --- a/dom/media/test/test_streams_element_capture_reset.html +++ b/dom/media/test/test_streams_element_capture_reset.html @@ -39,19 +39,24 @@ function isWithinEps(a, b, msg) { "Got " + a + ", expected " + b + "; " + msg); } +function isGreaterThanOrEqualEps(a, b, msg) { + ok(a >= b - 0.01, + "Got " + a + ", expected at least " + b + "; " + msg); +} + function startTest(test) { var seekTime = test.duration/2; function endedAfterReplay() { - isWithinEps(v.currentTime, test.duration, "checking v.currentTime at third 'ended' event"); - isWithinEps(vout.currentTime, (test.duration - seekTime) + test.duration*2, + isGreaterThanOrEqualEps(v.currentTime, test.duration, "checking v.currentTime at third 'ended' event"); + isGreaterThanOrEqualEps(vout.currentTime, (test.duration - seekTime) + test.duration*2, "checking vout.currentTime after seeking, playing through and reloading"); SimpleTest.finish(); }; function endedAfterSeek() { - isWithinEps(v.currentTime, test.duration, "checking v.currentTime at second 'ended' event"); - isWithinEps(vout.currentTime, (test.duration - seekTime) + test.duration, + isGreaterThanOrEqualEps(v.currentTime, test.duration, "checking v.currentTime at second 'ended' event"); + isGreaterThanOrEqualEps(vout.currentTime, (test.duration - seekTime) + test.duration, "checking vout.currentTime after seeking and playing through again"); v.removeEventListener("ended", endedAfterSeek, false); v.addEventListener("ended", endedAfterReplay, false); @@ -60,8 +65,8 @@ function startTest(test) { }; function seeked() { - isWithinEps(v.currentTime, seekTime, "Finished seeking"); - isWithinEps(vout.currentTime, test.duration, + isGreaterThanOrEqualEps(v.currentTime, seekTime, "Finished seeking"); + isGreaterThanOrEqualEps(vout.currentTime, test.duration, "checking vout.currentTime has not changed after seeking"); v.removeEventListener("seeked", seeked, false); function dontPlayAgain() { @@ -80,8 +85,8 @@ function startTest(test) { return; } - isWithinEps(vout.currentTime, test.duration, "checking vout.currentTime at first 'ended' event"); - isWithinEps(v.currentTime, test.duration, "checking v.currentTime at first 'ended' event"); + isGreaterThanOrEqualEps(vout.currentTime, test.duration, "checking vout.currentTime at first 'ended' event"); + isGreaterThanOrEqualEps(v.currentTime, test.duration, "checking v.currentTime at first 'ended' event"); is(vout.ended, false, "checking vout has not ended"); is(vout_untilended.ended, true, "checking vout_untilended has actually ended");