Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-playbackrate.html
blob3782060384bb2f7810791d3027ec5ef2dce8e825
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>test playbackRate and defaultPlaybackRate</title>
5 <script src=media-file.js></script>
6 <script src=video-test.js></script>
7 <script>
8 var rateChangeCount = 0;
10 function ratechange()
12 consoleWrite("*** checking rates after event");
13 switch (++rateChangeCount)
15 case 1:
16 testExpected("video.playbackRate", 1);
17 testExpected("video.defaultPlaybackRate", 2);
19 consoleWrite("<br>*** setting playbackRate");
20 run("video.playbackRate = 2");
21 testExpected("video.playbackRate", 2);
22 testExpected("video.defaultPlaybackRate", 2);
23 consoleWrite("");
24 break;
25 case 2:
26 testExpected("video.playbackRate", 2);
27 testExpected("video.defaultPlaybackRate", 2);
29 consoleWrite("<br>*** beginning playback");
30 video.currentTime = video.duration - 0.2;
31 run("video.playbackRate = 1");
32 testExpected("video.playbackRate", 1);
33 testExpected("video.defaultPlaybackRate", 2);
34 run("video.play()");
35 consoleWrite("");
36 break;
37 case 3:
38 testExpected("video.playbackRate", 1);
39 testExpected("video.defaultPlaybackRate", 2);
40 consoleWrite("");
41 break;
42 default:
43 break;
47 function canplaythrough()
49 consoleWrite("<br>*** checking defaults");
50 testExpected("video.playbackRate", 1);
51 testExpected("video.defaultPlaybackRate", 1);
53 consoleWrite("<br>*** setting defaultPlaybackRate");
54 run("video.defaultPlaybackRate = 2");
55 testExpected("video.playbackRate", 1);
56 testExpected("video.defaultPlaybackRate", 2);
57 consoleWrite("");
60 function ended()
62 testExpected("video.playbackRate", 1);
63 testExpected("video.defaultPlaybackRate", 2);
64 consoleWrite("");
66 consoleWrite("Test extreme playback rates");
67 run("video.defaultPlaybackRate = Number.MIN_VALUE");
68 testExpected("video.defaultPlaybackRate", Number.MIN_VALUE);
69 consoleWrite("");
71 run("video.defaultPlaybackRate = Number.MAX_VALUE");
72 testExpected("video.defaultPlaybackRate", Number.MAX_VALUE);
73 consoleWrite("");
75 run("video.playbackRate = Number.MIN_VALUE");
76 testExpected("video.playbackRate", Number.MIN_VALUE);
77 consoleWrite("");
79 run("video.playbackRate = Number.MAX_VALUE");
80 testExpected("video.playbackRate", Number.MAX_VALUE);
81 consoleWrite("");
83 consoleWrite("Test non-finite playback rates");
84 testException("video.defaultPlaybackRate = -Infinity", '"TypeError: Failed to set the \'defaultPlaybackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
85 testException("video.defaultPlaybackRate = Infinity", '"TypeError: Failed to set the \'defaultPlaybackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
86 testException("video.defaultPlaybackRate = NaN", '"TypeError: Failed to set the \'defaultPlaybackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
87 consoleWrite("");
89 testException("video.playbackRate = -Infinity", '"TypeError: Failed to set the \'playbackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
90 testException("video.playbackRate = Infinity", '"TypeError: Failed to set the \'playbackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
91 testException("video.playbackRate = NaN", '"TypeError: Failed to set the \'playbackRate\' property on \'HTMLMediaElement\': The provided double value is non-finite."');
92 consoleWrite("");
94 endTest();
97 function start()
99 findMediaElement();
100 waitForEventOnce('canplaythrough', canplaythrough);
101 waitForEvent('ended', ended);
102 waitForEvent('ratechange', ratechange);
104 consoleWrite("*** setting src");
105 setSrcByTagName("video", findMediaFile("video", "content/test"));
108 </script>
109 </head>
111 <body onload="start()">
113 <video controls > </video>
114 <ol>
115 <li>'playbackRate' should not change when play() is called.</li>
116 <li>'playbackRate' and 'defaultPlaybackRate' should always return the last value set.</li>
117 </ol>
118 </body>
119 </html>