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

Unified Diff: third_party/WebKit/LayoutTests/media/video-playbackrate.html

Issue 2121383005: Convert video-playback* and sources-fallback* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and address comments Created 4 years, 5 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-playbackrate.html
diff --git a/third_party/WebKit/LayoutTests/media/video-playbackrate.html b/third_party/WebKit/LayoutTests/media/video-playbackrate.html
index abe071ac011082ee482c582eebe231e7db9f5ed7..47cff0305c356ef8890ffe777c541b79566db8cf 100644
--- a/third_party/WebKit/LayoutTests/media/video-playbackrate.html
+++ b/third_party/WebKit/LayoutTests/media/video-playbackrate.html
@@ -1,121 +1,85 @@
<!DOCTYPE html>
-<html>
- <head>
- <title>test playbackRate and defaultPlaybackRate</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>
- var rateChangeCount = 0;
-
- function ratechange()
- {
- consoleWrite("*** checking rates after event");
- switch (++rateChangeCount)
- {
- case 1:
- testExpected("video.playbackRate", 1);
- testExpected("video.defaultPlaybackRate", 2);
-
- consoleWrite("<br>*** setting playbackRate");
- run("video.playbackRate = 2");
- testExpected("video.playbackRate", 2);
- testExpected("video.defaultPlaybackRate", 2);
- consoleWrite("");
- break;
- case 2:
- testExpected("video.playbackRate", 2);
- testExpected("video.defaultPlaybackRate", 2);
-
- consoleWrite("<br>*** beginning playback");
- video.currentTime = video.duration - 0.2;
- run("video.playbackRate = 1");
- testExpected("video.playbackRate", 1);
- testExpected("video.defaultPlaybackRate", 2);
- run("video.play()");
- consoleWrite("");
- break;
- case 3:
- testExpected("video.playbackRate", 1);
- testExpected("video.defaultPlaybackRate", 2);
- consoleWrite("");
- break;
- default:
- break;
- }
- }
-
- function canplaythrough()
- {
- consoleWrite("<br>*** checking defaults");
- testExpected("video.playbackRate", 1);
- testExpected("video.defaultPlaybackRate", 1);
-
- consoleWrite("<br>*** setting defaultPlaybackRate");
- run("video.defaultPlaybackRate = 2");
- testExpected("video.playbackRate", 1);
- testExpected("video.defaultPlaybackRate", 2);
- consoleWrite("");
- }
-
- function ended()
- {
- testExpected("video.playbackRate", 1);
- testExpected("video.defaultPlaybackRate", 2);
- consoleWrite("");
-
- consoleWrite("Test extreme playback rates");
- run("video.defaultPlaybackRate = Number.MIN_VALUE");
- testExpected("video.defaultPlaybackRate", Number.MIN_VALUE);
- consoleWrite("");
-
- run("video.defaultPlaybackRate = Number.MAX_VALUE");
- testExpected("video.defaultPlaybackRate", Number.MAX_VALUE);
- consoleWrite("");
-
- run("video.playbackRate = Number.MIN_VALUE");
- testExpected("video.playbackRate", Number.MIN_VALUE);
- consoleWrite("");
-
- run("video.playbackRate = Number.MAX_VALUE");
- testExpected("video.playbackRate", Number.MAX_VALUE);
- consoleWrite("");
-
- consoleWrite("Test non-finite playback rates");
- testException("video.defaultPlaybackRate = -Infinity", '"TypeError: Failed to set the \'defaultPlaybackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
- testException("video.defaultPlaybackRate = Infinity", '"TypeError: Failed to set the \'defaultPlaybackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
- testException("video.defaultPlaybackRate = NaN", '"TypeError: Failed to set the \'defaultPlaybackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
- consoleWrite("");
-
- testException("video.playbackRate = -Infinity", '"TypeError: Failed to set the \'playbackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
- testException("video.playbackRate = Infinity", '"TypeError: Failed to set the \'playbackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
- testException("video.playbackRate = NaN", '"TypeError: Failed to set the \'playbackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
- consoleWrite("");
-
- endTest();
- }
-
- function start()
- {
- findMediaElement();
- waitForEventOnce('canplaythrough', canplaythrough);
- waitForEvent('ended', ended);
- waitForEvent('ratechange', ratechange);
-
- consoleWrite("*** setting src");
- setSrcByTagName("video", findMediaFile("video", "content/test"));
- }
-
- </script>
- </head>
-
- <body onload="start()">
-
- <video controls > </video>
- <ol>
- <li>'playbackRate' should not change when play() is called.</li>
- <li>'playbackRate' and 'defaultPlaybackRate' should always return the last value set.</li>
- </ol>
- </body>
-</html>
+<title>Test playbackRate and defaultPlaybackRate.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="media-file.js"></script>
+<video></video>
+<script>
+// "playbackRate" should not change when play() is called.
+// "playbackRate" and "defaultPlaybackRate" should always return the last value set.
+async_test(function(t) {
+ var video = document.querySelector("video");
+
+ video.oncanplaythrough = t.step_func(function() {
+ video.oncanplaythrough = null;
+ // checking defaults.
+ assert_equals(video.playbackRate, 1);
+ assert_equals(video.defaultPlaybackRate, 1);
+
+ // setting defaultPlaybackRate.
+ video.defaultPlaybackRate = 2;
+ assert_equals(video.playbackRate, 1);
+ assert_equals(video.defaultPlaybackRate, 2);
+ });
+
+ video.onended = t.step_func_done(function() {
+ assert_equals(video.playbackRate, 1);
+ assert_equals(video.defaultPlaybackRate, 2);
+
+ // Test extreme playback rates.
+ video.defaultPlaybackRate = Number.MIN_VALUE;
+ assert_equals(video.defaultPlaybackRate, Number.MIN_VALUE);
+
+ video.defaultPlaybackRate = Number.MAX_VALUE;
+ assert_equals(video.defaultPlaybackRate, Number.MAX_VALUE);
+
+ video.playbackRate = Number.MIN_VALUE;
+ assert_equals(video.playbackRate, Number.MIN_VALUE);
+
+ video.playbackRate = Number.MAX_VALUE;
+ assert_equals(video.playbackRate, Number.MAX_VALUE);
+
+ // Test non-finite playback rates.
+ assert_throws(new TypeError, function() { video.defaultPlaybackRate = -Infinity; });
+ assert_throws(new TypeError, function() { video.defaultPlaybackRate = Infinity; });
+ assert_throws(new TypeError, function() { video.defaultPlaybackRate = NaN; });
+
+ assert_throws(new TypeError, function() { video.playbackRate = -Infinity; });
+ assert_throws(new TypeError, function() { video.playbackRate = Infinity; });
+ assert_throws(new TypeError, function() { video.playbackRate = NaN; });
+ });
+
+ var rateChangeCount = 0;
+ video.onratechange = t.step_func(function() {
+ // checking rate after event.
+ switch (++rateChangeCount) {
+ case 1:
+ assert_equals(video.playbackRate, 1);
+ assert_equals(video.defaultPlaybackRate, 2);
+
+ // setting playbackRate.
+ video.playbackRate = 2;
+ assert_equals(video.playbackRate, 2);
+ assert_equals(video.defaultPlaybackRate, 2);
+ break;
+ case 2:
+ assert_equals(video.playbackRate, 2);
+ assert_equals(video.defaultPlaybackRate, 2);
+
+ // beginning playback.
+ video.currentTime = video.duration - 0.2;
+ video.playbackRate = 1;
+ assert_equals(video.playbackRate, 1);
+ assert_equals(video.defaultPlaybackRate, 2);
+ video.play();
+ break;
+ case 3:
+ assert_equals(video.playbackRate, 1);
+ assert_equals(video.defaultPlaybackRate, 2);
+ break;
+ }
+ });
+
+ video.src = findMediaFile("video", "content/test");
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698