2009-08-18 Eric Carlson <eric.carlson@apple.com>
[WebKit-https.git] / LayoutTests / media / progress-event-at-least-one.html
1 <html>
2     <head>
3         <script src=video-test.js></script>
4
5         <script>
6
7             var progressEventCount = 0;
8
9             function progress()
10             {
11                 // 'progress' events can fire an arbitrary number of times if the
12                 // file loads slowly, we only want to ensure that AT LEAST one is
13                 // fired so only log the first one so test results are consistent.
14                 if (++progressEventCount > 1)
15                     return;
16                 consoleWrite("EVENT(progress)");
17             }
18
19             function loaded()
20             {
21                 consoleWrite("EVENT(load)");
22                 
23                 testExpected('progressEventCount', 1, '>=');
24                 endTest();
25             }
26
27             function start()
28             {
29                 run("mediaElement = document.createElement('audio')");
30
31                 mediaElement.setAttribute('onload', "loaded()");
32                 mediaElement.setAttribute('onprogress', "progress()");
33
34                 waitForEvent("loadstart");
35                 waitForEvent("waiting");
36                 waitForEvent("ratechange");
37                 waitForEvent("durationchange");
38                 waitForEvent("pause");
39                 waitForEvent("play");
40                 waitForEvent("playing");
41                 waitForEvent('loadedmetadata');
42                 waitForEvent('loadeddata');
43
44                 run("mediaElement.src = 'content/test.wav'");
45                 run("mediaElement.load()");
46
47                 consoleWrite("");
48             }
49
50         </script>
51     </head>
52
53     <body onload="start()">
54
55     <p>Test that at least one 'progress' event is fired before the 'load' event.</p>
56
57     </body>
58 </html>