Bug 1315591 - remove duplicated waitUntilTime() in test_BufferingWait[_mp4].html.
MozReview-Commit-ID: 12Z9TJ4WVVt
--- a/dom/media/mediasource/test/test_BufferingWait.html
+++ b/dom/media/mediasource/test/test_BufferingWait.html
@@ -15,46 +15,33 @@ var receivedSourceOpen = false;
runWithMSE(function(ms, v) {
ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
receivedSourceOpen = true;
var sb = ms.addSourceBuffer("video/webm");
ok(sb, "Create a SourceBuffer");
- function waitUntilTime(targetTime) {
- return new Promise(function(resolve, reject) {
- v.addEventListener("waiting", function onwaiting() {
- info("Got a waiting event at " + v.currentTime);
- if (v.currentTime >= targetTime) {
- ok(true, "Reached target time of: " + targetTime);
- v.removeEventListener("waiting", onwaiting);
- resolve();
- }
- });
- });
- }
-
fetchWithXHR("seek.webm", function(arrayBuffer) {
sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 0, 318))().then(
loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 318, 25523-318))).then(
loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 25523, 46712-25523))).then(
/* Note - Missing |46712, 67833 - 46712| segment here corresponding to (0.8, 1.2] */
/* Note - Missing |67833, 88966 - 67833| segment here corresponding to (1.2, 1.6] */
loadSegment.bind(null, sb, new Uint8Array(arrayBuffer, 88966))).then(function() {
// 0.767 is the time of the last video sample +- 40ms.
- var promise = waitUntilTime(.767-0.04);
+ var promise = waitUntilTime(v, .767-0.04);
info("Playing video. It should play for a bit, then fire 'waiting'");
v.play();
return promise;
}).then(function() {
window.firstStop = Date.now();
loadSegment(sb, new Uint8Array(arrayBuffer, 46712, 67833 - 46712));
- return waitUntilTime(1.167-0.04);
+ return waitUntilTime(v, 1.167-0.04);
}).then(function() {
var waitDuration = (Date.now() - window.firstStop) / 1000;
ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
SimpleTest.finish();
/* If we allow the rest of the stream to be played, we get stuck at
around 2s. See bug 1093133.
once(v, 'ended', SimpleTest.finish.bind(SimpleTest));
return loadSegment(sb, new Uint8Array(arrayBuffer, 67833, 88966 - 67833));
--- a/dom/media/mediasource/test/test_BufferingWait_mp4.html
+++ b/dom/media/mediasource/test/test_BufferingWait_mp4.html
@@ -15,47 +15,34 @@ var receivedSourceOpen = false;
runWithMSE(function(ms, v) {
ms.addEventListener("sourceopen", function() {
ok(true, "Receive a sourceopen event");
ok(!receivedSourceOpen, "Should only receive one sourceopen for this test");
receivedSourceOpen = true;
var sb = ms.addSourceBuffer("video/mp4");
ok(sb, "Create a SourceBuffer");
- function waitUntilTime(targetTime) {
- return new Promise(function(resolve, reject) {
- v.addEventListener("waiting", function onwaiting() {
- info("Got a waiting event at " + v.currentTime);
- if (v.currentTime >= targetTime) {
- ok(true, "Reached target time of: " + targetTime);
- v.removeEventListener("waiting", onwaiting);
- resolve();
- }
- });
- });
- }
-
sb.addEventListener('error', (e) => { ok(false, "Got Error: " + e); SimpleTest.finish(); });
fetchAndLoad(sb, 'bipbop/bipbop', ['init'], '.mp4')
.then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', ['1'], '.m4s'))
.then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', ['2'], '.m4s'))
/* Note - Missing |bipbop3| segment here corresponding to (1.62, 2.41] */
/* Note - Missing |bipbop4| segment here corresponding to (2.41, 3.20] */
.then(fetchAndLoad.bind(null, sb, 'bipbop/bipbop', ['5'], '.m4s'))
.then(function() {
// last audio sample has a start time of 1.578956s
- var promise = waitUntilTime(1.57895);
+ var promise = waitUntilTime(v, 1.57895);
info("Playing video. It should play for a bit, then fire 'waiting'");
v.play();
return promise;
}).then(function() {
window.firstStop = Date.now();
fetchAndLoad(sb, 'bipbop/bipbop', ['3'], '.m4s');
// last audio sample has a start time of 2.368435
- return waitUntilTime(2.36843);
+ return waitUntilTime(v, 2.36843);
}).then(function() {
var waitDuration = (Date.now() - window.firstStop) / 1000;
ok(waitDuration < 15, "Should not spend an inordinate amount of time buffering: " + waitDuration);
once(v, 'ended', SimpleTest.finish.bind(SimpleTest));
return fetchAndLoad(sb, 'bipbop/bipbop', ['4'], '.m4s');
}).then(function() {
ms.endOfStream();
});;