OLD | NEW |
1 <html> | 1 <!DOCTYPE html> |
2 <head> | 2 <title>Test that line breaks are forced in captions.</title> |
3 <script> | 3 <script src="../../resources/testharness.js"></script> |
4 if (window.internals.settings) | 4 <script src="../../resources/testharnessreport.js"></script> |
5 { | 5 <script src="../media-file.js"></script> |
6 // This should not be necessary, but due to crbug.com/372245 style | 6 <script src="../media-controls.js"></script> |
7 // gets dirtied during layout in LayoutTextTrackContainer which | 7 <script> |
8 // causes assertions to fail when Document::scrollingElement is | 8 // This should not be necessary, but due to crbug.com/372245 style |
9 // queried during compositing update (a valid request). | 9 // gets dirtied during layout in LayoutTextTrackContainer which |
10 window.internals.settings.setCompositorWorkerEnabled(false); | 10 // causes assertions to fail when Document::scrollingElement is |
11 } | 11 // queried during compositing update (a valid request). |
12 </script> | 12 window.internals.settings.setCompositorWorkerEnabled(false); |
13 <script src=../media-file.js></script> | 13 </script> |
14 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 14 <video> |
15 (Please avoid writing new tests using video-test.js) --> | 15 <track src="captions-webvtt/long-word.vtt" kind="captions" default> |
16 <script src=../video-test.js></script> | 16 </video> |
17 <script src=../media-controls.js></script> | 17 <script> |
18 <script> | 18 async_test(function(t) { |
| 19 var singleLineCaptionHeight; |
| 20 var video = document.querySelector("video"); |
| 21 video.oncanplaythrough = t.step_func(function() { |
| 22 // Record Single line caption height. |
| 23 singleLineCaptionHeight = getCaptionLineHeight(); |
| 24 video.currentTime = 3; |
| 25 }); |
19 | 26 |
20 var singleLineRect; | 27 video.onseeked = t.step_func_done(function() { |
| 28 var multiLineCaptionHeight = getCaptionLineHeight(); |
| 29 assert_greater_than(multiLineCaptionHeight / singleLineCaptionHeight, 2)
; |
| 30 }); |
21 | 31 |
22 function testUnbreakableLine() | 32 video.src = findMediaFile("video", "../content/test"); |
23 { | |
24 var multiLineRect = textTrackDisplayElement(video).firstChild.firstC
hild.getBoundingClientRect(); | |
25 var ratio = multiLineRect.height / singleLineRect.height; | |
26 logResult(ratio > 2, "Second caption was more than twice as tall as
first caption.") | |
27 endTest(); | |
28 } | |
29 | 33 |
30 function testSingleLine() | 34 function getCaptionLineHeight() { |
31 { | 35 var captionElement = textTrackDisplayElement(video).firstChild.firstChil
d; |
32 singleLineRect = textTrackDisplayElement(video).firstChild.firstChil
d.getBoundingClientRect(); | 36 return captionElement.getBoundingClientRect().height; |
33 consoleWrite("Single line caption height recorded."); | 37 } |
34 video.currentTime = 3; | 38 }); |
35 } | 39 </script> |
36 | |
37 function loaded() | |
38 { | |
39 consoleWrite('Test that line breaks are forced in captions.'); | |
40 findMediaElement(); | |
41 waitForEvent('canplaythrough', testSingleLine); | |
42 waitForEvent('seeked', testUnbreakableLine); | |
43 video.src = findMediaFile('video', '../content/test'); | |
44 } | |
45 | |
46 </script> | |
47 </head> | |
48 <body onload="loaded()"> | |
49 <video controls > | |
50 <track src="captions-webvtt/long-word.vtt" kind="captions" default> | |
51 </video> | |
52 </body> | |
53 </html> | |
OLD | NEW |