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

Side by Side 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Test playbackRate and defaultPlaybackRate.</title>
3 <head> 3 <script src="../resources/testharness.js"></script>
4 <title>test playbackRate and defaultPlaybackRate</title> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src=media-file.js></script> 5 <script src="media-file.js"></script>
6 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 6 <video></video>
7 (Please avoid writing new tests using video-test.js) --> 7 <script>
8 <script src=video-test.js></script> 8 // "playbackRate" should not change when play() is called.
9 <script> 9 // "playbackRate" and "defaultPlaybackRate" should always return the last value set.
10 var rateChangeCount = 0; 10 async_test(function(t) {
11 var video = document.querySelector("video");
11 12
12 function ratechange() 13 video.oncanplaythrough = t.step_func(function() {
13 { 14 video.oncanplaythrough = null;
14 consoleWrite("*** checking rates after event"); 15 // checking defaults.
15 switch (++rateChangeCount) 16 assert_equals(video.playbackRate, 1);
16 { 17 assert_equals(video.defaultPlaybackRate, 1);
17 case 1:
18 testExpected("video.playbackRate", 1);
19 testExpected("video.defaultPlaybackRate", 2);
20 18
21 consoleWrite("<br>*** setting playbackRate"); 19 // setting defaultPlaybackRate.
22 run("video.playbackRate = 2"); 20 video.defaultPlaybackRate = 2;
23 testExpected("video.playbackRate", 2); 21 assert_equals(video.playbackRate, 1);
24 testExpected("video.defaultPlaybackRate", 2); 22 assert_equals(video.defaultPlaybackRate, 2);
25 consoleWrite(""); 23 });
26 break;
27 case 2:
28 testExpected("video.playbackRate", 2);
29 testExpected("video.defaultPlaybackRate", 2);
30 24
31 consoleWrite("<br>*** beginning playback"); 25 video.onended = t.step_func_done(function() {
32 video.currentTime = video.duration - 0.2; 26 assert_equals(video.playbackRate, 1);
33 run("video.playbackRate = 1"); 27 assert_equals(video.defaultPlaybackRate, 2);
34 testExpected("video.playbackRate", 1);
35 testExpected("video.defaultPlaybackRate", 2);
36 run("video.play()");
37 consoleWrite("");
38 break;
39 case 3:
40 testExpected("video.playbackRate", 1);
41 testExpected("video.defaultPlaybackRate", 2);
42 consoleWrite("");
43 break;
44 default:
45 break;
46 }
47 }
48 28
49 function canplaythrough() 29 // Test extreme playback rates.
50 { 30 video.defaultPlaybackRate = Number.MIN_VALUE;
51 consoleWrite("<br>*** checking defaults"); 31 assert_equals(video.defaultPlaybackRate, Number.MIN_VALUE);
52 testExpected("video.playbackRate", 1);
53 testExpected("video.defaultPlaybackRate", 1);
54 32
55 consoleWrite("<br>*** setting defaultPlaybackRate"); 33 video.defaultPlaybackRate = Number.MAX_VALUE;
56 run("video.defaultPlaybackRate = 2"); 34 assert_equals(video.defaultPlaybackRate, Number.MAX_VALUE);
57 testExpected("video.playbackRate", 1);
58 testExpected("video.defaultPlaybackRate", 2);
59 consoleWrite("");
60 }
61 35
62 function ended() 36 video.playbackRate = Number.MIN_VALUE;
63 { 37 assert_equals(video.playbackRate, Number.MIN_VALUE);
64 testExpected("video.playbackRate", 1);
65 testExpected("video.defaultPlaybackRate", 2);
66 consoleWrite("");
67 38
68 consoleWrite("Test extreme playback rates"); 39 video.playbackRate = Number.MAX_VALUE;
69 run("video.defaultPlaybackRate = Number.MIN_VALUE"); 40 assert_equals(video.playbackRate, Number.MAX_VALUE);
70 testExpected("video.defaultPlaybackRate", Number.MIN_VALUE);
71 consoleWrite("");
72 41
73 run("video.defaultPlaybackRate = Number.MAX_VALUE"); 42 // Test non-finite playback rates.
74 testExpected("video.defaultPlaybackRate", Number.MAX_VALUE); 43 assert_throws(new TypeError, function() { video.defaultPlaybackRate = -I nfinity; });
75 consoleWrite(""); 44 assert_throws(new TypeError, function() { video.defaultPlaybackRate = In finity; });
45 assert_throws(new TypeError, function() { video.defaultPlaybackRate = Na N; });
76 46
77 run("video.playbackRate = Number.MIN_VALUE"); 47 assert_throws(new TypeError, function() { video.playbackRate = -Infinity ; });
78 testExpected("video.playbackRate", Number.MIN_VALUE); 48 assert_throws(new TypeError, function() { video.playbackRate = Infinity; });
79 consoleWrite(""); 49 assert_throws(new TypeError, function() { video.playbackRate = NaN; });
50 });
80 51
81 run("video.playbackRate = Number.MAX_VALUE"); 52 var rateChangeCount = 0;
82 testExpected("video.playbackRate", Number.MAX_VALUE); 53 video.onratechange = t.step_func(function() {
83 consoleWrite(""); 54 // checking rate after event.
55 switch (++rateChangeCount) {
56 case 1:
57 assert_equals(video.playbackRate, 1);
58 assert_equals(video.defaultPlaybackRate, 2);
84 59
85 consoleWrite("Test non-finite playback rates"); 60 // setting playbackRate.
86 testException("video.defaultPlaybackRate = -Infinity", '"TypeErr or: Failed to set the \'defaultPlaybackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."'); 61 video.playbackRate = 2;
87 testException("video.defaultPlaybackRate = Infinity", '"TypeErro r: Failed to set the \'defaultPlaybackRate\' property on \'HTMLMediaElement\': T he provided double value is non-finite."'); 62 assert_equals(video.playbackRate, 2);
88 testException("video.defaultPlaybackRate = NaN", '"TypeError: Fa iled to set the \'defaultPlaybackRate\' property on \'HTMLMediaElement\': The pr ovided double value is non-finite."'); 63 assert_equals(video.defaultPlaybackRate, 2);
89 consoleWrite(""); 64 break;
65 case 2:
66 assert_equals(video.playbackRate, 2);
67 assert_equals(video.defaultPlaybackRate, 2);
90 68
91 testException("video.playbackRate = -Infinity", '"TypeError: Fai led to set the \'playbackRate\' property on \'HTMLMediaElement\': The provided d ouble value is non-finite."'); 69 // beginning playback.
92 testException("video.playbackRate = Infinity", '"TypeError: Fail ed to set the \'playbackRate\' property on \'HTMLMediaElement\': The provided do uble value is non-finite."'); 70 video.currentTime = video.duration - 0.2;
93 testException("video.playbackRate = NaN", '"TypeError: Failed to set the \'playbackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."'); 71 video.playbackRate = 1;
94 consoleWrite(""); 72 assert_equals(video.playbackRate, 1);
73 assert_equals(video.defaultPlaybackRate, 2);
74 video.play();
75 break;
76 case 3:
77 assert_equals(video.playbackRate, 1);
78 assert_equals(video.defaultPlaybackRate, 2);
79 break;
80 }
81 });
95 82
96 endTest(); 83 video.src = findMediaFile("video", "content/test");
97 } 84 });
98 85 </script>
99 function start()
100 {
101 findMediaElement();
102 waitForEventOnce('canplaythrough', canplaythrough);
103 waitForEvent('ended', ended);
104 waitForEvent('ratechange', ratechange);
105
106 consoleWrite("*** setting src");
107 setSrcByTagName("video", findMediaFile("video", "content/test")) ;
108 }
109
110 </script>
111 </head>
112
113 <body onload="start()">
114
115 <video controls > </video>
116 <ol>
117 <li>'playbackRate' should not change when play() is called.</li>
118 <li>'playbackRate' and 'defaultPlaybackRate' should always return th e last value set.</li>
119 </ol>
120 </body>
121 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698