Index: third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-duration.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-duration.html b/third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-duration.html |
index 75baddb47958a4c8ac126466bcce5cc3bd67b54c..ba61b9c7ab4d4114bf9b9af95c9ac3980d643b4d 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-duration.html |
+++ b/third_party/WebKit/LayoutTests/http/tests/media/video-seek-to-duration.html |
@@ -1,77 +1,54 @@ |
-<html> |
- <head> |
- <script src=../../media-resources/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=../../media-resources/video-test.js></script> |
- <script> |
- function start() |
- { |
- findMediaElement(); |
- |
- waitForEvent('durationchange'); |
- waitForEvent('loadedmetadata'); |
- waitForEventOnce('loadeddata', function () |
- { |
- waitForEvent('seeking', function () |
- { |
- testExpected('video.seeking', true, '=='); |
- testExpected('video.ended', true, '=='); |
- testExpected('video.currentTime == video.duration', true, '=='); |
- testExpected('video.paused', false, '=='); |
- |
- waitForEventOnce('timeupdate', function() |
- { |
- testExpected('video.seeking', false, '=='); |
- testExpected('video.ended', true, '=='); |
- testExpected('video.currentTime == video.duration', true, '=='); |
- }); |
- }); |
- |
- waitForEvent('seeked', function () |
- { |
- testExpected('video.seeking', false, '=='); |
- testExpected('video.ended', true, '=='); |
- testExpected('video.currentTime == video.duration', true, '=='); |
- |
- }); |
- |
- waitForEvent('pause', function() |
- { |
- testExpected('video.paused', true, '=='); |
- testExpected('video.seeking', false, '=='); |
- testExpected('video.ended', true, '=='); |
- testExpected('video.currentTime == video.duration', true, '=='); |
- }); |
- |
- waitForEvent('ended', function () |
- { |
- testExpected('video.seeking', false, '=='); |
- testExpected('video.ended', true, '=='); |
- testExpected('video.paused', true, '=='); |
- testExpected('video.currentTime == video.duration', true, '=='); |
- endTest(); |
- }); |
- |
- // Seek to the duration of the media |
- testExpected('video.currentTime < video.duration', true, '=='); |
- testExpected('video.ended', false, '=='); |
- testExpected('video.paused', false, '=='); |
- consoleWrite('Starting seek to duration by setting video.currentTime to video.duration'); |
- video.currentTime = video.duration; |
- testExpected('video.currentTime == video.duration', true, '=='); |
- testExpected('video.seeking', true, '=='); |
- testExpected('video.ended', true, '=='); |
- }); |
- |
- var mediaFile = findMediaFile('video', 'resources/test'); |
- video.src = '/' + mediaFile; |
- run('video.play()'); |
- } |
- </script> |
- </head> |
- <body onload="start()"> |
- <video></video> |
- <p>Test event dispatches and attribute changes for seek to duration</p> |
- </body> |
-</html> |
+<!DOCTYPE html> |
+<title>Test event dispatches and attribute changes for seek to duration.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="../../media-resources/media-file.js"></script> |
+<video></video> |
+<script> |
+async_test(function(t) { |
+ var video = document.querySelector("video"); |
+ |
+ var watcher = new EventWatcher(t, video, ["durationchange", "loadedmetadata", |
+ "loadeddata", "seeking", "timeupdate", "seeked", "pause", "ended"]); |
+ |
+ watcher.wait_for(["durationchange", "loadedmetadata", "loadeddata"]).then(t.step_func(function() { |
+ // Seek to the duration of the media. |
+ assert_less_than(video.currentTime, video.duration); |
+ assert_false(video.ended) |
+ assert_false(video.paused); |
+ //Starting seek to duration by setting video.currentTime to video.duration. |
+ video.currentTime = video.duration; |
+ testCommonAttributes(true); |
+ return watcher.wait_for("seeking"); |
+ })).then(t.step_func(function() { |
+ testCommonAttributes(true); |
+ assert_false(video.paused); |
+ return watcher.wait_for("timeupdate"); |
+ })).then(t.step_func(function() { |
+ testCommonAttributes(false); |
+ return watcher.wait_for("seeked"); |
+ })).then(t.step_func(function() { |
+ testCommonAttributes(false); |
+ return watcher.wait_for("timeupdate"); |
Srirama
2016/07/25 11:05:06
Added this extra "timeupdate" event so that we wil
fs
2016/07/25 15:17:59
Acknowledged.
|
+ })).then(t.step_func(function() { |
+ testCommonAttributes(false); |
+ return watcher.wait_for("pause"); |
+ })).then(t.step_func(function() { |
+ assert_true(video.paused); |
+ testCommonAttributes(false); |
+ return watcher.wait_for("ended"); |
+ })).then(t.step_func_done(function() { |
+ testCommonAttributes(false); |
+ assert_true(video.paused); |
+ })); |
+ |
+ function testCommonAttributes(seekingExpected) { |
+ assert_equals(video.seeking, seekingExpected); |
+ assert_true(video.ended); |
+ assert_equals(video.currentTime, video.duration); |
+ } |
+ |
+ video.src = findMediaFile("video", "resources/test");; |
+ video.play(); |
+}); |
+</script> |