Bug 1289742. P5 - test.duration is mandatory to run the test. r=kaku

MozReview-Commit-ID: GSvVrCBTeQB

--HG--
extra : rebase_source : 4ebe68ec17daa3fab40142f3136e2e29177a3474
This commit is contained in:
JW Wang 2017-03-06 15:15:38 +08:00
Родитель de071ed157
Коммит d423d4d586
1 изменённых файлов: 10 добавлений и 15 удалений

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

@ -14,15 +14,15 @@
SimpleTest.requestCompleteLog(); SimpleTest.requestCompleteLog();
var manager = new MediaTestManager; var manager = new MediaTestManager;
function checkDuration(actual, expected, name) {
ok(Math.abs(actual - expected) < 0.1,
`${name} duration: ${actual} expected: ${expected}`);
}
function cloneLoaded(event) { function cloneLoaded(event) {
ok(true, "Clone loaded OK"); ok(true, "Clone loaded OK");
var e = event.target; var e = event.target;
checkDuration(e.duration, e._expectedDuration, e.token);
if (e._expectedDuration) {
ok(Math.abs(e.duration - e._expectedDuration) < 0.1,
"Clone " + e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
}
removeNodeAndSource(e); removeNodeAndSource(e);
manager.finished(e.token); manager.finished(e.token);
} }
@ -45,11 +45,8 @@ function tryClone(event) {
}); });
if (e._expectedDuration) { checkDuration(e.duration, e._expectedDuration, e.token);
ok(Math.abs(e.duration - e._expectedDuration) < 0.1, clone._expectedDuration = e._expectedDuration;
e.currentSrc + " duration: " + e.duration + " expected: " + e._expectedDuration);
clone._expectedDuration = e._expectedDuration;
}
clone.addEventListener("loadeddata", cloneLoaded, {once: true}); clone.addEventListener("loadeddata", cloneLoaded, {once: true});
clone.addEventListener("loadstart", function(evt) { clone.addEventListener("loadstart", function(evt) {
@ -76,10 +73,8 @@ function initTest(test, token) {
var e = document.createElement(elemType); var e = document.createElement(elemType);
e.preload = "auto"; e.preload = "auto";
e.src = test.name; e.src = test.name;
if (test.duration) { e._expectedDuration = test.duration;
e._expectedDuration = test.duration; ok(true, `Trying to load ${test.name}, duration=${test.duration}`);
}
ok(true, "Trying to load " + test.name);
e.addEventListener("loadeddata", tryClone, {once: true}); e.addEventListener("loadeddata", tryClone, {once: true});
e.token = token; e.token = token;
manager.started(token); manager.started(token);