OLD | NEW |
1 <html> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test media element's "played" attribute.</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 video = document.querySelector("video"); |
10 | 12 |
11 var testFunctions = | 13 video.onerror = t.step_func(function() {}); |
12 [ | 14 video.onloadstart = t.step_func(function() {}); |
13 PlayWithNoRanges, | 15 video.onratechange = t.step_func(function() {}); |
14 ResetToAVideoSource, | 16 video.onloadedmetadata = t.step_func(function() {}); |
15 JumpAndPlayFwd, | 17 video.oncanplay = t.step_func(function() { |
16 ResetToAnEmptyVideoSource | 18 video.oncanplay = null; |
17 ]; | 19 testRanges(video); |
| 20 // Test playing when there are no ranges. |
| 21 timeRangeCount = currentTimeRange = 0; |
| 22 startPlayingInNewRange(t); |
| 23 }); |
| 24 waitForPauseAndContinue(t, resetToAVideoSource, false); |
18 | 25 |
19 // NOTE: Result details are not printed for this test because time v
alues are different from machine | 26 function resetToAVideoSource() { |
20 // to machine and run to run. Commenting out the following line turn
s on detailed logging back on, which | 27 // Test to reset to non empty video source. |
21 // can be useful for debugging test failure. | 28 timeRangeCount = currentTimeRange = 0; |
22 disableFullTestDetailsPrinting(); | 29 expectedStartTimes = new Array(); |
| 30 expectedEndTimes = new Array(); |
| 31 video.src = findMediaFile("video", "content/test"); |
| 32 video.oncanplay = t.step_func(jumpAndPlayFwd); |
| 33 } |
23 | 34 |
24 function PlayWithNoRanges() | 35 function jumpAndPlayFwd() { |
25 { | 36 video.oncanplay = null; |
26 consoleWrite("<br><b><em>Test playing when there are no ranges</
em></b>"); | 37 testRanges(video); |
| 38 // Test jumping forward into a new range and play. |
| 39 video.currentTime = (video.duration - 0.5).toFixed(2); |
| 40 currentTimeRange = 1; |
| 41 startPlayingInNewRange(t); |
| 42 waitForPauseAndContinue(t, ResetToAnEmptyVideoSource, false); |
| 43 } |
27 | 44 |
28 timeRangeCount = currentTimeRange = 0; | 45 function ResetToAnEmptyVideoSource() { |
29 willPauseInExistingRange = false; | 46 // Test to reset to an empty video source. |
30 willExtendAnExistingRange = false; | 47 timeRangeCount = currentTimeRange = 0; |
| 48 expectedStartTimes = new Array(); |
| 49 expectedEndTimes = new Array(); |
| 50 video.src = ""; |
| 51 video.onloadstart = t.step_func_done(testRanges); |
| 52 } |
31 | 53 |
32 startPlayingInNewRange(); | 54 video.src = findMediaFile("video", "content/test"); |
33 } | 55 }); |
34 | 56 </script> |
35 function ResetToAVideoSource() | |
36 { | |
37 consoleWrite("<br><b><em>Test to reset to non empty video source
</em></b>"); | |
38 | |
39 timeRangeCount = currentTimeRange = 0; | |
40 expectedStartTimes = new Array(); | |
41 expectedEndTimes = new Array(); | |
42 | |
43 willPauseInExistingRange = false; | |
44 willExtendAnExistingRange = false; | |
45 | |
46 var mediaFile = findMediaFile("video", "content/test"); | |
47 runSilently("video.src = \"" + mediaFile + "\""); | |
48 | |
49 waitForEventOnce("canplay", canplay); | |
50 run("video.load()"); // Triggers canplay() | |
51 } | |
52 | |
53 function JumpAndPlayFwd() | |
54 { | |
55 consoleWrite("<br><b><em>Test jumping forward into a new range a
nd play</em></b>"); | |
56 | |
57 var newTime = video.duration - 0.5; | |
58 runSilently("video.currentTime = " + (newTime.toFixed(2))); | |
59 | |
60 willPauseInExistingRange = false; | |
61 willExtendAnExistingRange = false; | |
62 currentTimeRange = 1; | |
63 | |
64 startPlayingInNewRange(); | |
65 } | |
66 | |
67 function ResetToAnEmptyVideoSource() | |
68 { | |
69 consoleWrite("<br><b><em>Test to reset to an empty video source<
/em></b>"); | |
70 | |
71 willPauseInExistingRange = false; | |
72 willExtendAnExistingRange = false; | |
73 timeRangeCount = currentTimeRange = 0; | |
74 | |
75 expectedStartTimes = new Array(); | |
76 expectedEndTimes = new Array(); | |
77 | |
78 run("video.src = \"\""); | |
79 waitForEvent("loadstart", function () { testRanges(); nextTest()
; }); | |
80 run("video.load()"); // Triggers loadstart() | |
81 } | |
82 </script> | |
83 </head> | |
84 | |
85 <body onload="videoPlayedMain()"> | |
86 | |
87 <video controls></video> | |
88 <p>Test of the media element 'played' attribute</p> | |
89 | |
90 </body> | |
91 </html> | |
OLD | NEW |