Index: third_party/WebKit/LayoutTests/media/video-played-reset.html |
diff --git a/third_party/WebKit/LayoutTests/media/video-played-reset.html b/third_party/WebKit/LayoutTests/media/video-played-reset.html |
index f0e71747dd2e2d8fe4e27bbe98aea1efa1726a5f..fb426c95fb2f895f781f2e6187e00cdc365b26fa 100644 |
--- a/third_party/WebKit/LayoutTests/media/video-played-reset.html |
+++ b/third_party/WebKit/LayoutTests/media/video-played-reset.html |
@@ -1,91 +1,54 @@ |
-<html> |
- <head> |
- <title>Test of 'played' attribute</title> |
- <script src=media-file.js></script> |
- <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 |
- (Please avoid writing new tests using video-test.js) --> |
- <script src=video-test.js></script> |
- <script src=video-played.js></script> |
- <script> |
- |
- var testFunctions = |
- [ |
- PlayWithNoRanges, |
- ResetToAVideoSource, |
- JumpAndPlayFwd, |
- ResetToAnEmptyVideoSource |
- ]; |
- |
- // NOTE: Result details are not printed for this test because time values are different from machine |
- // to machine and run to run. Commenting out the following line turns on detailed logging back on, which |
- // can be useful for debugging test failure. |
- disableFullTestDetailsPrinting(); |
- |
- function PlayWithNoRanges() |
- { |
- consoleWrite("<br><b><em>Test playing when there are no ranges</em></b>"); |
- |
- timeRangeCount = currentTimeRange = 0; |
- willPauseInExistingRange = false; |
- willExtendAnExistingRange = false; |
- |
- startPlayingInNewRange(); |
- } |
- |
- function ResetToAVideoSource() |
- { |
- consoleWrite("<br><b><em>Test to reset to non empty video source</em></b>"); |
- |
- timeRangeCount = currentTimeRange = 0; |
- expectedStartTimes = new Array(); |
- expectedEndTimes = new Array(); |
- |
- willPauseInExistingRange = false; |
- willExtendAnExistingRange = false; |
- |
- var mediaFile = findMediaFile("video", "content/test"); |
- runSilently("video.src = \"" + mediaFile + "\""); |
- |
- waitForEventOnce("canplay", canplay); |
- run("video.load()"); // Triggers canplay() |
- } |
- |
- function JumpAndPlayFwd() |
- { |
- consoleWrite("<br><b><em>Test jumping forward into a new range and play</em></b>"); |
- |
- var newTime = video.duration - 0.5; |
- runSilently("video.currentTime = " + (newTime.toFixed(2))); |
- |
- willPauseInExistingRange = false; |
- willExtendAnExistingRange = false; |
- currentTimeRange = 1; |
- |
- startPlayingInNewRange(); |
- } |
- |
- function ResetToAnEmptyVideoSource() |
- { |
- consoleWrite("<br><b><em>Test to reset to an empty video source</em></b>"); |
- |
- willPauseInExistingRange = false; |
- willExtendAnExistingRange = false; |
- timeRangeCount = currentTimeRange = 0; |
- |
- expectedStartTimes = new Array(); |
- expectedEndTimes = new Array(); |
- |
- run("video.src = \"\""); |
- waitForEvent("loadstart", function () { testRanges(); nextTest(); }); |
- run("video.load()"); // Triggers loadstart() |
- } |
- </script> |
- </head> |
- |
-<body onload="videoPlayedMain()"> |
- |
- <video controls></video> |
- <p>Test of the media element 'played' attribute</p> |
- |
-</body> |
-</html> |
+<!DOCTYPE html> |
+<title>Test media element's "played" attribute.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="media-file.js"></script> |
+<script src="video-played.js"></script> |
+<video></video> |
+<script> |
+var video; |
+async_test(function(t) { |
+ var expectedStartTimes = []; |
+ var expectedEndTimes = []; |
+ video = document.querySelector("video"); |
+ |
+ video.oncanplay = t.step_func(function() { |
+ video.oncanplay = null; |
+ testRanges(expectedStartTimes, expectedEndTimes); |
+ // Test playing when there are no ranges. |
+ timeRangeCount = currentTimeRange = 0; |
+ startPlayingInNewRange(t, expectedStartTimes); |
+ }); |
+ waitForPauseAndContinue(t, resetToAVideoSource, false, expectedStartTimes, expectedEndTimes); |
+ |
+ function resetToAVideoSource() { |
+ // Test to reset to non empty video source. |
+ timeRangeCount = currentTimeRange = 0; |
+ expectedStartTimes = []; |
+ expectedEndTimes = []; |
+ video.src = findMediaFile("video", "content/test"); |
+ video.oncanplay = t.step_func(jumpAndPlayFwd); |
+ } |
+ |
+ function jumpAndPlayFwd() { |
+ video.oncanplay = null; |
+ testRanges(expectedStartTimes, expectedEndTimes); |
+ // Test jumping forward into a new range and play. |
+ video.currentTime = (video.duration - 0.5).toFixed(2); |
+ currentTimeRange = 1; |
+ startPlayingInNewRange(t, expectedStartTimes); |
+ waitForPauseAndContinue(t, resetToAnEmptyVideoSource, false, expectedStartTimes, expectedEndTimes); |
+ } |
+ |
+ function resetToAnEmptyVideoSource() { |
+ // Test to reset to an empty video source. |
+ timeRangeCount = currentTimeRange = 0; |
+ expectedStartTimes = []; |
+ expectedEndTimes = []; |
+ video.src = ""; |
+ video.onloadstart = t.step_func_done(testRanges(expectedStartTimes, expectedEndTimes)); |
+ } |
+ |
+ video.src = findMediaFile("video", "content/test"); |
+}); |
+</script> |