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 <video> | 7 <video> |
8 <track src="captions-webvtt/captions.vtt" kind="captions" default> | 8 <track src="captions-webvtt/captions.vtt" kind="captions" default> |
9 </video> | 9 </video> |
10 <script> | 10 <script> |
11 async_test(function(t) { | 11 async_test(function(t) { |
12 var video = document.querySelector("video"); | 12 var video = document.querySelector("video"); |
13 var testTrack = document.querySelector("track"); | 13 var testTrack = document.querySelector("track"); |
14 video.src = findMediaFile("video", "../content/test"); | 14 video.src = findMediaFile("video", "../content/test"); |
15 | 15 |
16 var cueTextIndex = 0; | 16 var cueTextIndex = 0; |
17 var cueText = [ "Lorem", "ipsum", "dolor", "sit" ]; | 17 var cueText = [ "Lorem", "ipsum", "dolor", "sit" ]; |
18 video.onseeked = t.step_func(function() { | 18 video.onseeked = t.step_func(function() { |
19 assert_equals(video.currentTime, cueTextIndex + 0.5); | 19 assert_equals(video.currentTime, cueTextIndex + 0.5); |
20 assert_equals(testTrack.track.activeCues.length, 1); | 20 assert_equals(testTrack.track.activeCues.length, 1); |
21 assert_equals(testTrack.track.activeCues[0].text, cueText[cueTextIndex])
; | 21 assert_equals(testTrack.track.activeCues[0].text, cueText[cueTextIndex])
; |
22 | 22 |
23 var testCueDisplayBox = textTrackDisplayElement(video, "display"); | 23 var testCueDisplayBox = textTrackDisplayElement(video); |
24 assert_equals(testCueDisplayBox.innerText, cueText[cueTextIndex]); | 24 assert_equals(testCueDisplayBox.innerText, cueText[cueTextIndex]); |
25 assert_equals(2 * testCueDisplayBox.offsetLeft, video.videoWidth - testC
ueDisplayBox.offsetWidth) | 25 assert_equals(2 * testCueDisplayBox.offsetLeft, video.videoWidth - testC
ueDisplayBox.offsetWidth) |
26 | 26 |
27 if (++cueTextIndex == cueText.length) { | 27 if (++cueTextIndex == cueText.length) { |
28 // Test the cue display colors and font. | 28 // Test the cue display colors and font. |
29 testFontSize(320, 240); | 29 testFontSize(320, 240); |
30 testFontSize(640, 480); | 30 testFontSize(640, 480); |
31 testFontSize(1280, 960); | 31 testFontSize(1280, 960); |
32 testFontSize(2560, 1440); | 32 testFontSize(2560, 1440); |
33 | 33 |
34 assert_equals(getComputedStyle(textTrackDisplayElement(video)).fontF
amily, "sans-serif"); | 34 assert_equals(getComputedStyle(textTrackContainerElement(video)).fon
tFamily, "sans-serif"); |
35 assert_equals(getComputedStyle(textTrackDisplayElement(video)).color
, "rgb(255, 255, 255)"); | 35 assert_equals(getComputedStyle(textTrackContainerElement(video)).col
or, "rgb(255, 255, 255)"); |
36 assert_equals(getComputedStyle(textTrackDisplayElement(video, "displ
ay").firstChild).backgroundColor, "rgba(0, 0, 0, 0.8)"); | 36 assert_equals(getComputedStyle(textTrackDisplayElement(video).firstC
hild).backgroundColor, "rgba(0, 0, 0, 0.8)"); |
37 | 37 |
38 t.done(); | 38 t.done(); |
39 } else { | 39 } else { |
40 video.currentTime += 1; | 40 video.currentTime += 1; |
41 } | 41 } |
42 }); | 42 }); |
43 | 43 |
44 function testFontSize(width, height) { | 44 function testFontSize(width, height) { |
45 video.width = width; | 45 video.width = width; |
46 video.height = height; | 46 video.height = height; |
47 // Force a relayout of the document | 47 // Force a relayout of the document |
48 document.body.offsetTop; | 48 document.body.offsetTop; |
49 assert_equals(getComputedStyle(textTrackDisplayElement(video)).fontSize,
parseInt(height * 0.05) + "px"); | 49 assert_equals(getComputedStyle(textTrackContainerElement(video)).fontSiz
e, parseInt(height * 0.05) + "px"); |
50 } | 50 } |
51 | 51 |
52 video.currentTime = 0.5; | 52 video.currentTime = 0.5; |
53 }); | 53 }); |
54 </script> | 54 </script> |
OLD | NEW |