2012-01-19 10:30:29 -08:00
|
|
|
<!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>
|
2012-01-19 10:31:03 -08:00
|
|
|
|
|
|
|
<p>Received loadeddata event for <span id="result">0</span> <span id="expected"></span>audio elements.</p>
|
2012-01-19 10:30:29 -08:00
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 713381 **/
|
|
|
|
|
|
|
|
const num = 500;
|
2012-01-19 10:31:03 -08:00
|
|
|
var loadeddata = 0;
|
|
|
|
|
|
|
|
var result = document.getElementById("result");
|
|
|
|
document.getElementById("expected").innerHTML = " of " + num + " ";
|
2012-01-19 10:30:29 -08:00
|
|
|
|
|
|
|
var finish = function(testNum) {
|
|
|
|
return function() {
|
2012-01-19 10:31:03 -08:00
|
|
|
ok(true, "Received loadeddata event for instance " + testNum );
|
|
|
|
loadeddata++;
|
|
|
|
if (loadeddata == num) {
|
|
|
|
ok(true, "Should receive loadeddata events for all " + num + " elements.");
|
2012-01-19 10:30:29 -08:00
|
|
|
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);
|
2012-01-19 10:31:03 -08:00
|
|
|
a.addEventListener("loadeddata", finish(i), false);
|
2012-01-19 10:30:29 -08:00
|
|
|
}
|
|
|
|
}, false);
|
|
|
|
res.play();
|
|
|
|
}
|
|
|
|
|
2012-01-19 10:31:03 -08:00
|
|
|
setInterval(function() { result.innerHTML = loadeddata; }, 1000);
|
2012-01-19 10:30:29 -08:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|