Bug 1315591 - remove duplicated waitUntilTime() in test_BufferingWait[_mp4].html. r=jya

MozReview-Commit-ID: 12Z9TJ4WVVt

--HG--
extra : rebase_source : 34b9d33b354c41f02ce0da7dfcf13612e809bd34
This commit is contained in:
JW Wang 2016-11-07 11:49:38 +08:00
parent 41ed0a2cdf
commit c73002e638
2 changed files with 4 additions and 30 deletions

View File

@ -20,19 +20,6 @@ runWithMSE(function(ms, v) {
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(
@ -42,14 +29,14 @@ runWithMSE(function(ms, v) {
/* 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);

View File

@ -20,19 +20,6 @@ runWithMSE(function(ms, v) {
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'))
@ -42,7 +29,7 @@ runWithMSE(function(ms, v) {
.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;
@ -50,7 +37,7 @@ runWithMSE(function(ms, v) {
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);