OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
5 | |
6 <script src=../../media-file.js></script> | |
7 <script src=../../video-test.js></script> | |
8 <script> | |
9 var region; | |
10 var invalidPercentageValues; | |
11 | |
12 function startTest() | |
13 { | |
14 if (!window.TextTrackRegion) { | |
15 failTest(); | |
16 return; | |
17 } | |
18 | |
19 region = new TextTrackRegion(); | |
20 | |
21 consoleWrite("** Test the default indexs of a region. **"); | |
22 testExpected("region.track", null); | |
23 testExpected("region.scroll", ""); | |
24 testExpected("region.viewportAnchorX", 0); | |
25 testExpected("region.viewportAnchorY", 100); | |
26 testExpected("region.regionAnchorX", 0); | |
27 testExpected("region.regionAnchorY", 100); | |
28 testExpected("region.height", 3); | |
29 testExpected("region.width", 100); | |
30 | |
31 consoleWrite("<br>** Test that incorrect mutation keeps previous
valid values. **"); | |
32 run("region.scroll = 'invalid-scroll-value'"); | |
33 testExpected("region.scroll", ""); | |
34 | |
35 invalidPercentageValues = [-1, 101, -Infinity, Infinity, NaN]; | |
36 for (index in invalidPercentageValues) { | |
37 consoleWrite("<br>Invalid percentage value: " + invalidPercent
ageValues[index]); | |
38 run("region.viewportAnchorX = invalidPercentageValues[index]")
; | |
39 testExpected("region.viewportAnchorX", 0); | |
40 run("region.viewportAnchorY = invalidPercentageValues[index]")
; | |
41 testExpected("region.viewportAnchorY", 100); | |
42 run("region.regionAnchorX = invalidPercentageValues[index]"); | |
43 testExpected("region.regionAnchorX", 0); | |
44 run("region.regionAnchorY = invalidPercentageValues[index]"); | |
45 testExpected("region.regionAnchorY", 100); | |
46 run("region.width = invalidPercentageValues[index]"); | |
47 testExpected("region.width", 100); | |
48 } | |
49 | |
50 run("region.height = -1"); | |
51 testExpected("region.height", 3); | |
52 | |
53 consoleWrite("<br>** Test that proper mutation keeps assigned va
lue. **"); | |
54 run("region.height = 130"); | |
55 testExpected("region.height", 130); | |
56 | |
57 run("region.viewportAnchorX = 64"); | |
58 testExpected("region.viewportAnchorX", 64); | |
59 run("region.viewportAnchorY = 32"); | |
60 testExpected("region.viewportAnchorY", 32); | |
61 run("region.regionAnchorX = 16"); | |
62 testExpected("region.regionAnchorX", 16); | |
63 run("region.regionAnchorY = 8"); | |
64 testExpected("region.regionAnchorY", 8); | |
65 | |
66 run("region.width = 42"); | |
67 testExpected("region.width", 42); | |
68 | |
69 endTest(); | |
70 } | |
71 | |
72 </script> | |
73 </head> | |
74 <body onload="startTest()"> | |
75 <p>Tests the constructor and mutation of TextTrackRegion.</p> | |
76 </body> | |
77 </html> | |
OLD | NEW |