summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webvtt/api/VTTRegion
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webvtt/api/VTTRegion')
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/constructor.html67
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/id.html21
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/lines.html36
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/non-visible-cue-with-region.html26
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/regionAnchorX.html26
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/regionAnchorY.html26
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/scroll.html27
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/viewportAnchorX.html26
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/viewportAnchorY.html26
-rw-r--r--testing/web-platform/tests/webvtt/api/VTTRegion/width.html26
10 files changed, 307 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/constructor.html b/testing/web-platform/tests/webvtt/api/VTTRegion/constructor.html
new file mode 100644
index 0000000000..a427f4f7d6
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/constructor.html
@@ -0,0 +1,67 @@
+<!doctype html>
+<title>VTTRegion()</title>
+<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-vttregion">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var region = new VTTRegion();
+ assert_true(region instanceof VTTRegion, "instanceof");
+
+ 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.lines, 3);
+ assert_equals(region.width, 100);
+}, document.title + " initial values");
+
+test(function() {
+ var region = new VTTRegion();
+ region.scroll = "invalid-scroll-value";
+ assert_equals(region.scroll, "");
+
+ checkValues([-1, 101], "IndexSizeError");
+ checkValues([-Infinity, Infinity, NaN], TypeError);
+
+ function assert_throws_something(error, func) {
+ if (typeof error == "string") {
+ assert_throws_dom(error, func);
+ } else {
+ assert_throws_js(error, func);
+ }
+ }
+
+ function checkValues(invalidValues, exception) {
+ for (var value of invalidValues) {
+ assert_throws_something(exception, function() { region.viewportAnchorX = value; });
+ assert_equals(region.viewportAnchorX, 0);
+ assert_throws_something(exception, function() { region.viewportAnchorY = value; });
+ assert_equals(region.viewportAnchorY, 100);
+ assert_throws_something(exception, function() { region.regionAnchorX = value; });
+ assert_equals(region.regionAnchorX, 0);
+ assert_throws_something(exception, function() { region.regionAnchorY = value; });
+ assert_equals(region.regionAnchorY, 100);
+ assert_throws_something(exception, function() { region.width = value; });
+ assert_equals(region.width, 100);
+ }
+ }
+
+ assert_equals(region.lines, 3);
+
+ region.lines = 130;
+ assert_equals(region.lines, 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);
+}, document.title + " mutations");
+</script>
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/id.html b/testing/web-platform/tests/webvtt/api/VTTRegion/id.html
new file mode 100644
index 0000000000..1eabac2d16
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/id.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<title>VTTRegion.id</title>
+<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-id">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var region = new VTTRegion();
+ assert_true('id' in region, 'id is not supported');
+
+ assert_equals(region.id, '', 'initial value');
+
+ region.id = '1';
+ assert_equals(region.id, '1', 'value after setting to "1"');
+
+ region.id = '';
+ assert_equals(region.id, '', 'value after setting to the empty string');
+
+}, document.title + ' script-created region');
+</script>
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/lines.html b/testing/web-platform/tests/webvtt/api/VTTRegion/lines.html
new file mode 100644
index 0000000000..9bde9a1947
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/lines.html
@@ -0,0 +1,36 @@
+<!doctype html>
+<title>VTTRegion.lines</title>
+<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-lines">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var region = new VTTRegion();
+ assert_true('lines' in region, 'lines is not supported');
+
+ for (var i = 1; i <= 100; i++) {
+ region.lines = i;
+ assert_equals(region.lines, i);
+ }
+
+ // https://webidl.spec.whatwg.org/#abstract-opdef-converttoint
+ [[0, 0],
+ [-0, 0],
+ [-1, 4294967295],
+ [-100, 4294967196],
+ [101, 101],
+ [-2147483648, 2147483648],
+ [2147483647, 2147483647],
+ [2147483648, 2147483648],
+ [NaN, 0],
+ [Infinity, 0],
+ [-Infinity, 0]].forEach(function (pair) {
+ var input = pair[0];
+ var expected = pair[1];
+ region.lines = input;
+ assert_equals(region.lines, expected);
+ });
+
+}, document.title + ' script-created region');
+</script>
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/non-visible-cue-with-region.html b/testing/web-platform/tests/webvtt/api/VTTRegion/non-visible-cue-with-region.html
new file mode 100644
index 0000000000..5a48e46520
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/non-visible-cue-with-region.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<title>Box-less VTTCue attached to VTTRegion</title>
+<script src="/common/media.js"></script>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<video></video>
+<script>
+setup(function() {
+ window.video = document.querySelector('video');
+ video.src = getVideoURI('/media/test');
+});
+async_test(function(t) {
+ let track = video.addTextTrack('subtitles');
+ let cue = new VTTCue(0, 1, '');
+ cue.region = new VTTRegion();
+ cue.onexit = t.step_func_done(function() {
+ video.pause();
+ });
+ track.addCue(cue);
+ video.onloadedmetadata = t.step_func(function() {
+ video.currentTime = 0.8;
+ video.play();
+ });
+ video.onended = t.unreached_func('test ends before video');
+});
+</script>
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/regionAnchorX.html b/testing/web-platform/tests/webvtt/api/VTTRegion/regionAnchorX.html
new file mode 100644
index 0000000000..f7663366cb
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/regionAnchorX.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>VTTRegion.regionAnchorX</title>
+<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-regionanchorx">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var region = new VTTRegion();
+ assert_true('regionAnchorX' in region, 'regionAnchorX is not supported');
+
+ for (var i = 0; i <= 100; i++) {
+ region.regionAnchorX = i;
+ assert_equals(region.regionAnchorX, i);
+ }
+
+ region.regionAnchorX = 1.5;
+ assert_equals(region.regionAnchorX, 1.5);
+
+ [-1, -100, -150, 101, 200, 250].forEach(function (invalid) {
+ assert_throws_dom('IndexSizeError', function() {
+ region.regionAnchorX = invalid;
+ });
+ });
+}, document.title + ' script-created region');
+</script>
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/regionAnchorY.html b/testing/web-platform/tests/webvtt/api/VTTRegion/regionAnchorY.html
new file mode 100644
index 0000000000..174ff67890
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/regionAnchorY.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>VTTRegion.regionAnchorY</title>
+<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-regionanchory">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var region = new VTTRegion();
+ assert_true('regionAnchorY' in region, 'regionAnchorY is not supported');
+
+ for (var i = 0; i <= 100; i++) {
+ region.regionAnchorY = i;
+ assert_equals(region.regionAnchorY, i);
+ }
+
+ region.regionAnchorX = 1.5;
+ assert_equals(region.regionAnchorX, 1.5);
+
+ [-1, -100, -150, 101, 200, 250].forEach(function (invalid) {
+ assert_throws_dom('IndexSizeError', function() {
+ region.regionAnchorY = invalid;
+ });
+ });
+}, document.title + ' script-created region');
+</script>
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/scroll.html b/testing/web-platform/tests/webvtt/api/VTTRegion/scroll.html
new file mode 100644
index 0000000000..63dc50ab45
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/scroll.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<title>VTTRegion.scroll</title>
+<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-scroll">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var region = new VTTRegion();
+ assert_true('scroll' in region, 'scroll is not supported');
+
+ region.scroll = '';
+ assert_equals(region.scroll, '');
+
+ region.scroll = 'up';
+ assert_equals(region.scroll, 'up');
+
+ region.scroll = 'down';
+ assert_equals(region.scroll, 'up');
+
+ region.scroll = '';
+ for (var invalid in ['left', 'right', 'center', 'top', 'bottom', 'down']) {
+ region.scroll = invalid;
+ assert_equals(region.scroll, '');
+ }
+}, document.title + ' script-created region');
+</script>
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/viewportAnchorX.html b/testing/web-platform/tests/webvtt/api/VTTRegion/viewportAnchorX.html
new file mode 100644
index 0000000000..0786585d46
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/viewportAnchorX.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>VTTRegion.viewportAnchorX</title>
+<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-viewportanchorx">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var region = new VTTRegion();
+ assert_true('viewportAnchorX' in region, 'viewportAnchorX is not supported');
+
+ for (var i = 0; i <= 100; i++) {
+ region.viewportAnchorX = i;
+ assert_equals(region.viewportAnchorX, i);
+ }
+
+ region.viewportAnchorX = 1.5;
+ assert_equals(region.viewportAnchorX, 1.5);
+
+ [-1, -100, -150, 101, 200, 250].forEach(function (invalid) {
+ assert_throws_dom('IndexSizeError', function() {
+ region.viewportAnchorX = invalid;
+ });
+ });
+}, document.title + ' script-created region');
+</script>
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/viewportAnchorY.html b/testing/web-platform/tests/webvtt/api/VTTRegion/viewportAnchorY.html
new file mode 100644
index 0000000000..de43567b62
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/viewportAnchorY.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>VTTRegion.viewportAnchorY</title>
+<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-viewportanchory">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function() {
+ var region = new VTTRegion();
+ assert_true('viewportAnchorY' in region, 'viewportAnchorY is not supported');
+
+ for (var i = 0; i <= 100; i++) {
+ region.viewportAnchorY = i;
+ assert_equals(region.viewportAnchorY, i);
+ }
+
+ region.viewportAnchorY = 1.5;
+ assert_equals(region.viewportAnchorY, 1.5);
+
+ [-1, -100, -150, 101, 200, 250].forEach(function (invalid) {
+ assert_throws_dom('IndexSizeError', function() {
+ region.viewportAnchorY = invalid;
+ });
+ });
+}, document.title + ' script-created region');
+</script>
diff --git a/testing/web-platform/tests/webvtt/api/VTTRegion/width.html b/testing/web-platform/tests/webvtt/api/VTTRegion/width.html
new file mode 100644
index 0000000000..97c1c73956
--- /dev/null
+++ b/testing/web-platform/tests/webvtt/api/VTTRegion/width.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<title>VTTRegion.width</title>
+<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttregion-width">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+<script>
+test(function(){
+ var region = new VTTRegion();
+ assert_true('width' in region, 'width is not supported');
+
+ for (var i = 0; i <= 100; i++) {
+ region.width = i;
+ assert_equals(region.width, i);
+ }
+
+ region.width = 1.5;
+ assert_equals(region.width, 1.5);
+
+ [-1, -100, -150, 101, 200, 250].forEach(function (invalid) {
+ assert_throws_dom('IndexSizeError', function() {
+ region.width = invalid;
+ });
+ });
+}, document.title + ' script-created region');
+</script>