Index: third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html |
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html |
index 998408c798f95631842fe1a4894e42083fdca56e..d88822053854eb482a44864b11e6c0f55ddca36f 100644 |
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html |
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html |
@@ -1,86 +1,54 @@ |
<!DOCTYPE html> |
-<html> |
- <head> |
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
- |
- <script src=../media-file.js></script> |
- <!-- TODO(philipj): 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> |
- |
- var testTrack; |
- var testCueDisplayBox; |
- var seekedCount = 0; |
- var info = [ "Lorem", "ipsum", "dolor", "sit" ]; |
- |
- function testFontSize(width, height) |
- { |
- run("video.width = " + width); |
- run("video.height = " + height); |
- document.body.offsetTop; |
- testExpected("getComputedStyle(textTrackDisplayElement(video)).fontSize", parseInt(height * 0.05) + "px"); |
- consoleWrite(""); |
- } |
- |
- function testCueStyle() |
- { |
- consoleWrite("<br>Test the cue display colors and font."); |
+<title>Test that default positioned TextTrack's cues are rendered correctly.</title> |
+<script src="../media-file.js"></script> |
+<script src="../media-controls.js"></script> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<video> |
+ <track src="captions-webvtt/captions.vtt" kind="captions" default> |
+</video> |
+<script> |
+async_test(function(t) { |
+ var video = document.querySelector("video"); |
+ var testTrack = document.querySelector("track"); |
+ video.src = findMediaFile("video", "../content/test"); |
+ |
+ var cueTextIndex = 0; |
+ var cueText = [ "Lorem", "ipsum", "dolor", "sit" ]; |
+ video.onseeked = t.step_func(function() { |
+ assert_equals(video.currentTime, cueTextIndex + 0.5); |
+ assert_equals(testTrack.track.activeCues.length, 1); |
+ assert_equals(testTrack.track.activeCues[0].text, cueText[cueTextIndex]); |
+ |
+ var testCueDisplayBox = textTrackDisplayElement(video, "display"); |
+ assert_equals(testCueDisplayBox.innerText, cueText[cueTextIndex]); |
+ assert_equals(2 * testCueDisplayBox.offsetLeft, video.videoWidth - testCueDisplayBox.offsetWidth) |
+ |
+ if (++cueTextIndex == cueText.length) { |
+ // Test the cue display colors and font. |
testFontSize(320, 240); |
testFontSize(640, 480); |
testFontSize(1280, 960); |
testFontSize(2560, 1440); |
- testExpected("getComputedStyle(textTrackDisplayElement(video)).fontFamily", "sans-serif"); |
- testExpected("getComputedStyle(textTrackDisplayElement(video)).color", "rgb(255, 255, 255)"); |
- testExpected("getComputedStyle(textTrackDisplayElement(video, 'display').firstChild).backgroundColor", "rgba(0, 0, 0, 0.796875)"); |
+ assert_equals(getComputedStyle(textTrackDisplayElement(video)).fontFamily, "sans-serif"); |
+ assert_equals(getComputedStyle(textTrackDisplayElement(video)).color, "rgb(255, 255, 255)"); |
+ assert_equals(getComputedStyle(textTrackDisplayElement(video, "display").firstChild).backgroundColor, "rgba(0, 0, 0, 0.8)"); |
- endTest(); |
- |
- // Resize the video so it is easier to interact with it manually, if necessary. |
- video.width = 320; |
- video.height = 240; |
+ t.done(); |
+ } else { |
+ video.currentTime += 1; |
} |
- |
- function seeked() |
- { |
- if (testEnded) |
- return; |
- |
- testExpected("video.currentTime", seekedCount + .5); |
- testExpected("testTrack.track.activeCues.length", 1); |
- testExpected("testTrack.track.activeCues[0].text", info[seekedCount]); |
- |
- testCueDisplayBox = textTrackDisplayElement(video, 'display'); |
- testExpected("testCueDisplayBox.innerText", info[seekedCount]); |
- testExpected("2 * testCueDisplayBox.offsetLeft == video.videoWidth - testCueDisplayBox.offsetWidth", true) |
- |
- if (++seekedCount == info.length) |
- testCueStyle(); |
- else { |
- consoleWrite(""); |
- run("video.currentTime = " + (video.currentTime + 1)); |
- return; |
- } |
- } |
- |
- function loaded() |
- { |
- consoleWrite("Test that default positioned TextTrack's cues are rendered correctly."); |
- findMediaElement(); |
- testTrack = document.querySelector('track'); |
- video.src = findMediaFile('video', '../content/test'); |
- waitForEvent('seeked', seeked); |
- waitForEventOnce('canplaythrough', function() { video.currentTime = .5; }); |
- } |
- |
- </script> |
- </head> |
- <body onload="loaded()"> |
- <video controls > |
- <track src="captions-webvtt/captions.vtt" kind="captions" default> |
- </video> |
- </body> |
-</html> |
+ }); |
+ |
+ function testFontSize(width, height) { |
+ video.width = width; |
+ video.height = height; |
+ // Force a relayout of the document |
+ document.body.offsetTop; |
+ assert_equals(getComputedStyle(textTrackDisplayElement(video)).fontSize, parseInt(height * 0.05) + "px"); |
+ } |
+ |
+ video.currentTime = 0.5; |
+}); |
+</script> |