Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-cue-rendering-overscan.html

Issue 2268923003: Clean up textTrackDisplayElement utility function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <title>WebVTT overscan margin test</title> 2 <title>WebVTT overscan margin test</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 <script> 7 <script>
8 setup(function() { window.internals.settings.setTextTrackMarginPercentage(5); }); 8 setup(function() { window.internals.settings.setTextTrackMarginPercentage(5); });
9 9
10 var makeTest = function(time, edgeName, marginAssertFunc) { 10 var makeTest = function(time, edgeName, marginAssertFunc) {
11 var expectedText = "Checks " + edgeName + " margin"; 11 var expectedText = "Checks " + edgeName + " margin";
12 var t = async_test(expectedText); 12 var t = async_test(expectedText);
13 t.step(function() { 13 t.step(function() {
14 var video = document.createElement('video'); 14 var video = document.createElement('video');
15 video.width = 320; 15 video.width = 320;
16 video.height = 240; 16 video.height = 240;
17 var track = document.createElement('track'); 17 var track = document.createElement('track');
18 track.src = "captions-webvtt/captions-overscan.vtt"; 18 track.src = "captions-webvtt/captions-overscan.vtt";
19 track['default'] = true; 19 track['default'] = true;
20 track.kind = 'captions'; 20 track.kind = 'captions';
21 video.appendChild(track); 21 video.appendChild(track);
22 document.body.appendChild(video); 22 document.body.appendChild(video);
23 23
24 video.src = findMediaFile('video', '../content/test'); 24 video.src = findMediaFile('video', '../content/test');
25 video.oncanplaythrough = function() { video.currentTime = time; }; 25 video.oncanplaythrough = function() { video.currentTime = time; };
26 video.onseeked = t.step_func(function() { 26 video.onseeked = t.step_func(function() {
27 var testCueDisplayBox = textTrackDisplayElement(video, 'display'); 27 var testCueDisplayBox = textTrackDisplayElement(video);
28 28
29 assert_equals(video.currentTime, time, "video.currentTime"); 29 assert_equals(video.currentTime, time, "video.currentTime");
30 assert_equals(track.track.activeCues.length, 1, "activeCues.length"); 30 assert_equals(track.track.activeCues.length, 1, "activeCues.length");
31 assert_equals(track.track.activeCues[0].text, expectedText, "activeCues[ 0].text"); 31 assert_equals(track.track.activeCues[0].text, expectedText, "activeCues[ 0].text");
32 assert_equals(testCueDisplayBox.innerText, expectedText, "testCueDisplay Box.innerText"); 32 assert_equals(testCueDisplayBox.innerText, expectedText, "testCueDisplay Box.innerText");
33 33
34 marginAssertFunc(testCueDisplayBox, video); 34 marginAssertFunc(testCueDisplayBox, video);
35 t.done(); 35 t.done();
36 }); 36 });
37 }); 37 });
38 }; 38 };
39 39
40 onload = function() { 40 onload = function() {
41 makeTest(0.5, "left", function(box, v) { assert_greater_than_equal(box.offse tLeft, v.width * 0.05); }); 41 makeTest(0.5, "left", function(box, v) { assert_greater_than_equal(box.offse tLeft, v.width * 0.05); });
42 makeTest(1.5, "right", function(box, v) { assert_less_than(box.offsetLeft + box.offsetWidth, v.width * 0.95); }); 42 makeTest(1.5, "right", function(box, v) { assert_less_than(box.offsetLeft + box.offsetWidth, v.width * 0.95); });
43 makeTest(2.5, "bottom", function(box, v) { assert_less_than(box.offsetTop + box.offsetHeight, v.height * 0.95); }); 43 makeTest(2.5, "bottom", function(box, v) { assert_less_than(box.offsetTop + box.offsetHeight, v.height * 0.95); });
44 makeTest(3.5, "top", function(box, v) { assert_greater_than_equal(box.offset Top, v.height * 0.05); }); 44 makeTest(3.5, "top", function(box, v) { assert_greater_than_equal(box.offset Top, v.height * 0.05); });
45 }; 45 };
46 </script> 46 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698