2009-11-27 Daniel Bates <dbates@webkit.org>
[webkit:qtwebkit.git] / LayoutTests / http / tests / media / video-play-stall.html
1 <video></video>
2 <p>Test that stalled, timeupdate and waiting events are sent when media load stalls in the middle.</p>
3 <script src=../../../media/video-test.js></script>
4 <script>
5
6     var timeupdateCount = 0;
7     var waitingCount = 0;
8
9     waitForEvent('durationchange');
10     waitForEvent('loadedmetadata');
11     waitForEvent('loadeddata');
12     waitForEvent('canplaythrough');
13     waitForEvent('canplay', function () {
14
15         mediaElement.addEventListener('timeupdate', function () {
16             // timeupdate events are fired as playback progresses so only verify that at least one
17             // event is fired
18             ++timeupdateCount;
19             if (timeupdateCount == 1)
20                 consoleWrite("EVENT(timeupdate)");
21         } );
22
23         waitForEvent('waiting', function () {
24             ++waitingCount;
25             if (waitingCount > 1)
26                 failTest("too many 'waiting' events fired.");
27
28             waitForEvent('timeupdate');
29         } );
30
31         waitForEventAndEnd('stalled');
32     } );
33     video.src = "http://127.0.0.1:8000/media/video-load-and-stall.cgi?name=../../../media/content/test.mp4&stallAt=100000";
34     run("video.play()");
35 </script>