Index: third_party/WebKit/LayoutTests/media/track/track-word-breaking.html |
diff --git a/third_party/WebKit/LayoutTests/media/track/track-word-breaking.html b/third_party/WebKit/LayoutTests/media/track/track-word-breaking.html |
index 12fc37bd4617acfec95f25480827156eaa8a0a3d..7334c854bba6c1ed8d2a2414e4abe1039af199bd 100644 |
--- a/third_party/WebKit/LayoutTests/media/track/track-word-breaking.html |
+++ b/third_party/WebKit/LayoutTests/media/track/track-word-breaking.html |
@@ -1,53 +1,39 @@ |
-<html> |
- <head> |
- <script> |
- if (window.internals.settings) |
- { |
- // This should not be necessary, but due to crbug.com/372245 style |
- // gets dirtied during layout in LayoutTextTrackContainer which |
- // causes assertions to fail when Document::scrollingElement is |
- // queried during compositing update (a valid request). |
- window.internals.settings.setCompositorWorkerEnabled(false); |
- } |
- </script> |
- <script src=../media-file.js></script> |
- <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 |
- (Please avoid writing new tests using video-test.js) --> |
- <script src=../video-test.js></script> |
- <script src=../media-controls.js></script> |
- <script> |
+<!DOCTYPE html> |
+<title>Test that line breaks are forced in captions.</title> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<script src="../media-file.js"></script> |
+<script src="../media-controls.js"></script> |
+<script> |
+// This should not be necessary, but due to crbug.com/372245 style |
+// gets dirtied during layout in LayoutTextTrackContainer which |
+// causes assertions to fail when Document::scrollingElement is |
+// queried during compositing update (a valid request). |
+window.internals.settings.setCompositorWorkerEnabled(false); |
+</script> |
+<video> |
+ <track src="captions-webvtt/long-word.vtt" kind="captions" default> |
+</video> |
+<script> |
+async_test(function(t) { |
+ var singleLineCaptionHeight; |
+ var video = document.querySelector("video"); |
+ video.oncanplaythrough = t.step_func(function() { |
+ // Record Single line caption height. |
+ singleLineCaptionHeight = getCaptionLineHeight(); |
+ video.currentTime = 3; |
+ }); |
- var singleLineRect; |
+ video.onseeked = t.step_func_done(function() { |
+ var multiLineCaptionHeight = getCaptionLineHeight(); |
+ assert_greater_than(multiLineCaptionHeight / singleLineCaptionHeight, 2); |
+ }); |
- function testUnbreakableLine() |
- { |
- var multiLineRect = textTrackDisplayElement(video).firstChild.firstChild.getBoundingClientRect(); |
- var ratio = multiLineRect.height / singleLineRect.height; |
- logResult(ratio > 2, "Second caption was more than twice as tall as first caption.") |
- endTest(); |
- } |
+ video.src = findMediaFile("video", "../content/test"); |
- function testSingleLine() |
- { |
- singleLineRect = textTrackDisplayElement(video).firstChild.firstChild.getBoundingClientRect(); |
- consoleWrite("Single line caption height recorded."); |
- video.currentTime = 3; |
- } |
- |
- function loaded() |
- { |
- consoleWrite('Test that line breaks are forced in captions.'); |
- findMediaElement(); |
- waitForEvent('canplaythrough', testSingleLine); |
- waitForEvent('seeked', testUnbreakableLine); |
- video.src = findMediaFile('video', '../content/test'); |
- } |
- |
- </script> |
- </head> |
- <body onload="loaded()"> |
- <video controls > |
- <track src="captions-webvtt/long-word.vtt" kind="captions" default> |
- </video> |
- </body> |
-</html> |
+ function getCaptionLineHeight() { |
+ var captionElement = textTrackDisplayElement(video).firstChild.firstChild; |
+ return captionElement.getBoundingClientRect().height; |
+ } |
+}); |
+</script> |