64 lines
1.8 KiB
HTML
64 lines
1.8 KiB
HTML
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
<body>
|
|
|
|
<p>Tests that we don't garbage collect playing audio object or event listener.</p>
|
|
<p>According to http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html,<br />
|
|
"4.8.10.8 Playing the media resource",<br />
|
|
"Media elements must not stop playing just because all references to them have
|
|
been removed; only once a media element is in a state where no further audio
|
|
could ever be played by that element may the element be garbage collected."<br /><br />
|
|
(see https://bugs.webkit.org/show_bug.cgi?id=66878, https://bugs.webkit.org/show_bug.cgi?id=70421, and http://crbug.com/62604 for more details).</p>
|
|
<p id="result">
|
|
FAIL: Test either still running or stopped prematurely.
|
|
</p>
|
|
|
|
<script src=../resources/gc.js></script>
|
|
<script src=media-file.js></script>
|
|
<script src=video-test.js></script>
|
|
<script type="text/javascript">
|
|
|
|
var num_players = 4;
|
|
var play_times = 5;
|
|
|
|
function finish() {
|
|
document.getElementById("result").innerText = "PASS";
|
|
if (window.testRunner) {
|
|
testRunner.notifyDone();
|
|
}
|
|
}
|
|
|
|
function start() {
|
|
var num_played = 0;
|
|
var audioFile = findMediaFile("audio", "content/silence");
|
|
var a = new Audio(audioFile);
|
|
a.addEventListener('ended', function() {
|
|
num_played ++;
|
|
if (num_played < play_times) {
|
|
a.currentTime = a.duration - 0.35;
|
|
a.play();
|
|
if (num_played == play_times - 1) {
|
|
a = null;
|
|
gc();
|
|
}
|
|
} else {
|
|
num_players --;
|
|
if (num_players == 0)
|
|
start();
|
|
else
|
|
finish();
|
|
}
|
|
});
|
|
a.addEventListener('canplaythrough', function() {
|
|
a.currentTime = a.duration - 0.35;
|
|
a.play();
|
|
});
|
|
}
|
|
|
|
start();
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|