Index: third_party/WebKit/LayoutTests/media/controls-drag-timebar.html |
diff --git a/third_party/WebKit/LayoutTests/media/controls-drag-timebar.html b/third_party/WebKit/LayoutTests/media/controls-drag-timebar.html |
index 2b58e979ba9a84c7b416d0c7bf411254a6a1e2c6..eca1ad11ba3cb02b7f208648790f086b6349a57f 100644 |
--- a/third_party/WebKit/LayoutTests/media/controls-drag-timebar.html |
+++ b/third_party/WebKit/LayoutTests/media/controls-drag-timebar.html |
@@ -1,96 +1,63 @@ |
<!DOCTYPE html> |
-<html> |
- <head> |
- <title>drag timebar test</title> |
- <script src=media-controls.js></script> |
- <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> |
- var x; |
- var y; |
- var seekCount; |
- var moveCount; |
- |
- if (window.testRunner) |
- testRunner.dumpAsText(); |
- |
- function test() |
- { |
- seekCount = 0; |
- moveCount = 0; |
- |
- testExpected("video.paused", false); |
- |
- if (window.eventSender) { |
- var seekCoords; |
- try { |
- seekCoords = mediaControlsButtonCoordinates(video, "timeline"); |
- } catch (exception) { |
- failTest(exception.description); |
- return; |
- } |
- x = seekCoords[0]; |
- y = seekCoords[1]; |
- |
- eventSender.dragMode = false; |
- eventSender.mouseMoveTo(x, y); |
- eventSender.mouseDown(); |
- |
- testExpected("video.paused", true); |
- |
- // Drag mouse off of the slider thumb to make sure it continues to track |
- y += 100; |
- eventSender.mouseMoveTo(x, y); |
- } |
- window.setTimeout("move()", 100); |
- } |
- |
- function move() |
- { |
- ++moveCount; |
- |
- var delta = (10 + moveCount * 2) * (moveCount % 2 ? 1 : -1); |
- |
- if (window.eventSender) { |
- x += delta; |
- eventSender.mouseMoveTo(x, y); |
- } |
- } |
- |
- function seeked() |
- { |
- |
- ++seekCount; |
- if (seekCount < 6) { |
- window.setTimeout("move()", 100); |
- return; |
- } |
- |
- if (window.eventSender) { |
- testExpected("video.paused", true); |
- eventSender.mouseUp(); |
- } |
- |
- testExpected("video.paused", false); |
- |
- endTest(); |
- } |
- |
- function start() |
- { |
- findMediaElement(); |
- waitForEventOnce('playing', test); |
- waitForEvent('seeked', seeked); |
- video.src = findMediaFile("video", "content/test"); |
- video.play(); |
- } |
- </script> |
- </head> |
- |
- <body onload="start()"> |
- <p>Test that dragging the timebar thumb causes seeks.</p> |
- <video controls></video> |
- </body> |
-</html> |
+<title>Test that dragging the timebar thumb causes seeks.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="media-file.js"></script> |
+<script src="media-controls.js"></script> |
+<video controls></video> |
+<script> |
+async_test(function(t) { |
+ var currentMousePosition = { |
foolip
2016/05/30 13:33:27
Any reason to group these into an object? fooPosit
|
+ seekPosition: [], |
foolip
2016/05/30 13:33:27
Suggest null as the initial value. This empty arra
|
+ seekCount: 0, |
+ moveCount: 0 |
+ }; |
+ |
+ var video = document.querySelector("video"); |
+ video.onplaying = t.step_func(test); |
+ video.onseeked = t.step_func(seeked); |
+ video.src = findMediaFile("video", "content/test"); |
+ video.play(); |
+ |
+ function test() { |
foolip
2016/05/30 13:33:28
Suggest renaming this to playing, calling it test
Srirama
2016/05/30 13:59:22
Done.
|
+ video.onplaying = null; |
+ assert_equals(video.paused, false); |
+ |
+ currentMousePosition.seekPosition = mediaControlsButtonCoordinates(video, "timeline"); |
+ |
+ eventSender.dragMode = false; |
+ eventSender.mouseMoveTo(currentMousePosition.seekPosition[0], currentMousePosition.seekPosition[1]); |
+ eventSender.mouseDown(); |
+ |
+ assert_equals(video.paused, true); |
+ |
+ // Drag mouse off of the slider thumb to make sure it continues to track |
+ currentMousePosition.seekPosition[1] += 100; |
+ eventSender.mouseMoveTo(currentMousePosition.seekPosition[0], currentMousePosition.seekPosition[1]); |
+ |
+ setTimeout(t.step_func(move), 100); |
+ } |
+ |
+ function move() { |
+ ++(currentMousePosition.moveCount); |
foolip
2016/05/30 13:33:27
Looks funny, can you use currentMousePosition.move
|
+ |
+ currentMousePosition.seekPosition[0] += (10 + currentMousePosition.moveCount * 2) |
+ * (currentMousePosition.moveCount % 2 ? 1 : -1); |
+ eventSender.mouseMoveTo(currentMousePosition.seekPosition[0], currentMousePosition.seekPosition[1]); |
+ } |
+ |
+ function seeked() { |
+ ++(currentMousePosition.seekCount); |
+ if (currentMousePosition.seekCount < 6) { |
+ setTimeout(t.step_func(move), 100); |
+ return; |
+ } |
+ |
+ assert_equals(video.paused, true); |
+ eventSender.mouseUp(); |
+ |
+ assert_equals(video.paused, false); |
+ t.done(); |
+ } |
+}); |
+</script> |