OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Test that TextTrack's cues are rendered correctly when the snap to lines
flag is not set.</title> | 2 <title>Test that TextTrack's cues are rendered correctly when the snap to lines
flag is not set.</title> |
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-snap-to-lines-not-set.vtt" kind="captio
ns" default> | 8 <track src="captions-webvtt/captions-snap-to-lines-not-set.vtt" kind="captio
ns" 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 // In Chromium it is the enclosure element, which provides the controls heig
ht, otherwise the panel; | 16 // In Chromium it is the enclosure element, which provides the controls heig
ht, otherwise the panel; |
17 // both are the second child in the shadow DOM. | 17 // both are the second child in the shadow DOM. |
18 var controlsPanelElement = internals.shadowRoot(video).firstChild.firstChild
; | 18 var controlsPanelElement = internals.shadowRoot(video).firstChild.firstChild
; |
19 | 19 |
20 var cueDisplayContainer; | 20 var cueDisplayContainer; |
21 video.oncanplaythrough = t.step_func(function() { | 21 video.oncanplaythrough = t.step_func(function() { |
22 cueDisplayContainer = textTrackDisplayElement(video); | 22 cueDisplayContainer = textTrackContainerElement(video); |
23 runNextTestCase(); | 23 runNextTestCase(); |
24 }); | 24 }); |
25 | 25 |
26 var seekTimeIndex = 0; | 26 var seekTimeIndex = 0; |
27 var testCaseSeekTime = [ | 27 var testCaseSeekTime = [ |
28 0.10, | 28 0.10, |
29 0.60, | 29 0.60, |
30 1.10, | 30 1.10, |
31 1.60, | 31 1.60, |
32 2.10, | 32 2.10, |
(...skipping 26 matching lines...) Expand all Loading... |
59 return; | 59 return; |
60 } | 60 } |
61 | 61 |
62 video.currentTime = testCaseSeekTime[seekTimeIndex]; | 62 video.currentTime = testCaseSeekTime[seekTimeIndex]; |
63 video.onseeked = t.step_func(seeked); | 63 video.onseeked = t.step_func(seeked); |
64 } | 64 } |
65 | 65 |
66 function seeked() { | 66 function seeked() { |
67 var cuePosition = cueRenderingPosition[seekTimeIndex]; | 67 var cuePosition = cueRenderingPosition[seekTimeIndex]; |
68 for (var i = 0; i < testTrack.track.activeCues.length; ++i) { | 68 for (var i = 0; i < testTrack.track.activeCues.length; ++i) { |
69 cueDisplayElement = textTrackDisplayElement(video, "display", i); | 69 cueDisplayElement = textTrackCueElementByIndex(video, i); |
70 | 70 |
71 assert_equals(cueDisplayElement.innerText, testTrack.track.activeCue
s[i].text); | 71 assert_equals(cueDisplayElement.innerText, testTrack.track.activeCue
s[i].text); |
72 assert_equals(testTrack.track.activeCues[i].align, cuePosition[i][2]
); | 72 assert_equals(testTrack.track.activeCues[i].align, cuePosition[i][2]
); |
73 | 73 |
74 assert_equals(Math.round(cueDisplayElement.offsetLeft / cueDisplayCo
ntainer.offsetWidth * 100), cuePosition[i][0]); | 74 assert_equals(Math.round(cueDisplayElement.offsetLeft / cueDisplayCo
ntainer.offsetWidth * 100), cuePosition[i][0]); |
75 assert_equals(Math.round(cueDisplayElement.offsetTop / cueDisplayCon
tainer.offsetHeight * 100), cuePosition[i][1]); | 75 assert_equals(Math.round(cueDisplayElement.offsetTop / cueDisplayCon
tainer.offsetHeight * 100), cuePosition[i][1]); |
76 } | 76 } |
77 | 77 |
78 seekTimeIndex++; | 78 seekTimeIndex++; |
79 runNextTestCase(); | 79 runNextTestCase(); |
80 } | 80 } |
81 }); | 81 }); |
82 </script> | 82 </script> |
OLD | NEW |