OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Test that default positioned TextTrack's cues are rendered correctly.</ti
tle> | 2 <title>Test that default positioned TextTrack's cues are rendered correctly.</ti
tle> |
3 <script src="../media-file.js"></script> | 3 <script src="../media-file.js"></script> |
4 <script src="../media-controls.js"></script> | 4 <script src="../media-controls.js"></script> |
5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="../../resources/run-after-layout-and-paint.js"></script> |
7 <video> | 8 <video> |
8 <track src="captions-webvtt/captions.vtt" kind="captions" default> | 9 <track src="captions-webvtt/captions.vtt" kind="captions" default> |
9 </video> | 10 </video> |
10 <script> | 11 <script> |
11 async_test(function(t) { | 12 async_test(function(t) { |
12 var video = document.querySelector("video"); | 13 var video = document.querySelector("video"); |
13 var testTrack = document.querySelector("track"); | 14 var testTrack = document.querySelector("track"); |
14 video.src = findMediaFile("video", "../content/test"); | 15 video.src = findMediaFile("video", "../content/test"); |
15 | 16 |
16 var cueTextIndex = 0; | 17 var cueTextIndex = 0; |
17 var cueText = [ "Lorem", "ipsum", "dolor", "sit" ]; | 18 var cueText = [ "Lorem", "ipsum", "dolor", "sit" ]; |
18 video.onseeked = t.step_func(function() { | 19 video.onseeked = t.step_func(function() { |
19 assert_equals(video.currentTime, cueTextIndex + 0.5); | 20 assert_equals(video.currentTime, cueTextIndex + 0.5); |
20 assert_equals(testTrack.track.activeCues.length, 1); | 21 assert_equals(testTrack.track.activeCues.length, 1); |
21 assert_equals(testTrack.track.activeCues[0].text, cueText[cueTextIndex])
; | 22 assert_equals(testTrack.track.activeCues[0].text, cueText[cueTextIndex])
; |
22 | 23 |
23 var testCueDisplayBox = textTrackDisplayElement(video); | 24 var testCueDisplayBox = textTrackDisplayElement(video); |
24 assert_equals(testCueDisplayBox.innerText, cueText[cueTextIndex]); | 25 assert_equals(testCueDisplayBox.innerText, cueText[cueTextIndex]); |
25 assert_equals(2 * testCueDisplayBox.offsetLeft, video.videoWidth - testC
ueDisplayBox.offsetWidth) | 26 assert_equals(2 * testCueDisplayBox.offsetLeft, video.videoWidth - testC
ueDisplayBox.offsetWidth) |
26 | 27 |
27 if (++cueTextIndex == cueText.length) { | 28 if (++cueTextIndex == cueText.length) { |
28 // Test the cue display colors and font. | 29 // Test the cue display colors and font. |
29 testFontSize(320, 240); | 30 testFontSize([[2560, 1440], [1280, 960], [640, 480], [320, 240]]); |
30 testFontSize(640, 480); | |
31 testFontSize(1280, 960); | |
32 testFontSize(2560, 1440); | |
33 | |
34 assert_equals(getComputedStyle(textTrackContainerElement(video)).fon
tFamily, "sans-serif"); | |
35 assert_equals(getComputedStyle(textTrackContainerElement(video)).col
or, "rgb(255, 255, 255)"); | |
36 assert_equals(getComputedStyle(textTrackDisplayElement(video).firstC
hild).backgroundColor, "rgba(0, 0, 0, 0.8)"); | |
37 | |
38 t.done(); | |
39 } else { | 31 } else { |
40 video.currentTime += 1; | 32 video.currentTime += 1; |
41 } | 33 } |
42 }); | 34 }); |
43 | 35 |
44 function testFontSize(width, height) { | 36 function testFontSize(subjects) { |
45 video.width = width; | 37 var dimensions = subjects.shift(); |
46 video.height = height; | 38 video.width = dimensions[0]; |
47 // Force a relayout of the document | 39 video.height = dimensions[1]; |
48 document.body.offsetTop; | 40 runAfterLayoutAndPaint(t.step_func(function() { |
49 assert_equals(getComputedStyle(textTrackContainerElement(video)).fontSiz
e, parseInt(height * 0.05) + "px"); | 41 assert_equals(getComputedStyle(textTrackContainerElement(video)).fon
tSize, parseInt(video.height * 0.05) + "px"); |
| 42 if (subjects.length) { |
| 43 testFontSize(subjects); |
| 44 } else { |
| 45 assert_equals(getComputedStyle(textTrackContainerElement(video))
.fontFamily, "sans-serif"); |
| 46 assert_equals(getComputedStyle(textTrackContainerElement(video))
.color, "rgb(255, 255, 255)"); |
| 47 assert_equals(getComputedStyle(textTrackDisplayElement(video).fi
rstChild).backgroundColor, "rgba(0, 0, 0, 0.8)"); |
| 48 |
| 49 t.done(); |
| 50 } |
| 51 })); |
50 } | 52 } |
51 | 53 |
52 video.currentTime = 0.5; | 54 video.currentTime = 0.5; |
53 }); | 55 }); |
54 </script> | 56 </script> |
OLD | NEW |