OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>Tests the constructor and mutation of VTTRegion.</title> |
3 <head> | 3 <script src="../../../resources/testharness.js"></script> |
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | 4 <script src="../../../resources/testharnessreport.js"></script> |
5 <script> | |
6 test(function() { | |
7 assert_not_equals(window.VTTRegion, null); | |
philipj_slow
2016/04/01 11:07:49
You can drop this, the next line will throw if VTT
Srirama
2016/04/01 12:14:23
Done.
| |
5 | 8 |
6 <script src=../../media-file.js></script> | 9 var region = new VTTRegion(); |
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 | 10 assert_true(region instanceof VTTRegion, 'instanceof'); |
8 (Please avoid writing new tests using video-test.js) --> | |
9 <script src=../../video-test.js></script> | |
10 <script> | |
11 var region; | |
12 var invalidPercentageValues; | |
13 | 11 |
14 function startTest() | 12 assert_equals(region.track, null); |
15 { | 13 assert_equals(region.scroll, ""); |
16 if (!window.VTTRegion) { | 14 assert_equals(region.viewportAnchorX, 0); |
17 failTest(); | 15 assert_equals(region.viewportAnchorY, 100); |
18 return; | 16 assert_equals(region.regionAnchorX, 0); |
19 } | 17 assert_equals(region.regionAnchorY, 100); |
18 assert_equals(region.height, 3); | |
19 assert_equals(region.width, 100); | |
20 | 20 |
21 region = new VTTRegion(); | 21 assert_throws(new SyntaxError, function() { region.scroll = 'invalid-scroll- value'; }); |
22 assert_equals(region.scroll, ""); | |
22 | 23 |
23 consoleWrite("** Test instanceof VTTRegion. **"); | 24 var invalidPercentageValues = [-1, 101, -Infinity, Infinity, NaN]; |
24 testExpected("region instanceof VTTRegion", true); | 25 for (index in invalidPercentageValues) { |
26 assert_throws(new IndexSizeError, function() { region.viewportAnchorX = in validPercentageValues[index]; }); | |
Srirama
2016/04/01 09:58:18
Though this throw IndexSizeError object, it gives
fs
2016/04/01 10:39:45
Try "IndexSizeError".
Srirama
2016/04/01 12:14:23
Thank you, you always come to my rescue when i get
| |
27 assert_equals(region.viewportAnchorX, 0); | |
28 assert_throws(new IndexSizeError, function() { region.viewportAnchorY = in validPercentageValues[index]; }); | |
29 assert_equals(region.viewportAnchorY, 100); | |
30 assert_throws(new IndexSizeError, function() { region.regionAnchorX = inva lidPercentageValues[index]; }); | |
31 assert_equals(region.regionAnchorX, 0); | |
32 assert_throws(new IndexSizeError, function() { region.regionAnchorY = inva lidPercentageValues[index]; }); | |
33 assert_equals(region.regionAnchorY, 100); | |
34 assert_throws(new IndexSizeError, function() { region.width = invalidPerce ntageValues[index]; }); | |
35 assert_equals(region.width, 100); | |
36 } | |
25 | 37 |
26 consoleWrite("** Test the default indexs of a region. **"); | 38 assert_throws(new IndexSizeError, function() { region.height = -1; }); |
27 testExpected("region.track", null); | 39 assert_equals(region.height, 3); |
28 testExpected("region.scroll", ""); | |
29 testExpected("region.viewportAnchorX", 0); | |
30 testExpected("region.viewportAnchorY", 100); | |
31 testExpected("region.regionAnchorX", 0); | |
32 testExpected("region.regionAnchorY", 100); | |
33 testExpected("region.height", 3); | |
34 testExpected("region.width", 100); | |
35 | 40 |
36 consoleWrite("<br>** Test that incorrect mutation keeps previous valid values. **"); | 41 region.height = 130; |
37 run("region.scroll = 'invalid-scroll-value'"); | 42 assert_equals(region.height, 130); |
38 testExpected("region.scroll", ""); | 43 region.viewportAnchorX = 64; |
39 | 44 assert_equals(region.viewportAnchorX, 64); |
40 invalidPercentageValues = [-1, 101, -Infinity, Infinity, NaN]; | 45 region.viewportAnchorY = 32; |
41 for (index in invalidPercentageValues) { | 46 assert_equals(region.viewportAnchorY, 32); |
42 consoleWrite("<br>Invalid percentage value: " + invalidPercent ageValues[index]); | 47 region.regionAnchorX = 16; |
43 run("region.viewportAnchorX = invalidPercentageValues[index]") ; | 48 assert_equals(region.regionAnchorX, 16); |
44 testExpected("region.viewportAnchorX", 0); | 49 region.regionAnchorY = 8; |
45 run("region.viewportAnchorY = invalidPercentageValues[index]") ; | 50 assert_equals(region.regionAnchorY, 8); |
46 testExpected("region.viewportAnchorY", 100); | 51 region.width = 42; |
47 run("region.regionAnchorX = invalidPercentageValues[index]"); | 52 assert_equals(region.width, 42); |
48 testExpected("region.regionAnchorX", 0); | 53 }); |
49 run("region.regionAnchorY = invalidPercentageValues[index]"); | 54 </script> |
50 testExpected("region.regionAnchorY", 100); | |
51 run("region.width = invalidPercentageValues[index]"); | |
52 testExpected("region.width", 100); | |
53 } | |
54 | |
55 run("region.height = -1"); | |
56 testExpected("region.height", 3); | |
57 | |
58 consoleWrite("<br>** Test that proper mutation keeps assigned va lue. **"); | |
59 run("region.height = 130"); | |
60 testExpected("region.height", 130); | |
61 | |
62 run("region.viewportAnchorX = 64"); | |
63 testExpected("region.viewportAnchorX", 64); | |
64 run("region.viewportAnchorY = 32"); | |
65 testExpected("region.viewportAnchorY", 32); | |
66 run("region.regionAnchorX = 16"); | |
67 testExpected("region.regionAnchorX", 16); | |
68 run("region.regionAnchorY = 8"); | |
69 testExpected("region.regionAnchorY", 8); | |
70 | |
71 run("region.width = 42"); | |
72 testExpected("region.width", 42); | |
73 | |
74 endTest(); | |
75 } | |
76 | |
77 </script> | |
78 </head> | |
79 <body onload="startTest()"> | |
80 <p>Tests the constructor and mutation of VTTRegion.</p> | |
81 </body> | |
82 </html> | |
OLD | NEW |