| Index: third_party/WebKit/LayoutTests/media/audio-garbage-collect.html
|
| diff --git a/third_party/WebKit/LayoutTests/media/audio-garbage-collect.html b/third_party/WebKit/LayoutTests/media/audio-garbage-collect.html
|
| index 942f437d576a1d48fefebf9e649e5757bbc59444..148cbd2fe065c8283918f7bc0fe6101fa9f2d3f4 100644
|
| --- a/third_party/WebKit/LayoutTests/media/audio-garbage-collect.html
|
| +++ b/third_party/WebKit/LayoutTests/media/audio-garbage-collect.html
|
| @@ -1,66 +1,41 @@
|
| <!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>
|
| -<!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956
|
| - (Please avoid writing new tests using video-test.js) -->
|
| -<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;
|
| +<title>Tests that we don't garbage collect audio object while it is still playing.</title>
|
| +<script src="media-file.js"></script>
|
| +<script src="../resources/gc.js"></script>
|
| +<script src="../resources/testharness.js"></script>
|
| +<script src="../resources/testharnessreport.js"></script>
|
| +<script>
|
| +// According to http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html,
|
| +// 4.8.10.8 Playing the media resource,
|
| +// 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.
|
| +// 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).
|
| +async_test(function(t) {
|
| + var audioPlayers = 4;
|
| + var playedCount = 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;
|
| + var audio = new Audio(audioFile);
|
| +
|
| + audio.onended = t.step_func(function() {
|
| + playedCount ++;
|
| + if (playedCount <= audioPlayers) {
|
| + audio.currentTime = audio.duration - 0.35;
|
| + audio.play();
|
| + if (playedCount == audioPlayers) {
|
| + audio = null;
|
| gc();
|
| }
|
| } else {
|
| - num_players --;
|
| - if (num_players == 0)
|
| - start();
|
| - else
|
| - finish();
|
| + t.done();
|
| }
|
| });
|
|
|
| - waitForEvent('canplaythrough', function() {
|
| - a.currentTime = a.duration - 0.35;
|
| - a.play();
|
| - }, false, true, a, true);
|
| -}
|
| -
|
| -start();
|
| -
|
| -</script>
|
| -</body>
|
| -</html>
|
| + audio.oncanplaythrough = t.step_func(function() {
|
| + audio.oncanplaythrough = null;
|
| + audio.currentTime = audio.duration - 0.35;
|
| + audio.play();
|
| + });
|
| +});
|
| +</script>
|
|
|