OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <title>Tests VTTRegionList functionality: length, operator[], and getRegionById(
).</title> | |
3 <script src="../../../resources/testharness.js"></script> | |
4 <script src="../../../resources/testharnessreport.js"></script> | |
5 <script> | |
6 test(function() { | |
7 var testTrack = document.createElement('track'); | |
8 | |
9 assert_equals(testTrack.track.mode, 'disabled'); | |
10 assert_equals(testTrack.track.regions, null); | |
11 | |
12 testTrack.track.mode = 'hidden'; | |
13 var regions = testTrack.track.regions; | |
14 | |
15 assert_true(regions instanceof VTTRegionList, 'instanceof'); | |
16 | |
17 assert_equals(regions.length, 0); | |
18 | |
19 var region = new VTTRegion(); | |
20 region.id = 'TestId'; | |
21 | |
22 assert_equals(region.track, null); | |
23 | |
24 testTrack.track.addRegion(region); | |
25 | |
26 assert_equals(regions.length, 1); | |
27 assert_equals(regions[0], region); | |
28 assert_equals(regions[0].track, testTrack.track); | |
29 | |
30 assert_equals(region.track, testTrack.track); | |
31 | |
32 var updatedRegion = new VTTRegion(); | |
33 updatedRegion.id = region.id; | |
34 updatedRegion.viewportAnchorX = 59; | |
35 updatedRegion.viewportAnchorY = 68; | |
36 updatedRegion.regionAnchorX = 20; | |
37 updatedRegion.regionAnchorY = 30; | |
38 updatedRegion.height = 5; | |
39 updatedRegion.width = 87; | |
40 updatedRegion.scroll = 'up'; | |
41 | |
42 testTrack.track.addRegion(updatedRegion); | |
43 assert_equals(regions[0].viewportAnchorX, updatedRegion.viewportAnchorX); | |
44 assert_equals(regions[0].viewportAnchorY, updatedRegion.viewportAnchorY); | |
45 assert_equals(regions[0].regionAnchorX, updatedRegion.regionAnchorX); | |
46 assert_equals(regions[0].regionAnchorY, updatedRegion.regionAnchorY); | |
47 assert_equals(regions[0].height, updatedRegion.height); | |
48 assert_equals(regions[0].width, updatedRegion.width); | |
49 assert_equals(regions[0].scroll, updatedRegion.scroll); | |
50 | |
51 assert_not_equals(regions[0], updatedRegion); | |
52 | |
53 testTrack.track.addRegion(region); | |
54 assert_equals(regions.length, 1); | |
55 testTrack.track.removeRegion(region); | |
56 assert_equals(regions.length, 0); | |
57 | |
58 assert_throws('NotFoundError', function() { testTrack.track.removeRegion(reg
ion); }); | |
59 | |
60 // FIXME(109818): Update test for multiple initial regions (after parsing is
supported). | |
61 }); | |
62 </script> | |
63 </html> | |
OLD | NEW |