f76cd94053dbdae8e038ac5da440f9528eb66479
[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 loadend()
21             {
22                 consoleWrite("EVENT(loadend)");
23                 
24                 testExpected('progressEventCount', 1, '>=');
25                 endTest();
26             }
27
28             function start()
29             {
30                 run("mediaElement = document.createElement('audio')");
31
32                 mediaElement.setAttribute('onloadend', "loadend()");
33                 mediaElement.setAttribute('onprogress', "progress()");
34
35                 waitForEvent("loadstart");
36                 waitForEvent("loadend");
37                 waitForEvent("loaded");
38                 waitForEvent("waiting");
39                 waitForEvent("ratechange");
40                 waitForEvent("durationchange");
41                 waitForEvent("pause");
42                 waitForEvent("play");
43                 waitForEvent("playing");
44                 waitForEvent('loadedmetadata');
45                 waitForEvent('loadeddata');
46
47                 run("mediaElement.src = 'content/test.wav'");
48                 run("mediaElement.load()");
49
50                 consoleWrite("");
51             }
52
53         </script>
54     </head>
55
56     <body onload="start()">
57
58     <p>Test that at least one 'progress' event is fired before the 'load' event.</p>
59
60     </body>
61 </html>