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

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

Issue 1854553003: Convert webvtt regions tests from video-test.js to testharness.js based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address more comments Created 4 years, 8 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 <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 var region = new VTTRegion();
8 assert_true(region instanceof VTTRegion, "instanceof");
5 9
6 <script src=../../media-file.js></script> 10 assert_equals(region.track, null);
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 11 assert_equals(region.scroll, "");
8 (Please avoid writing new tests using video-test.js) --> 12 assert_equals(region.viewportAnchorX, 0);
9 <script src=../../video-test.js></script> 13 assert_equals(region.viewportAnchorY, 100);
10 <script> 14 assert_equals(region.regionAnchorX, 0);
11 var region; 15 assert_equals(region.regionAnchorY, 100);
12 var invalidPercentageValues; 16 assert_equals(region.height, 3);
17 assert_equals(region.width, 100);
13 18
14 function startTest() 19 assert_throws(new SyntaxError, function() { region.scroll = "invalid-scroll- value"; });
15 { 20 assert_equals(region.scroll, "");
16 if (!window.VTTRegion) {
17 failTest();
18 return;
19 }
20 21
21 region = new VTTRegion(); 22 var invalidPercentageValues = [-1, 101];
23 for (var value of invalidPercentageValues) {
24 assert_throws("IndexSizeError", function() { region.viewportAnchorX = valu e; });
25 assert_equals(region.viewportAnchorX, 0);
26 assert_throws("IndexSizeError", function() { region.viewportAnchorY = valu e; });
27 assert_equals(region.viewportAnchorY, 100);
28 assert_throws("IndexSizeError", function() { region.regionAnchorX = value; });
29 assert_equals(region.regionAnchorX, 0);
30 assert_throws("IndexSizeError", function() { region.regionAnchorY = value; });
31 assert_equals(region.regionAnchorY, 100);
32 assert_throws("IndexSizeError", function() { region.width = value; });
33 assert_equals(region.width, 100);
34 }
22 35
23 consoleWrite("** Test instanceof VTTRegion. **"); 36 invalidPercentageValues = [-Infinity, Infinity, NaN];
24 testExpected("region instanceof VTTRegion", true); 37 for (var value of invalidPercentageValues) {
38 assert_throws(new TypeError, function() { region.viewportAnchorX = value; });
39 assert_equals(region.viewportAnchorX, 0);
40 assert_throws(new TypeError, function() { region.viewportAnchorY = value; });
41 assert_equals(region.viewportAnchorY, 100);
42 assert_throws(new TypeError, function() { region.regionAnchorX = value; }) ;
43 assert_equals(region.regionAnchorX, 0);
44 assert_throws(new TypeError, function() { region.regionAnchorY = value; }) ;
45 assert_equals(region.regionAnchorY, 100);
46 assert_throws(new TypeError, function() { region.width = value; });
47 assert_equals(region.width, 100);
48 }
25 49
26 consoleWrite("** Test the default indexs of a region. **"); 50 assert_throws("IndexSizeError", function() { region.height = -1; });
27 testExpected("region.track", null); 51 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 52
36 consoleWrite("<br>** Test that incorrect mutation keeps previous valid values. **"); 53 region.height = 130;
37 run("region.scroll = 'invalid-scroll-value'"); 54 assert_equals(region.height, 130);
38 testExpected("region.scroll", ""); 55 region.viewportAnchorX = 64;
39 56 assert_equals(region.viewportAnchorX, 64);
40 invalidPercentageValues = [-1, 101, -Infinity, Infinity, NaN]; 57 region.viewportAnchorY = 32;
41 for (index in invalidPercentageValues) { 58 assert_equals(region.viewportAnchorY, 32);
42 consoleWrite("<br>Invalid percentage value: " + invalidPercent ageValues[index]); 59 region.regionAnchorX = 16;
43 run("region.viewportAnchorX = invalidPercentageValues[index]") ; 60 assert_equals(region.regionAnchorX, 16);
44 testExpected("region.viewportAnchorX", 0); 61 region.regionAnchorY = 8;
45 run("region.viewportAnchorY = invalidPercentageValues[index]") ; 62 assert_equals(region.regionAnchorY, 8);
46 testExpected("region.viewportAnchorY", 100); 63 region.width = 42;
47 run("region.regionAnchorX = invalidPercentageValues[index]"); 64 assert_equals(region.width, 42);
48 testExpected("region.regionAnchorX", 0); 65 });
49 run("region.regionAnchorY = invalidPercentageValues[index]"); 66 </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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698