Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / audio-garbage-collect.html
blobd7184cf106bfd60c34bdbd299a4da117cf797ed8
1 <!DOCTYPE HTML>
3 <html>
4 <body>
6 <p>Tests that we don't garbage collect playing audio object or event listener.</p>
7 <p>According to http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html,<br />
8 "4.8.10.8 Playing the media resource",<br />
9 "Media elements must not stop playing just because all references to them have
10 been removed; only once a media element is in a state where no further audio
11 could ever be played by that element may the element be garbage collected."<br /><br />
12 (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>
13 <p id="result">
14 FAIL: Test either still running or stopped prematurely.
15 </p>
17 <script src=../resources/gc.js></script>
18 <script src=media-file.js></script>
19 <script src=video-test.js></script>
20 <script type="text/javascript">
22 var num_players = 4;
23 var play_times = 5;
25 function finish() {
26 document.getElementById("result").innerText = "PASS";
27 if (window.testRunner) {
28 testRunner.notifyDone();
32 function start() {
33 var num_played = 0;
34 var audioFile = findMediaFile("audio", "content/silence");
35 var a = new Audio(audioFile);
36 a.addEventListener('ended', function() {
37 num_played ++;
38 if (num_played < play_times) {
39 a.currentTime = a.duration - 0.35;
40 a.play();
41 if (num_played == play_times - 1) {
42 a = null;
43 gc();
45 } else {
46 num_players --;
47 if (num_players == 0)
48 start();
49 else
50 finish();
52 });
54 waitForEvent('canplaythrough', function() {
55 a.currentTime = a.duration - 0.35;
56 a.play();
57 }, false, true, a, true);
60 start();
62 </script>
63 </body>
64 </html>