Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <title>VTTCue.align</title> | 2 <title>VTTCue.position</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 test(function(){ | 7 test(function() { |
| 8 var video = document.createElement('video'); | 8 var video = document.createElement('video'); |
| 9 document.body.appendChild(video); | 9 document.body.appendChild(video); |
| 10 var c1 = new VTTCue(0, 1, 'text1'); | 10 var cue = new VTTCue(0, 1, 'text1'); |
| 11 assert_equals(c1.align, 'middle'); | 11 assert_equals(cue.position, 'auto'); |
| 12 var track = document.createElement('track'); | 12 var track = document.createElement('track'); |
| 13 var t = track.track; | 13 var t = track.track; |
| 14 t.addCue(c1); | 14 t.addCue(cue); |
| 15 assert_equals(c1.align, 'middle'); | 15 assert_equals(cue.position, 'auto'); |
| 16 video.appendChild(track); | 16 video.appendChild(track); |
| 17 assert_equals(c1.align, 'middle'); | 17 assert_equals(cue.position, 'auto'); |
| 18 t.mode = 'showing'; | 18 t.mode = 'showing'; |
| 19 assert_equals(c1.align, 'middle'); | 19 assert_equals(cue.position, 'auto'); |
| 20 c1.align = 'start'; | 20 cue.position = 50; |
|
philipj_slow
2015/01/21 15:02:14
Also try setting to 'auto'.
fs
2015/01/21 15:28:24
Done.
| |
| 21 assert_equals(c1.align, 'start'); | 21 assert_equals(cue.position, 50); |
| 22 c1.align = 'end'; | 22 assert_throws(new TypeError, function() { cue.position = 'auto\u0000'; }); |
| 23 assert_equals(c1.align, 'end'); | 23 assert_throws(new TypeError, function() { cue.position = NaN; }); |
| 24 c1.align = 'start\u0000'; | 24 assert_throws(new TypeError, function() { cue.position = Infinity; }); |
| 25 assert_equals(c1.align, 'end'); | 25 assert_equals(cue.position, 50); |
| 26 }, document.title+', script-created cue'); | 26 }, document.title+', script-created cue'); |
| 27 | 27 |
| 28 var t_parsed = async_test(document.title+', parsed cue'); | 28 var t_parsed = async_test(document.title+', parsed cue'); |
| 29 t_parsed.step(function(){ | 29 t_parsed.step(function() { |
| 30 var video = document.createElement('video'); | 30 var video = document.createElement('video'); |
| 31 document.body.appendChild(video); | 31 document.body.appendChild(video); |
| 32 var t = document.createElement('track'); | 32 var t = document.createElement('track'); |
| 33 t.onload = this.step_func(function(){ | 33 t.onload = this.step_func(function() { |
| 34 var c1 = t.track.cues[0]; | 34 var cues = t.track.cues; |
| 35 var c2 = t.track.cues[1]; | 35 assert_equals(cues[0].position, 'auto'); |
| 36 var c3 = t.track.cues[2]; | 36 assert_equals(cues[1].position, 'auto'); |
| 37 var c4 = t.track.cues[3]; | 37 assert_equals(cues[2].position, 25); |
| 38 assert_equals(c1.align, 'middle'); | 38 assert_equals(cues[3].position, 75); |
| 39 assert_equals(c2.align, 'start'); | |
| 40 assert_equals(c3.align, 'middle'); | |
| 41 assert_equals(c4.align, 'end'); | |
| 42 this.done(); | 39 this.done(); |
| 43 }); | 40 }); |
| 44 t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:0 0:00.001\ntest\n\n'+ | 41 t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:0 0:00.001\ntest\n\n'+ |
| 45 '00:00:00.000 --> 00:00:00.001 a lign:start\ntest\n\n'+ | 42 '00:00:00.000 --> 00:00:00.001 a lign:start\ntest\n\n'+ |
| 46 '00:00:00.000 --> 00:00:00.001 a lign:middle\ntest\n\n'+ | 43 '00:00:00.000 --> 00:00:00.001 p osition:25%\ntest\n\n'+ |
| 47 '00:00:00.000 --> 00:00:00.001 a lign:end\ntest'); | 44 '00:00:00.000 --> 00:00:00.001 a lign:start position:75%\ntest\n\n'); |
| 48 t.track.mode = 'showing'; | 45 t.track.mode = 'showing'; |
| 49 video.appendChild(t); | 46 video.appendChild(t); |
| 50 }); | 47 }); |
| 51 </script> | 48 </script> |
| OLD | NEW |