upload tizen1.0 source
[framework/web/webkit-efl.git] / LayoutTests / media / audio-garbage-collect.html
1 <!DOCTYPE HTML>
2
3 <html>
4 <body>
5
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>
16
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">
21
22 var num_players = 4;
23 var play_times = 5;
24
25 function finish() {
26     document.getElementById("result").innerText = "PASS";
27     if (window.layoutTestController) {
28         layoutTestController.notifyDone();
29     }
30 }
31
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();
44             }
45         } else {
46             num_players --;
47             if (num_players == 0)
48                 start();
49             else
50                 finish();
51         }
52     });
53     a.addEventListener('canplaythrough', function() {
54         a.currentTime = a.duration - 0.35;
55         a.play();
56     });
57 }
58
59 start();
60
61 </script>
62 </body>
63 </html>