OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests that TextTracks in a TextTrackList are kept in the correct order.</
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 <video> |
| 6 <track kind="captions" src="captions-webvtt/tc004-webvtt-file.vtt" > |
| 7 </video> |
| 8 <script> |
| 9 test(function() { |
| 10 var video = document.querySelector("video"); |
5 | 11 |
6 <script src=../media-file.js></script> | 12 // Add a track with video.addTextTrack(). |
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 13 video.addTextTrack("descriptions", "Descriptions Track", "en"); |
8 (Please avoid writing new tests using video-test.js) --> | |
9 <script src=../video-test.js></script> | |
10 <script> | |
11 | 14 |
12 var trackElement; | 15 // Add a track element with DOM API. |
| 16 var trackElement = document.createElement("track"); |
| 17 trackElement.setAttribute("kind", "chapters"); |
| 18 video.appendChild(trackElement); |
13 | 19 |
14 function start() | 20 // Verify track order. |
15 { | 21 assert_equals(video.textTracks.length, 3); |
16 findMediaElement(); | 22 assert_equals(video.textTracks[0].kind, "captions"); |
| 23 assert_equals(video.textTracks[1].kind, "chapters"); |
| 24 assert_equals(video.textTracks[2].kind, "descriptions"); |
17 | 25 |
18 consoleWrite("** Add a track with video.addTextTrack()."); | 26 // Verify the default parameters of the text track object returned by addTex
tTrack(). |
19 run("video.addTextTrack('descriptions', 'Descriptions Track', 'e
n')"); | 27 assert_equals(video.textTracks[2].mode, "hidden"); |
| 28 assert_not_equals(video.textTracks[2].cues, null); |
| 29 assert_equals(video.textTracks[2].cues.length, 0); |
20 | 30 |
21 consoleWrite("<br>** Add a <track> element with DOM API.")
; | 31 // Add another track element, it should insert before the addTextTrack() tra
ck. |
22 run("trackElement = document.createElement('track')"); | 32 trackElement = document.createElement("track"); |
23 run("trackElement.setAttribute('kind', 'chapters')"); | 33 trackElement.setAttribute("kind", "metadata"); |
24 run("video.appendChild(trackElement)"); | 34 video.appendChild(trackElement); |
25 | 35 |
26 consoleWrite("<br>** Verify track order."); | 36 assert_equals(video.textTracks.length, 4); |
27 testExpected("video.textTracks.length", 3); | 37 assert_equals(video.textTracks[0].kind, "captions"); |
28 testExpected("video.textTracks[0].kind", "captions"); | 38 assert_equals(video.textTracks[1].kind, "chapters"); |
29 testExpected("video.textTracks[1].kind", "chapters"); | 39 assert_equals(video.textTracks[2].kind, "metadata"); |
30 testExpected("video.textTracks[2].kind", "descriptions"); | 40 assert_equals(video.textTracks[3].kind, "descriptions"); |
31 | 41 }); |
32 consoleWrite("<br>** Verify the default parameters of the text t
rack object returned by addTextTrack(). **"); | 42 </script> |
33 testExpected("video.textTracks[2].mode == 'hidden'", true); | |
34 testExpected("video.textTracks[2].cues != null", true); | |
35 testExpected("video.textTracks[2].cues.length == 0", true); | |
36 | |
37 consoleWrite("<br>** Add another <track> element, is shoul
d insert before the addTextTrack() track."); | |
38 run("trackElement = document.createElement('track')"); | |
39 run("trackElement.setAttribute('kind', 'metadata')"); | |
40 run("video.appendChild(trackElement)"); | |
41 | |
42 testExpected("video.textTracks.length", 4); | |
43 testExpected("video.textTracks[0].kind", "captions"); | |
44 testExpected("video.textTracks[1].kind", "chapters"); | |
45 testExpected("video.textTracks[2].kind", "metadata"); | |
46 testExpected("video.textTracks[3].kind", "descriptions"); | |
47 | |
48 consoleWrite(""); | |
49 endTest(); | |
50 } | |
51 | |
52 </script> | |
53 </head> | |
54 <body onload="start()"> | |
55 <p>Tests that TextTracks in a TextTrackList are kept in the correct orde
r.</p> | |
56 <video> | |
57 <track id="track_1" kind="captions" src="captions-webvtt/tc004-webvt
t-file.vtt" > | |
58 </video> | |
59 </body> | |
60 </html> | |
OLD | NEW |