Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: third_party/WebKit/LayoutTests/media/video-play-require-user-gesture.html

Issue 2090593002: Convert video-play* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/video-play-require-user-gesture.html
diff --git a/third_party/WebKit/LayoutTests/media/video-play-require-user-gesture.html b/third_party/WebKit/LayoutTests/media/video-play-require-user-gesture.html
index 8d6109d4956cc30c1035fb1851cd666d40a80fe0..31cc2317d8f9b8ad5f5894af8dd684da45a140e2 100644
--- a/third_party/WebKit/LayoutTests/media/video-play-require-user-gesture.html
+++ b/third_party/WebKit/LayoutTests/media/video-play-require-user-gesture.html
@@ -1,76 +1,40 @@
-<html>
- <head>
- <title>Test that video play does not work unless a user gesture is involved in playing a video</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 userGestureInitiated = 0;
- if (window.internals)
- window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
-
- function click()
- {
- if (window.eventSender) {
- var playCoords;
- try {
- playCoords = mediaControlsButtonCoordinates(video, "play-button");
- } catch (exception) {
- failTest(exception.description);
- return;
- }
- var x = playCoords[0];
- var y = playCoords[1];
-
- userGestureInitiated = 1;
- eventSender.mouseMoveTo(x, y);
- eventSender.mouseDown();
- eventSender.mouseUp();
- }
- }
-
- function playing()
- {
- if (userGestureInitiated == 0) {
- failTest("Should not play without user gesture.");
- } else {
- run("video.pause()");
- }
- }
-
- function pause()
- {
- testExpected("video.paused", true);
- endTest();
- }
-
- function canplaythrough()
- {
- consoleWrite("");
- consoleWrite("* No user gesture initiated");
- run("video.play()");
- testExpected("video.paused", true);
- consoleWrite("");
-
- consoleWrite("* User gesture initiated");
- click();
- }
-
- function start()
- {
- findMediaElement();
- waitForEvent('canplaythrough', canplaythrough);
- waitForEvent('playing', playing);
- waitForEvent('pause', pause);
- video.src = findMediaFile("video", "content/test");
- }
- </script>
- </head>
-
- <body onload="start()">
- <p>Test that video play() does not work unless a user clicked on the play button.</p>
- <video controls></video>
- </body>
-</html>
+<!DOCTYPE html>
+<title>Test that video play does not work unless a user gesture is involved in playing a video.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="media-controls.js"></script>
+<script src="media-file.js"></script>
+<script>
+internals.settings.setMediaPlaybackRequiresUserGesture(true);
+</script>
+<video controls></video>
+<script>
+async_test(function(t) {
+ var userGestureInitiated = false;
+ var video = document.querySelector("video");
+
+ video.oncanplaythrough = t.step_func(function() {
+ // No user gesture initiated.
+ video.play();
+ assert_true(video.paused);
+
+ // User gesture initiated.
+ userGestureInitiated = true;
+ var playCoords = mediaControlsButtonCoordinates(video, "play-button");
+ eventSender.mouseMoveTo(playCoords[0], playCoords[1]);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ });
+
+ video.onplaying = t.step_func(function() {
+ assert_true(userGestureInitiated);
+ video.pause();
+ });
+
+ video.onpause = t.step_func_done(function() {
+ assert_true(video.paused);
+ });
+
+ video.src = findMediaFile("video", "content/test");
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698