OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <title>TextTrack.cues</title> | 2 <title>TextTrack.cues</title> |
3 <script src=../../../../../resources/testharness.js></script> | 3 <script src=../../../../../resources/testharness.js></script> |
4 <script src=../../../../../resources/testharnessreport.js></script> | 4 <script src=../../../../../resources/testharnessreport.js></script> |
5 <div id=log></div> | 5 <div id=log></div> |
6 <script> | 6 <script> |
7 setup(function(){ | 7 setup(function(){ |
8 window.video = document.createElement('video'); | 8 window.video = document.createElement('video'); |
9 window.t1 = video.addTextTrack('subtitles'); | 9 window.t1 = video.addTextTrack('subtitles'); |
10 window.track = document.createElement('track'); | 10 window.track = document.createElement('track'); |
11 track['default'] = true; | 11 track['default'] = true; |
12 video.appendChild(track); | 12 video.appendChild(track); // queues a task to "honor user preferences...", m
edia element event task source |
13 window.t2 = track.track; | 13 window.t2 = track.track; |
14 window.t1_cues = t1.cues | 14 window.t1_cues = t1.cues |
15 window.t2_cues = t2.cues | 15 window.t2_cues = t2.cues |
16 }); | 16 }); |
17 // Skipping this test due to https://www.w3.org/Bugs/Public/show_bug.cgi?id=2006
6, | |
18 // tracking uncommenting this when test is fixed with webkit.org/b/104255 | |
19 // test(function(){ | |
20 // assert_equals(t1.cues, t1_cues, 't1.cues should return same object'); | |
21 // assert_equals(t2.cues, t2_cues, 't2.cues should return same object'); | |
22 // assert_not_equals(t1.cues, t2.cues, 't1.cues and t2.cues should be differ
ent objects'); | |
23 // assert_not_equals(t1.cues, null, 't1.cues should not be null'); | |
24 // assert_not_equals(t2.cues, null, 't2.cues should not be null'); | |
25 // assert_equals(t1.cues.length, 0, 't1.cues should have length 0'); | |
26 // assert_equals(t2.cues.length, 0, 't2.cues should have length 0'); | |
27 // }, document.title+', empty list'); | |
28 test(function(){ | 17 test(function(){ |
29 var c = new TextTrackCue(0, 1, "text"); | 18 assert_equals(t1.cues, t1_cues, 't1.cues should return same object'); |
| 19 assert_not_equals(t1.cues, null, 't1.cues should not be null'); |
| 20 assert_equals(t1.cues.length, 0, 't1.cues should have length 0'); |
| 21 }, document.title+', empty list'); |
| 22 test(function(){ |
| 23 var c = new VTTCue(0, 1, "text"); |
30 c.id = "id"; | 24 c.id = "id"; |
31 t1.addCue(c); | 25 t1.addCue(c); |
32 assert_equals(t1.cues, t1_cues, "t1.cues should return same object"); | 26 assert_equals(t1.cues, t1_cues, "t1.cues should return same object"); |
33 assert_equals(t1.cues.length, 1, "t1.cues.length"); | 27 assert_equals(t1.cues.length, 1, "t1.cues.length"); |
34 var c2 = new TextTrackCue(1, 2, "text2"); | 28 var c2 = new VTTCue(1, 2, "text2"); |
35 c2.id = "id2"; | 29 c2.id = "id2"; |
36 t1.addCue(c2); | 30 t1.addCue(c2); |
37 assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after
adding a second cue"); | 31 assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after
adding a second cue"); |
38 assert_equals(t1.cues.length, 2, "t1.cues.length after adding a second cue")
; | 32 assert_equals(t1.cues.length, 2, "t1.cues.length after adding a second cue")
; |
39 assert_equals(t1.cues[0].id, "id"); | 33 assert_equals(t1.cues[0].id, "id"); |
40 assert_equals(t1.cues[1].id, "id2"); | 34 assert_equals(t1.cues[1].id, "id2"); |
41 }, document.title+', after addCue()'); | 35 }, document.title+', after addCue()'); |
42 test(function(){ | 36 test(function(){ |
43 t1.mode = 'showing'; | 37 t1.mode = 'showing'; |
44 assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after
setting mode to 'showing'"); | 38 assert_equals(t1.cues, t1_cues, "t1.cues should return the same object after
setting mode to 'showing'"); |
(...skipping 16 matching lines...) Expand all Loading... |
61 }, document.title+', different modes'); | 55 }, document.title+', different modes'); |
62 test(function(){ | 56 test(function(){ |
63 t1.mode = 'showing'; | 57 t1.mode = 'showing'; |
64 t1.cues[1].startTime = 0; // this should change the text track cue order | 58 t1.cues[1].startTime = 0; // this should change the text track cue order |
65 assert_equals(t1.cues[0].id, 'id2'); | 59 assert_equals(t1.cues[0].id, 'id2'); |
66 assert_equals(t1.cues[1].id, 'id'); | 60 assert_equals(t1.cues[1].id, 'id'); |
67 t1.cues[0].startTime = 0.5; // this should change it back | 61 t1.cues[0].startTime = 0.5; // this should change it back |
68 assert_equals(t1.cues[0].id, 'id'); | 62 assert_equals(t1.cues[0].id, 'id'); |
69 assert_equals(t1.cues[1].id, 'id2'); | 63 assert_equals(t1.cues[1].id, 'id2'); |
70 }, document.title+', changing order'); | 64 }, document.title+', changing order'); |
| 65 // FIXME: disabled because it requires a newer testharness.js |
| 66 //async_test(function(){ |
| 67 // t1.mode = 'showing'; |
| 68 // assert_equals(t2.cues, null, 't2.cues should be null'); |
| 69 // video.onplay = this.step_func(function(){ |
| 70 // assert_equals(t2.cues, t2_cues, 't2.cues should return same object'); |
| 71 // assert_not_equals(t1.cues, t2.cues, 't1.cues and t2.cues should be dif
ferent objects'); |
| 72 // assert_not_equals(t2.cues, null, 't2.cues should not be null'); |
| 73 // assert_equals(t2.cues.length, 0, 't2.cues should have length 0'); |
| 74 // this.done(); |
| 75 // }); |
| 76 // video.play(); // queues a task to fire 'play', media element event task so
urce |
| 77 //}, document.title+', default attribute'); |
71 </script> | 78 </script> |
OLD | NEW |