OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests that the addTextTrack() only accepts known "kind" values.</title> |
3 <head> | 3 <script src="../../resources/testharness.js"></script> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script> |
| 6 test(function() { |
| 7 var trackCount = 0; |
5 | 8 |
6 <script src=../media-file.js></script> | 9 function addTrack(type) { |
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 10 video.addTextTrack(type); |
8 (Please avoid writing new tests using video-test.js) --> | 11 assert_equals(video.textTracks.length, ++trackCount); |
9 <script src=../video-test.js></script> | 12 } |
10 <script> | 13 |
| 14 var video = document.createElement("video"); |
| 15 assert_equals(video.textTracks.length, 0); |
| 16 assert_throws(new TypeError(), function() { video.addTextTrack("kaptions");
}); |
| 17 assert_equals(video.textTracks.length, 0); |
11 | 18 |
12 var trackCount = 0; | 19 addTrack("subtitles"); |
13 | 20 addTrack("captions"); |
14 function addTrack(type) | 21 addTrack("descriptions"); |
15 { | 22 addTrack("chapters"); |
16 run("video.addTextTrack('" + type + "')"); | 23 addTrack("metadata"); |
17 testExpected("video.textTracks.length", ++trackCount); | 24 }); |
18 } | 25 </script> |
19 | |
20 function start() | |
21 { | |
22 findMediaElement(); | |
23 | |
24 consoleWrite("<em>++ Test invalid 'kind'.</em>"); | |
25 testExpected("video.textTracks.length", 0); | |
26 testException("video.addTextTrack('kaptions')", '"TypeError: Fai
led to execute \'addTextTrack\' on \'HTMLMediaElement\': parameter 1 (\'kaptions
\') is not a valid enum value."'); | |
27 testExpected("video.textTracks.length", 0); | |
28 consoleWrite(""); | |
29 | |
30 consoleWrite("<em>++ Test all valid 'kind' keywords.</em>"); | |
31 addTrack("subtitles"); | |
32 addTrack("captions"); | |
33 addTrack("descriptions"); | |
34 addTrack("chapters"); | |
35 addTrack("metadata"); | |
36 | |
37 consoleWrite(""); | |
38 endTest(); | |
39 } | |
40 | |
41 </script> | |
42 </head> | |
43 <body onload="start()"> | |
44 <p>Tests that the addTextTrack() only accepts known 'kind' values.</p> | |
45 <video> | |
46 </video> | |
47 </body> | |
48 </html> | |
OLD | NEW |