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

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/regions-webvtt/vtt-region-parser.html

Issue 2682333002: Implement VTTCue.region and sync the VTTRegion interface (Closed)
Patch Set: Add DCHECK Created 3 years, 10 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>Tests proper parsing of various regions present in WebVTT header area.</t itle> 2 <title>Tests proper parsing of various regions present in WebVTT header area.</t itle>
3 <script src="../../media-file.js"></script> 3 <script src="../../media-file.js"></script>
4 <script src="../../../resources/testharness.js"></script> 4 <script src="../../../resources/testharness.js"></script>
5 <script src="../../../resources/testharnessreport.js"></script> 5 <script src="../../../resources/testharnessreport.js"></script>
6 <script> 6 <script>
7 const regionDefaults = {
8 width: 100,
9 lines: 3,
10 regionAnchorX: 0,
11 regionAnchorY: 100,
12 viewportAnchorX: 0,
13 viewportAnchorY: 100,
14 scroll: ''
15 };
16
17 function checkProperties(region, expected, i) {
18 for (var prop in regionDefaults) {
19 if (!(prop in expected))
20 expected[prop] = regionDefaults[prop];
21 assert_equals(region[prop], expected[prop], prop + ' (cue '+(i+1)+')');
22 }
23 }
24
25 function checkCueRegions(cues) {
26 for (let i = 0; i < cues.length; ++i) {
27 let cue = cues[i];
28 let expected = JSON.parse(cue.text);
29 if (cue.region)
30 checkProperties(cue.region, expected, i);
31 else
32 assert_equals(expected, 'no region');
33 }
34 }
35
7 async_test(function(t) { 36 async_test(function(t) {
8 var video = document.createElement('video'); 37 var video = document.createElement('video');
9 video.src = findMediaFile('video', '../../content/test'); 38 video.src = findMediaFile('video', '../../content/test');
10 var testTrack = document.createElement('track'); 39 var testTrack = document.createElement('track');
11 testTrack.onload = t.step_func_done(function() { 40 testTrack.onload = t.step_func_done(function() {
12 var track = testTrack.track; 41 var track = testTrack.track;
13 assert_equals(track.regions.length, 5); 42 assert_equals(track.cues.length, 9);
14 43 checkCueRegions(track.cues);
15 var region = track.regions[0];
16 assert_equals(region.id, 'region_without_settings');
17
18 region = track.regions[1];
19 assert_equals(region.id, 'region_with_all_settings');
20 assert_equals(region.width, 32);
21 assert_equals(region.height, 5);
22 assert_equals(region.regionAnchorX, 41);
23 assert_equals(region.regionAnchorY, 20);
24 assert_equals(region.viewportAnchorX, 31);
25 assert_equals(region.viewportAnchorY, 84);
26 assert_equals(region.scroll, 'up');
27
28 region = track.regions[2];
29 assert_equals(region.id, 'region_floating_point_anchor');
30 assert_equals(Math.round(region.regionAnchorX * 1000), 41133);
31 assert_equals(Math.round(region.regionAnchorY * 1000), 20420);
32 assert_equals(Math.round(region.viewportAnchorX * 1000), 32330);
33 assert_equals(Math.round(region.viewportAnchorY * 1000), 32440);
34
35 region = track.regions[3];
36 assert_equals(region.id, 'not_unique_id');
37 assert_equals(region.width, 67);
38
39 region = track.regions[4];
40 assert_equals(region.id, '');
41 }); 44 });
42 testTrack.src = '../captions-webvtt/header-regions.vtt'; 45 testTrack.src = '../captions-webvtt/header-regions.vtt';
43 testTrack.kind = 'captions'; 46 testTrack.kind = 'captions';
44 testTrack.default = true; 47 testTrack.default = true;
45 video.appendChild(testTrack); 48 video.appendChild(testTrack);
46 }); 49 });
47 </script> 50 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698