OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests proper parsing of various regions present in WebVTT header area.</t
itle> |
3 <head> | 3 <script src="../../media-file.js"></script> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../../resources/testharness.js"></script> |
| 5 <script src="../../../resources/testharnessreport.js"></script> |
| 6 <script> |
| 7 async_test(function(t) { |
| 8 var video = document.createElement('video'); |
| 9 video.src = findMediaFile('video', '../../content/test'); |
| 10 var testTrack = document.createElement('track'); |
| 11 testTrack.onload = t.step_func_done(function() { |
| 12 var track = testTrack.track; |
| 13 assert_equals(track.regions.length, 5); |
5 | 14 |
6 <script src=../../media-file.js></script> | 15 var region = track.regions[0]; |
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 16 assert_equals(region.id, 'region_without_settings'); |
8 (Please avoid writing new tests using video-test.js) --> | |
9 <script src=../../video-test.js></script> | |
10 <script> | |
11 var region; | |
12 | 17 |
13 function startTest() | 18 region = track.regions[1]; |
14 { | 19 assert_equals(region.id, 'region_with_all_settings'); |
15 if (!window.VTTRegion) { | 20 assert_equals(region.width, 32); |
16 failTest(); | 21 assert_equals(region.height, 5); |
17 return; | 22 assert_equals(region.regionAnchorX, 41); |
18 } | 23 assert_equals(region.regionAnchorY, 20); |
| 24 assert_equals(region.viewportAnchorX, 31); |
| 25 assert_equals(region.viewportAnchorY, 84); |
| 26 assert_equals(region.scroll, 'up'); |
19 | 27 |
20 findMediaElement(); | 28 region = track.regions[2]; |
21 testExpected("video.textTracks[0].regions.length", 5); | 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); |
22 | 34 |
23 consoleWrite(""); | 35 region = track.regions[3]; |
24 region = video.textTracks[0].regions[0]; | 36 assert_equals(region.id, 'not_unique_id'); |
25 testExpected("region.id", "region_without_settings"); | 37 assert_equals(region.width, 67); |
26 | 38 |
27 consoleWrite(""); | 39 region = track.regions[4]; |
28 region = video.textTracks[0].regions[1]; | 40 assert_equals(region.id, ''); |
29 testExpected("region.id", "region_with_all_settings"); | 41 }); |
30 testExpected("region.width", 32); | 42 testTrack.src = '../captions-webvtt/header-regions.vtt'; |
31 testExpected("region.height", 5); | 43 testTrack.kind = 'captions'; |
32 testExpected("region.regionAnchorX", 41); | 44 testTrack.default = true; |
33 testExpected("region.regionAnchorY", 20); | 45 video.appendChild(testTrack); |
34 testExpected("region.viewportAnchorX", 31); | 46 }); |
35 testExpected("region.viewportAnchorY", 84); | 47 </script> |
36 testExpected("region.scroll", "up"); | |
37 | |
38 consoleWrite(""); | |
39 region = video.textTracks[0].regions[2]; | |
40 testExpected("region.id", "region_floating_point_anchor"); | |
41 testExpected("Math.round(region.regionAnchorX * 1000)", 41133); | |
42 testExpected("Math.round(region.regionAnchorY * 1000)", 20420); | |
43 testExpected("Math.round(region.viewportAnchorX * 1000)", 32330); | |
44 testExpected("Math.round(region.viewportAnchorY * 1000)", 32440); | |
45 | |
46 consoleWrite(""); | |
47 region = video.textTracks[0].regions[3]; | |
48 testExpected("region.id", "not_unique_id"); | |
49 testExpected("region.width", 67); | |
50 | |
51 consoleWrite(""); | |
52 region = video.textTracks[0].regions[4]; | |
53 testExpected("region.id", ""); | |
54 | |
55 consoleWrite(""); | |
56 endTest(); | |
57 } | |
58 | |
59 </script> | |
60 </head> | |
61 <body> | |
62 <p>Tests proper parsing of various regions present in WebVTT header area
.</p> | |
63 <video controls> | |
64 <track src="../captions-webvtt/header-regions.vtt" kind="captions" d
efault onload="startTest()"> | |
65 </video> | |
66 | |
67 </body> | |
68 </html> | |
OLD | NEW |