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, and the order of the first event in relation
13                 // to the other events is not guaranteed, and we only want to ensure
14                 // that AT LEAST one is fired so just count the number of events instead
15                 // of logging them.
16                 if (++progressEventCount > 1)
17                     return;
18             }
19
20             function loaded()
21             {
22                 consoleWrite("EVENT(load)");
23                 
24                 testExpected('progressEventCount', 1, '>=');
25                 endTest();
26             }
27
28             function start()
29             {
30                 run("mediaElement = document.createElement('audio')");
31
32                 mediaElement.setAttribute('onload', "loaded()");
33                 mediaElement.setAttribute('onprogress', "progress()");
34
35                 waitForEvent("loadstart");
36                 waitForEvent("waiting");
37                 waitForEvent("ratechange");
38                 waitForEvent("durationchange");
39                 waitForEvent("pause");
40                 waitForEvent("play");
41                 waitForEvent("playing");
42                 waitForEvent('loadedmetadata');
43                 waitForEvent('loadeddata');
44
45                 run("mediaElement.src = 'content/test.wav'");
46                 run("mediaElement.load()");
47
48                 consoleWrite("");
49             }
50
51         </script>
52     </head>
53
54     <body onload="start()">
55
56     <p>Test that at least one 'progress' event is fired before the 'load' event.</p>
57
58     </body>
59 </html>