mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
Bug 881954 - Generalize test_too_many_elements to run on more than just Ogg audio. r=padenot
This commit is contained in:
parent
2fd31aa3da
commit
c8d412570d
@ -494,6 +494,25 @@ var gMetadataTests = [
|
||||
},
|
||||
];
|
||||
|
||||
// The resources for test_too_many_elements.
|
||||
// We loads *lots* of these all at the same time.
|
||||
var gTooManyElementAudioTests = [
|
||||
{ name:"small-shot.ogg", type:"audio/ogg" },
|
||||
{ name:"r11025_s16_c1.wav", type:"audio/x-wav" },
|
||||
{ name:"detodos.opus", type:"audio/ogg; codecs=opus" },
|
||||
{ name:"bogus.duh", type:"bogus/duh" }
|
||||
];
|
||||
// Unfortunately the WMF backend on Windows 7 can't handle having lots of
|
||||
// decoders running concurrently, so we only include MPEG files when running on
|
||||
// Windows versions 8 and later, and non Windows systems.
|
||||
if (navigator.userAgent.indexOf("Windows") == -1 ||
|
||||
IsWindows8OrLater()) {
|
||||
gTooManyElementAudioTests = gTooManyElementAudioTests.concat([
|
||||
{ name:"small-shot.m4a", type:"audio/mp4" },
|
||||
{ name:"small-shot.mp3", type:"audio/mpeg" }
|
||||
]);
|
||||
}
|
||||
|
||||
function checkMetadata(msg, e, test) {
|
||||
if (test.width) {
|
||||
is(e.videoWidth, test.width, msg + " video width");
|
||||
|
@ -24,43 +24,65 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=713381
|
||||
|
||||
const num = 500;
|
||||
var loadeddata = 0;
|
||||
var testName = "?";
|
||||
|
||||
var result = document.getElementById("result");
|
||||
document.getElementById("expected").innerHTML = " of " + num + " ";
|
||||
|
||||
var finish = function(testNum) {
|
||||
return function() {
|
||||
ok(true, "Received loadeddata event for instance " + testNum );
|
||||
ok(true, testName + ": received loadeddata event for instance " + testNum );
|
||||
loadeddata++;
|
||||
if (loadeddata == num) {
|
||||
ok(true, "Should receive loadeddata events for all " + num + " elements.");
|
||||
SimpleTest.finish();
|
||||
ok(true, testName + ": should receive loadeddata events for all " + num + " elements.");
|
||||
nextTest();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var resource = getPlayableAudio(gSmallTests);
|
||||
var testNum = 0;
|
||||
|
||||
function nextTest() {
|
||||
if (testNum >= gTooManyElementAudioTests.length) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
var test = gTooManyElementAudioTests[testNum];
|
||||
testNum++;
|
||||
|
||||
if (!document.createElement("audio").canPlayType(test.type)) {
|
||||
setTimeout(nextTest, 0);
|
||||
return;
|
||||
}
|
||||
var name = test.name;
|
||||
|
||||
loadeddata = 0;
|
||||
testName = name;
|
||||
|
||||
if (resource == null) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
// Load the resource, and play it to ensure it's entirely downloaded.
|
||||
// Once it's played through, create a large number of audio elements which
|
||||
// are the same resource. These will share data with the other resource, and
|
||||
// so be really cheap to create.
|
||||
var res = new Audio(resource.name);
|
||||
var res = new Audio(name);
|
||||
res.addEventListener("ended",
|
||||
function() {
|
||||
for (var i=0; i<num; ++i) {
|
||||
var a = new Audio(resource.name);
|
||||
var a = new Audio(name);
|
||||
a.addEventListener("loadeddata", finish(i), false);
|
||||
}
|
||||
}, false);
|
||||
res.play();
|
||||
|
||||
}
|
||||
|
||||
setInterval(function() { result.innerHTML = loadeddata; }, 1000);
|
||||
if (getPlayableAudio(gTooManyElementAudioTests) == null) {
|
||||
todo(false, "No types supported");
|
||||
} else {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
nextTest();
|
||||
}
|
||||
|
||||
setInterval(function() { result.innerHTML = testName + ": " + loadeddata; }, 1000);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
Loading…
Reference in New Issue
Block a user