2009-09-18 Alpha Lam <hclam@chromium.org>
[WebKit-https.git] / LayoutTests / media / progress-event-at-least-one.html
1 <html>
2     <head>
3         <script src=media-file.js></script>
4         <script src=video-test.js></script>
5
6         <script>
7
8             var progressEventCount = 0;
9
10             function progress()
11             {
12                 // 'progress' events can fire an arbitrary number of times if the
13                 // file loads slowly, and the order of the first event in relation
14                 // to the other events is not guaranteed, and we only want to ensure
15                 // that AT LEAST one is fired so just count the number of events instead
16                 // of logging them.
17                 if (++progressEventCount > 1)
18                     return;
19             }
20
21             function loadend()
22             {
23                 consoleWrite("EVENT(loadend)");
24                 
25                 testExpected('progressEventCount', 1, '>=');
26                 endTest();
27             }
28
29             function start()
30             {
31                 run("mediaElement = document.createElement('audio')");
32
33                 mediaElement.setAttribute('onloadend', "loadend()");
34                 mediaElement.setAttribute('onprogress', "progress()");
35
36                 waitForEvent("loadstart");
37                 waitForEvent("loadend");
38                 waitForEvent("loaded");
39                 waitForEvent("waiting");
40                 waitForEvent("ratechange");
41                 waitForEvent("durationchange");
42                 waitForEvent("pause");
43                 waitForEvent("play");
44                 waitForEvent("playing");
45                 waitForEvent('loadedmetadata');
46                 waitForEvent('loadeddata');
47
48                 var mediaFile = findMediaFile("audio", "content/test");
49                 run("mediaElement.src = '" + mediaFile + "'");
50                 run("mediaElement.load()");
51
52                 consoleWrite("");
53             }
54
55         </script>
56     </head>
57
58     <body onload="start()">
59
60     <p>Test that at least one 'progress' event is fired before the 'load' event.</p>
61
62     </body>
63 </html>