OLD | NEW |
1 <html> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test media element's "played" attribute and ranges.</title> |
3 <title>Test of 'played' attribute</title> | 3 <script src="../resources/testharness.js"></script> |
4 <script src=media-file.js></script> | 4 <script src="../resources/testharnessreport.js"></script> |
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 5 <script src="media-file.js"></script> |
6 (Please avoid writing new tests using video-test.js) --> | 6 <script src="video-played.js"></script> |
7 <script src=video-test.js></script> | 7 <video></video> |
8 <script src=video-played.js></script> | 8 <script> |
9 <script> | 9 var video; |
| 10 async_test(function(t) { |
| 11 var expectedStartTimes = []; |
| 12 var expectedEndTimes = []; |
| 13 video = document.querySelector("video"); |
10 | 14 |
11 var testFunctions = | 15 video.oncanplay = t.step_func(function() { |
12 [ | 16 video.oncanplay = null; |
13 PlayWithNoRanges, | 17 testRanges(expectedStartTimes, expectedEndTimes); |
14 JumpAndPlayFwd, | 18 // Test playing when there are no ranges. |
15 JumpBackAndPlayToNewRange, | 19 timeRangeCount = currentTimeRange = 0; |
16 JumpAndExtendRangeStart, | 20 startPlayingInNewRange(t, expectedStartTimes); |
17 JumpAndExtendRangeEnd, | 21 }); |
18 ]; | 22 waitForPauseAndContinue(t, jumpAndPlayFwd, false, expectedStartTimes, expect
edEndTimes); |
19 | 23 |
20 // NOTE: Detailed results are not printed for this test because time
values are different from machine | 24 function jumpAndPlayFwd() { |
21 // to machine and run to run. Commenting out the following line turn
s on detailed logging back on, which | 25 // Test jumping forward into a new range and play. |
22 // can be useful for debugging test failure. | 26 video.currentTime = (video.duration - 1.0).toFixed(2); |
23 disableFullTestDetailsPrinting(); | 27 currentTimeRange = 1; |
| 28 startPlayingInNewRange(t, expectedStartTimes); |
| 29 waitForPauseAndContinue(t, jumpBackAndPlayToNewRange, false, expectedSta
rtTimes, expectedEndTimes); |
| 30 } |
24 | 31 |
25 function PlayWithNoRanges() | 32 function jumpBackAndPlayToNewRange() { |
26 { | 33 // Test jumping backwards into a new range and play, should insert new r
ange. |
27 consoleWrite("<br><b><em>Test playing when there are no ranges</
em></b>"); | 34 video.currentTime = 3.0; |
| 35 startPlayingInNewRange(t, expectedStartTimes); |
| 36 waitForPauseAndContinue(t, jumpAndExtendRangeStart, false, expectedStart
Times, expectedEndTimes); |
| 37 } |
28 | 38 |
29 timeRangeCount = currentTimeRange = 0; | 39 function jumpAndExtendRangeStart() { |
30 willPauseInExistingRange = false; | 40 // Test playing into an existing range, should extend range start. |
31 willExtendAnExistingRange = false; | 41 var newTime = (video.played.start(currentTimeRange) - 0.05).toFixed(2); |
| 42 video.currentTime = newTime; |
| 43 expectedStartTimes[currentTimeRange] = newTime; |
| 44 playForDuration(0.1, t); |
| 45 waitForPauseAndContinue(t, jumpAndExtendRangeEnd, true, expectedStartTim
es, expectedEndTimes); |
| 46 } |
32 | 47 |
33 startPlayingInNewRange(); | 48 function jumpAndExtendRangeEnd() { |
34 } | 49 // Test jumping into an existing range and play beyond end, should exten
d range end. |
| 50 var newTime = (video.played.end(currentTimeRange) - 0.05).toFixed(2); |
| 51 video.currentTime = newTime; |
| 52 playForDuration(0.03, t); |
| 53 waitForPauseAndContinue(t, null, true, expectedStartTimes, expectedEndTi
mes); |
| 54 } |
35 | 55 |
36 function JumpAndPlayFwd() | 56 video.src = findMediaFile("video", "content/test"); |
37 { | 57 }); |
38 consoleWrite("<br><b><em>Test jumping forward into a new range a
nd play</em></b>"); | 58 </script> |
39 | |
40 var newTime = video.duration - 1.0; | |
41 runSilently("video.currentTime = " + (newTime.toFixed(2))); | |
42 | |
43 currentTimeRange = 1; | |
44 willPauseInExistingRange = false; | |
45 willExtendAnExistingRange = false; | |
46 | |
47 startPlayingInNewRange(); | |
48 } | |
49 | |
50 function JumpBackAndPlayToNewRange() | |
51 { | |
52 consoleWrite("<br><b><em>Test jumping backwards into a new range
and play, should insert new range</em></b>"); | |
53 | |
54 var newTime = 3.00; | |
55 runSilently("video.currentTime = " + newTime); | |
56 | |
57 currentTimeRange = 1; | |
58 willPauseInExistingRange = false; | |
59 willExtendAnExistingRange = false; | |
60 | |
61 startPlayingInNewRange(); | |
62 } | |
63 | |
64 function JumpAndExtendRangeStart() | |
65 { | |
66 consoleWrite("<br><b><em>Test playing into an existing range, sh
ould extend range start</em></b>"); | |
67 | |
68 currentTimeRange = 1; | |
69 var newTime = (video.played.start(currentTimeRange) - 0.05).toFi
xed(2); | |
70 runSilently("video.currentTime = " + newTime); | |
71 | |
72 expectedStartTimes[currentTimeRange] = newTime; | |
73 willPauseInExistingRange = true; | |
74 willExtendAnExistingRange = true; | |
75 startPlaying(); | |
76 } | |
77 | |
78 function JumpAndExtendRangeEnd() | |
79 { | |
80 consoleWrite("<br><b><em>Test jumping into an existing range and
play beyond end, should extend range end</em></b>"); | |
81 | |
82 currentTimeRange = 1; | |
83 | |
84 var newTime = (video.played.end(currentTimeRange) - 0.05).toFixe
d(2); | |
85 runSilently("video.currentTime = " + newTime); | |
86 | |
87 willPauseInExistingRange = false; | |
88 willExtendAnExistingRange = true; | |
89 playForMillisecs(30); | |
90 } | |
91 | |
92 </script> | |
93 </head> | |
94 | |
95 <body onload="videoPlayedMain()"> | |
96 | |
97 <video controls></video> | |
98 <p>Test of the media element 'played' attribute, ranges part 1.</p> | |
99 | |
100 </body> | |
101 </html> | |
OLD | NEW |