gecko/content/media/test/test_too_many_elements.html

69 lines
1.9 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=713381
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 713381</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript" src="manifest.js"></script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=713381">Mozilla Bug 713381</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<p>Received loadeddata event for <span id="result">0</span> <span id="expected"></span>audio elements.</p>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 713381 **/
const num = 500;
var loadeddata = 0;
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 );
loadeddata++;
if (loadeddata == num) {
ok(true, "Should receive loadeddata events for all " + num + " elements.");
SimpleTest.finish();
}
}
};
var resource = getPlayableAudio(gSmallTests);
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);
res.addEventListener("ended",
function() {
for (var i=0; i<num; ++i) {
var a = new Audio(resource.name);
a.addEventListener("loadeddata", finish(i), false);
}
}, false);
res.play();
}
setInterval(function() { result.innerHTML = loadeddata; }, 1000);
</script>
</pre>
</body>
</html>