Chromium Code Reviews| 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 singleLineRect; | |
| 20 var video = document.querySelector("video"); | |
| 21 video.oncanplaythrough = t.step_func(function() { | |
| 22 // Record Single line caption height. | |
| 23 singleLineRect = textTrackDisplayElement(video).firstChild.firstChild.ge tBoundingClientRect(); | |
|
fs
2016/06/13 15:20:18
Maybe move the right-hand side (+ .height) here in
Srirama
2016/06/13 17:33:38
Done.
| |
| 24 video.currentTime = 3; | |
| 25 }); | |
| 19 | 26 |
| 20 var singleLineRect; | 27 video.onseeked = t.step_func_done(function() { |
| 28 var multiLineRect = textTrackDisplayElement(video).firstChild.firstChild .getBoundingClientRect(); | |
| 29 var ratio = multiLineRect.height / singleLineRect.height; | |
| 30 assert_greater_than(ratio, 2); | |
| 31 }); | |
| 21 | 32 |
| 22 function testUnbreakableLine() | 33 video.src = findMediaFile("video", "../content/test"); |
| 23 { | 34 }); |
| 24 var multiLineRect = textTrackDisplayElement(video).firstChild.firstC hild.getBoundingClientRect(); | 35 </script> |
| 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 | |
| 30 function testSingleLine() | |
| 31 { | |
| 32 singleLineRect = textTrackDisplayElement(video).firstChild.firstChil d.getBoundingClientRect(); | |
| 33 consoleWrite("Single line caption height recorded."); | |
| 34 video.currentTime = 3; | |
| 35 } | |
| 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 |