Add new access object callback
[framework/web/webkit-efl.git] / LayoutTests / media / video-played-collapse.html
1 <html>
2     <head>
3         <title>Test of 'played' attribute</title>
4         <script src=media-file.js></script>
5         <script src=video-test.js></script>
6         <script src=video-played.js></script>
7         <script>
8     
9             var testFunctions = 
10             [ 
11                 PlayWithNoRanges,
12                 CreateANewRange,
13                 JumpAndCollapseTwoRanges,
14                 TestLoopingAndPassToTheEnd
15             ];
16     
17             // NOTE: Result details are not printed for this test because time values are different from machine
18             // to machine and run to run. Commenting out the following line turns on detailed logging back on, which
19             // can be useful for debugging test failure.
20             disableFullTestDetailsPrinting(); 
21
22             function PlayWithNoRanges()
23             {
24                 consoleWrite("<br><b><em>Test playing when there are no ranges</em></b>");
25
26                 willPauseInExistingRange = false;
27                 willExtendAnExistingRange = false;
28                 timeRangeCount = currentTimeRange = 0;
29
30                 runSilently("video.currentTime = 0.5");
31
32                 currentTimeRange++;
33                 startPlayingInNewRange();
34             }
35     
36
37             function CreateANewRange()
38             {
39                 consoleWrite("<br><b><em>Create a new range</em></b>");
40         
41                 var newTime = (video.played.end(0) + 0.05).toFixed(2);
42                 runSilently("video.currentTime = " + newTime);
43
44                 willPauseInExistingRange = false;
45                 willExtendAnExistingRange = false;
46
47                 startPlayingInNewRange();
48             }
49
50             function JumpAndCollapseTwoRanges()
51             {
52                 consoleWrite("<br><b><em>Test playing from one range into another, should collapse the two ranges</em></b>");
53     
54                 timeRangeCount--;
55                 currentTimeRange = timeRangeCount - 1;
56                 var startTime = expectedStartTimes[0] - 0.1;
57                 expectedStartTimes[0] = startTime;
58                 expectedEndTimes[0] = expectedEndTimes[1];
59
60                 willPauseInExistingRange = false;
61                 willExtendAnExistingRange = false;
62                 runSilently("video.currentTime = " + startTime);
63
64                 playForMillisecs(secToMilli(expectedEndTimes[1] - startTime + 0.1)); // Triggers pause()
65             }
66
67             function TestLoopingAndPassToTheEnd()
68             {
69                 consoleWrite("<br><b><em>Test looping</em></b>");
70
71                 // Start playing near the end of the movie so it will loop quickly.
72                 run("video.loop = true");
73                 var startTime = (video.duration - 0.05).toFixed(2);
74                 runSilently("video.currentTime = " + startTime);
75                 
76                 // We will end in the very first time range
77                 currentTimeRange = 0; 
78
79                 willPauseInExistingRange = true;
80                 willExtendAnExistingRange = true;
81
82                 // Playing from near the end so we will create a new time range from startTime .. duration
83                 timeRangeCount++;
84                 expectedStartTimes[timeRangeCount-1] = startTime;
85                 expectedEndTimes[timeRangeCount-1] = video.duration.toFixed(2);
86
87                 // Have to play for long enough to loop and play into the existing range.
88                 var playDuration = 1.25;
89
90                 // Playback restarts from beginning, so expect the beginning of first time range to be 0.
91                 expectedStartTimes[0] = 0;
92                 playForMillisecs(secToMilli(playDuration)); // Triggers pause()
93             }
94
95         </script>
96      </head>
97
98 <body onload="videoPlayedMain()">
99
100     <video controls></video>
101     <p>Test of the media element 'played' attribute</p>
102
103 </body>
104 </html>