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

Unified 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: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/track/regions-webvtt/vtt-region-constructor.html
diff --git a/third_party/WebKit/LayoutTests/media/track/regions-webvtt/vtt-region-constructor.html b/third_party/WebKit/LayoutTests/media/track/regions-webvtt/vtt-region-constructor.html
index 0171e841709a3dd84b8aac6498b73cae6159133c..ab322a28fd1c6e00eafde1b296eaec87a1a41640 100644
--- a/third_party/WebKit/LayoutTests/media/track/regions-webvtt/vtt-region-constructor.html
+++ b/third_party/WebKit/LayoutTests/media/track/regions-webvtt/vtt-region-constructor.html
@@ -1,82 +1,54 @@
<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
- <script src=../../media-file.js></script>
- <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956
- (Please avoid writing new tests using video-test.js) -->
- <script src=../../video-test.js></script>
- <script>
- var region;
- var invalidPercentageValues;
-
- function startTest()
- {
- if (!window.VTTRegion) {
- failTest();
- return;
- }
-
- region = new VTTRegion();
-
- consoleWrite("** Test instanceof VTTRegion. **");
- testExpected("region instanceof VTTRegion", true);
-
- consoleWrite("** Test the default indexs of a region. **");
- testExpected("region.track", null);
- testExpected("region.scroll", "");
- testExpected("region.viewportAnchorX", 0);
- testExpected("region.viewportAnchorY", 100);
- testExpected("region.regionAnchorX", 0);
- testExpected("region.regionAnchorY", 100);
- testExpected("region.height", 3);
- testExpected("region.width", 100);
-
- consoleWrite("<br>** Test that incorrect mutation keeps previous valid values. **");
- run("region.scroll = 'invalid-scroll-value'");
- testExpected("region.scroll", "");
-
- invalidPercentageValues = [-1, 101, -Infinity, Infinity, NaN];
- for (index in invalidPercentageValues) {
- consoleWrite("<br>Invalid percentage value: " + invalidPercentageValues[index]);
- run("region.viewportAnchorX = invalidPercentageValues[index]");
- testExpected("region.viewportAnchorX", 0);
- run("region.viewportAnchorY = invalidPercentageValues[index]");
- testExpected("region.viewportAnchorY", 100);
- run("region.regionAnchorX = invalidPercentageValues[index]");
- testExpected("region.regionAnchorX", 0);
- run("region.regionAnchorY = invalidPercentageValues[index]");
- testExpected("region.regionAnchorY", 100);
- run("region.width = invalidPercentageValues[index]");
- testExpected("region.width", 100);
- }
-
- run("region.height = -1");
- testExpected("region.height", 3);
-
- consoleWrite("<br>** Test that proper mutation keeps assigned value. **");
- run("region.height = 130");
- testExpected("region.height", 130);
-
- run("region.viewportAnchorX = 64");
- testExpected("region.viewportAnchorX", 64);
- run("region.viewportAnchorY = 32");
- testExpected("region.viewportAnchorY", 32);
- run("region.regionAnchorX = 16");
- testExpected("region.regionAnchorX", 16);
- run("region.regionAnchorY = 8");
- testExpected("region.regionAnchorY", 8);
-
- run("region.width = 42");
- testExpected("region.width", 42);
-
- endTest();
- }
-
- </script>
- </head>
- <body onload="startTest()">
- <p>Tests the constructor and mutation of VTTRegion.</p>
- </body>
-</html>
+<title>Tests the constructor and mutation of VTTRegion.</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script>
+test(function() {
+ 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.
+
+ var region = new VTTRegion();
+ assert_true(region instanceof VTTRegion, 'instanceof');
+
+ assert_equals(region.track, null);
+ assert_equals(region.scroll, "");
+ assert_equals(region.viewportAnchorX, 0);
+ assert_equals(region.viewportAnchorY, 100);
+ assert_equals(region.regionAnchorX, 0);
+ assert_equals(region.regionAnchorY, 100);
+ assert_equals(region.height, 3);
+ assert_equals(region.width, 100);
+
+ assert_throws(new SyntaxError, function() { region.scroll = 'invalid-scroll-value'; });
+ assert_equals(region.scroll, "");
+
+ var invalidPercentageValues = [-1, 101, -Infinity, Infinity, NaN];
+ for (index in invalidPercentageValues) {
+ assert_throws(new IndexSizeError, function() { region.viewportAnchorX = invalidPercentageValues[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
+ assert_equals(region.viewportAnchorX, 0);
+ assert_throws(new IndexSizeError, function() { region.viewportAnchorY = invalidPercentageValues[index]; });
+ assert_equals(region.viewportAnchorY, 100);
+ assert_throws(new IndexSizeError, function() { region.regionAnchorX = invalidPercentageValues[index]; });
+ assert_equals(region.regionAnchorX, 0);
+ assert_throws(new IndexSizeError, function() { region.regionAnchorY = invalidPercentageValues[index]; });
+ assert_equals(region.regionAnchorY, 100);
+ assert_throws(new IndexSizeError, function() { region.width = invalidPercentageValues[index]; });
+ assert_equals(region.width, 100);
+ }
+
+ assert_throws(new IndexSizeError, function() { region.height = -1; });
+ assert_equals(region.height, 3);
+
+ region.height = 130;
+ assert_equals(region.height, 130);
+ region.viewportAnchorX = 64;
+ assert_equals(region.viewportAnchorX, 64);
+ region.viewportAnchorY = 32;
+ assert_equals(region.viewportAnchorY, 32);
+ region.regionAnchorX = 16;
+ assert_equals(region.regionAnchorX, 16);
+ region.regionAnchorY = 8;
+ assert_equals(region.regionAnchorY, 8);
+ region.width = 42;
+ assert_equals(region.width, 42);
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698