Update web-platform-tests to revision 58eb04cecbbec2e18531ab440225e38944a9c444

This commit is contained in:
Josh Matthews 2017-04-17 12:06:02 +10:00 committed by Anthony Ramine
parent 25e8bf69e6
commit 665817d2a6
35333 changed files with 1818077 additions and 16036 deletions

View file

@ -0,0 +1,66 @@
<!doctype html>
<title>VTTCue.align</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-align">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
document.body.appendChild(video);
var cue = new VTTCue(0, 1, 'text');
assert_true('align' in cue, 'align is not supported');
assert_equals(cue.align, 'center');
var track = document.createElement('track');
var t = track.track;
t.addCue(cue);
assert_equals(cue.align, 'center');
video.appendChild(track);
assert_equals(cue.align, 'center');
t.mode = 'showing';
assert_equals(cue.align, 'center');
cue.align = 'start';
assert_equals(cue.align, 'start');
cue.align = 'end';
assert_equals(cue.align, 'end');
['start\u0000', 'centre', 'middle'].forEach(function(invalid) {
cue.align = invalid;
assert_equals(cue.align, 'end');
});
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var video = document.createElement('video');
document.body.appendChild(video);
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c1 = t.track.cues[0];
var c2 = t.track.cues[1];
var c3 = t.track.cues[2];
var c4 = t.track.cues[3];
assert_equals(c1.align, 'center');
assert_equals(c2.align, 'start');
assert_equals(c3.align, 'center');
assert_equals(c4.align, 'end');
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 align:start\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 align:center\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 align:end\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,3 @@
{
"region.html": "regions"
}

View file

@ -0,0 +1,49 @@
<!doctype html>
<title>VTTCue()</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-vttcue">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function() {
var cue = new VTTCue(3, 12, 'foo bar');
assert_equals(cue.startTime, 3);
assert_equals(cue.endTime, 12);
assert_equals(cue.text, 'foo bar');
assert_equals(cue.id, '');
assert_equals(cue.region, null);
assert_equals(cue.pauseOnExit, false);
assert_equals(cue.snapToLines, true);
assert_equals(cue.line, 'auto');
assert_equals(cue.lineAlign, 'start');
assert_equals(cue.position, 'auto');
assert_equals(cue.positionAlign, 'auto');
assert_equals(cue.size, 100);
assert_equals(cue.align, 'center');
}, document.title + ', initial values');
test(function() {
var cue = new VTTCue(-1, 12, 'foo bar');
assert_equals(cue.startTime, -1);
assert_equals(cue.endTime, 12);
}, document.title + ', bad start time');
test(function() {
var cue = new VTTCue(2, -1, 'foo bar');
assert_equals(cue.startTime, 2);
assert_equals(cue.endTime, -1);
}, document.title + ', bad end time');
test(function() {
var cue = new VTTCue(3, 12, '<i>foo bar</i>');
var frag = cue.getCueAsHTML();
assert_equals(frag.childNodes.length, 1);
assert_equals(frag.childNodes[0].localName, 'i');
assert_equals(frag.childNodes[0].textContent, 'foo bar');
}, document.title + ', text formatting');
</script>

View file

@ -0,0 +1,93 @@
<!doctype html>
<title>VTTCue.getCueAsHTML()</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-getcueashtml">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
var t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
var c1 = new VTTCue(0, 1, '<c></c><c.a.b></c><i></i><b></b><u></u><ruby><rt></rt></ruby><v></v><v a b></v><1:00:00.500>x\0');
t1.addCue(c1);
window.frag = c1.getCueAsHTML();
assert_equals(frag.childNodes.length, 10, 'childNodes.length');
assert_true(frag instanceof DocumentFragment, 'getCueAsHTML() should return DocumentFragment');
}, document.title+', creating the cue');
test(function(){
assert_equals(frag.childNodes[0].namespaceURI, 'http://www.w3.org/1999/xhtml', 'namespaceURI');
assert_equals(frag.childNodes[0].localName, 'span', 'localName');
assert_equals(frag.childNodes[0].attributes.length, 0, 'attributes');
assert_false(frag.childNodes[0].hasChildNodes(), 'hasChildNodes()');
assert_true(frag.childNodes[0] instanceof HTMLElement, 'instanceof');
}, document.title+', <c>');
test(function(){
assert_equals(frag.childNodes[1].namespaceURI, 'http://www.w3.org/1999/xhtml', 'namespaceURI');
assert_equals(frag.childNodes[1].localName, 'span', 'localName');
assert_equals(frag.childNodes[1].attributes.length, 1, 'attributes');
assert_equals(frag.childNodes[1].getAttributeNS('', 'class'), 'a b', 'class attribute');
assert_false(frag.childNodes[1].hasChildNodes(), 'hasChildNodes()');
assert_true(frag.childNodes[1] instanceof HTMLElement, 'instanceof');
}, document.title+', <c.a.b>');
test(function(){
assert_equals(frag.childNodes[2].namespaceURI, 'http://www.w3.org/1999/xhtml', 'namespaceURI');
assert_equals(frag.childNodes[2].localName, 'i', 'localName');
assert_equals(frag.childNodes[2].attributes.length, 0, 'attributes');
assert_false(frag.childNodes[2].hasChildNodes(), 'hasChildNodes()');
assert_true(frag.childNodes[2] instanceof HTMLElement, 'instanceof');
}, document.title+', <i>');
test(function(){
assert_equals(frag.childNodes[3].namespaceURI, 'http://www.w3.org/1999/xhtml', 'namespaceURI');
assert_equals(frag.childNodes[3].localName, 'b', 'localName');
assert_equals(frag.childNodes[3].attributes.length, 0, 'attributes');
assert_false(frag.childNodes[3].hasChildNodes(), 'hasChildNodes()');
assert_true(frag.childNodes[3] instanceof HTMLElement, 'instanceof');
}, document.title+', <b>');
test(function(){
assert_equals(frag.childNodes[4].namespaceURI, 'http://www.w3.org/1999/xhtml', 'namespaceURI');
assert_equals(frag.childNodes[4].localName, 'u', 'localName');
assert_equals(frag.childNodes[4].attributes.length, 0, 'attributes');
assert_false(frag.childNodes[4].hasChildNodes(), 'hasChildNodes()');
assert_true(frag.childNodes[4] instanceof HTMLElement, 'instanceof');
}, document.title+', <u>');
test(function(){
assert_equals(frag.childNodes[5].namespaceURI, 'http://www.w3.org/1999/xhtml', 'namespaceURI');
assert_equals(frag.childNodes[5].localName, 'ruby', 'localName');
assert_equals(frag.childNodes[5].attributes.length, 0, 'attributes');
assert_true(frag.childNodes[5].hasChildNodes(), 'hasChildNodes()');
assert_true(frag.childNodes[5] instanceof HTMLElement, 'instanceof');
}, document.title+', <ruby>');
test(function(){
assert_equals(frag.childNodes[5].firstChild.namespaceURI, 'http://www.w3.org/1999/xhtml', 'namespaceURI');
assert_equals(frag.childNodes[5].firstChild.localName, 'rt', 'localName');
assert_equals(frag.childNodes[5].firstChild.attributes.length, 0, 'attributes');
assert_false(frag.childNodes[5].firstChild.hasChildNodes(), 'hasChildNodes()');
assert_true(frag.childNodes[5].firstChild instanceof HTMLElement, 'instanceof');
}, document.title+', <rt>');
test(function(){
assert_equals(frag.childNodes[6].namespaceURI, 'http://www.w3.org/1999/xhtml', 'namespaceURI');
assert_equals(frag.childNodes[6].localName, 'span', 'localName');
assert_equals(frag.childNodes[6].attributes.length, 1, 'attributes');
assert_equals(frag.childNodes[6].getAttributeNS('', 'title'), '', 'title attribute');
assert_false(frag.childNodes[6].hasChildNodes(), 'hasChildNodes()');
assert_true(frag.childNodes[6] instanceof HTMLElement, 'instanceof');
}, document.title+', <v>');
test(function(){
assert_equals(frag.childNodes[7].namespaceURI, 'http://www.w3.org/1999/xhtml', 'namespaceURI');
assert_equals(frag.childNodes[7].localName, 'span', 'localName');
assert_equals(frag.childNodes[7].attributes.length, 1, 'attributes');
assert_equals(frag.childNodes[7].getAttributeNS('', 'title'), 'a b', 'title attribute');
assert_false(frag.childNodes[7].hasChildNodes(), 'hasChildNodes()');
assert_true(frag.childNodes[7] instanceof HTMLElement, 'instanceof');
}, document.title+', <v a b>');
test(function(){
assert_equals(frag.childNodes[8].target, 'timestamp', 'target');
assert_equals(frag.childNodes[8].data, '01:00:00.500', 'data');
assert_true(frag.childNodes[8] instanceof ProcessingInstruction, 'instanceof');
}, document.title+', <1:00:00.500>');
test(function(){
assert_equals(frag.childNodes[9].data, 'x\0', 'data');
assert_true(frag.childNodes[9] instanceof Text, 'instanceof');
}, document.title+', x\\0');
</script>

View file

@ -0,0 +1,64 @@
<!doctype html>
<title>VTTCue.line</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-line">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
document.body.appendChild(video);
var c1 = new VTTCue(0, 1, 'text1');
assert_true('line' in c1, 'line is not supported');
assert_equals(c1.line, "auto");
var track = document.createElement('track');
var t = track.track;
t.addCue(c1);
assert_equals(c1.line, "auto");
video.appendChild(track);
assert_equals(c1.line, "auto");
t.mode = 'showing';
assert_equals(c1.line, "auto");
var c2 = new VTTCue(0, 1, 'text2');
var track2 = document.createElement('track');
var t2 = track2.track;
t2.addCue(c2);
assert_equals(c2.line, "auto");
video.appendChild(track2);
t2.mode = 'showing';
assert_equals(c2.line, "auto");
assert_equals(c1.line, "auto");
c1.line = -5;
assert_equals(c1.line, -5);
assert_equals(c2.line, "auto");
c1.line = 0;
c1.snapToLines = false;
assert_equals(c1.line, 0);
assert_equals(c2.line, "auto");
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var video = document.createElement('video');
document.body.appendChild(video);
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c1 = t.track.cues[0];
var c2 = t.track.cues[1];
var c3 = t.track.cues[2];
assert_equals(c1.line, "auto");
assert_equals(c2.line, 0);
assert_equals(c3.line, 0);
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 line:0\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 line:0%\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,39 @@
<!doctype html>
<title>VTTCue.lineAlign</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-linealign">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
document.body.appendChild(video);
var cue = new VTTCue(0, 1, 'text');
assert_true('lineAlign' in cue, 'lineAlign is not supported');
assert_equals(cue.lineAlign, 'start');
var track = document.createElement('track');
var t = track.track;
t.addCue(cue);
assert_equals(cue.lineAlign, 'start');
video.appendChild(track);
assert_equals(cue.lineAlign, 'start');
t.mode = 'showing';
assert_equals(cue.lineAlign, 'start');
cue.lineAlign = 'center';
assert_equals(cue.lineAlign, 'center');
cue.lineAlign = 'end';
assert_equals(cue.lineAlign, 'end');
['start\u0000', 'centre', 'middle'].forEach(function(invalid) {
cue.lineAlign = invalid;
assert_equals(cue.lineAlign, 'end');
});
}, document.title+', script-created cue');
</script>

View file

@ -0,0 +1,32 @@
<!doctype html>
<title>VTTCue.position</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-position">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var cue = new VTTCue(0, 1, 'text');
assert_true('position' in cue, 'position is not supported');
cue.position = 'auto';
assert_equals(cue.position, 'auto');
for (i = 0; i <= 100; i++) {
cue.position = i;
assert_equals(cue.position, i);
}
[-1, -100, -101, 101, 200, 201].forEach(function(invalid) {
assert_throws('IndexSizeError', function() {
cue.position = invalid;
});
});
cue.position = 1.5;
assert_equals(cue.position, 1.5);
cue.position = 'auto';
assert_equals(cue.position, 'auto');
}, document.title+', script-created cue');
</script>

View file

@ -0,0 +1,23 @@
<!doctype html>
<title>VTTCue.positionAlign</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-positionalign">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var cue = new VTTCue(0, 1, 'text');
assert_true('positionAlign' in cue, 'positionAlign is not supported');
['line-left', 'center', 'line-right', 'auto'].forEach(function(valid) {
cue.positionAlign = valid;
assert_equals(cue.positionAlign, valid);
});
cue.positionAlign = 'center';
['auto\u0000', 'centre', 'middle'].forEach(function(invalid) {
cue.positionAlign = invalid;
assert_equals(cue.positionAlign, 'center');
});
}, document.title+', script-created cue');
</script>

View file

@ -0,0 +1,38 @@
<!doctype html>
<title>VTTCue.region</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-region">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
document.body.appendChild(video);
var cue = new VTTCue(0, 1, 'text');
assert_true('region' in cue, 'region is not supported');
assert_equals(cue.region, null);
var track = document.createElement('track');
var t = track.track;
t.addCue(cue);
assert_equals(cue.region, null);
video.appendChild(track);
assert_equals(cue.region, null);
t.mode = 'showing';
assert_equals(cue.region, null);
var region = new VTTRegion();
cue.region = region;
assert_equals(cue.region, region);
cue.region = 'foo';
assert_equals(cue.region, region);
cue.region = null;
assert_equals(cue.region, null);
}, document.title+', script-created cue');
</script>

View file

@ -0,0 +1,26 @@
<!doctype html>
<title>VTTCue.size</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-size">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var cue = new VTTCue(0, 1, 'text');
assert_true('size' in cue, 'size is not supported');
for (i = 0; i <= 100; i++) {
cue.size = i;
assert_equals(cue.size, i);
}
[-1, -100, -101, 101, 200, 201].forEach(function(invalid) {
assert_throws('IndexSizeError', function() {
cue.size = invalid;
});
});
cue.size = 1.5;
assert_equals(cue.size, 1.5);
}, document.title+', script-created cue');
</script>

View file

@ -0,0 +1,99 @@
<!doctype html>
<title>VTTCue.snapToLines</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-snaptolines">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var c1 = new VTTCue(0, 1, 'text1');
assert_true('snapToLines' in c1, 'snapToLines is not supported');
assert_true(c1.snapToLines);
c1.line = 101;
c1.snapToLines = false;
assert_false(c1.snapToLines);
c1.snapToLines = true;
assert_true(c1.snapToLines);
c1.line = -1;
c1.snapToLines = false;
assert_false(c1.snapToLines);
c1.snapToLines = true;
assert_true(c1.snapToLines);
c1.line = 0;
c1.snapToLines = false;
assert_false(c1.snapToLines);
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c1 = t.track.cues[0];
assert_true(c1.snapToLines);
c1.line = 101;
c1.snapToLines = false;
assert_false(c1.snapToLines);
c1.snapToLines = true;
assert_true(c1.snapToLines);
c1.line = -1;
c1.snapToLines = false;
assert_false(c1.snapToLines);
c1.snapToLines = true;
assert_true(c1.snapToLines);
c1.line = 0;
c1.snapToLines = false;
assert_false(c1.snapToLines);
var c2 = t.track.cues[1];
assert_true(c2.snapToLines);
c2.line = 101;
c2.snapToLines = false;
assert_false(c2.snapToLines);
c2.snapToLines = true;
assert_true(c2.snapToLines);
c2.line = -1;
c2.snapToLines = false;
assert_false(c2.snapToLines);
c2.snapToLines = true;
assert_true(c2.snapToLines);
c2.line = 0;
c2.snapToLines = false;
assert_false(c2.snapToLines);
var c3 = t.track.cues[2];
assert_false(c3.snapToLines);
c3.snapToLines = false;
assert_false(c3.snapToLines);
c3.snapToLines = true;
assert_true(c3.snapToLines);
c3.line = 101;
c3.snapToLines = false;
assert_false(c3.snapToLines);
c3.snapToLines = true;
assert_true(c3.snapToLines);
c3.line = -1;
c3.snapToLines = false;
assert_false(c3.snapToLines);
c3.snapToLines = true;
assert_true(c3.snapToLines);
c3.line = 0;
c3.snapToLines = false;
assert_false(c3.snapToLines);
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 line:0\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 line:0%\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,40 @@
<!doctype html>
<title>VTTCue.text</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-text">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var c1 = new VTTCue(0, 1, 'text1\r\n\n\u0000');
assert_true('text' in c1, 'text is not supported');
assert_equals(c1.text, 'text1\r\n\n\u0000');
c1.text = c1.text;
assert_equals(c1.text, 'text1\r\n\n\u0000');
c1.text = null;
assert_equals(c1.text, 'null');
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c = t.track.cues;
assert_equals(c[0].text, '');
assert_equals(c[1].text, 'test');
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\n'+
'\n\nfoobar\n00:00:00.000 --> 00:00:00.001\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,56 @@
<!doctype html>
<title>VTTCue.vertical</title>
<link rel="help" href="https://w3c.github.io/webvtt/#dom-vttcue-vertical">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
setup(function(){
window.video = document.createElement('video');
window.t1 = video.addTextTrack('subtitles');
document.body.appendChild(video);
});
test(function(){
var video = document.createElement('video');
document.body.appendChild(video);
var c1 = new VTTCue(0, 1, 'text1');
assert_true('vertical' in c1, 'vertical is not supported');
assert_equals(c1.vertical, '');
var track = document.createElement('track');
var t = track.track;
t.addCue(c1);
assert_equals(c1.vertical, '');
video.appendChild(track);
assert_equals(c1.vertical, '');
t.mode = 'showing';
assert_equals(c1.vertical, '');
c1.vertical = 'rl';
assert_equals(c1.vertical, 'rl');
c1.vertical = 'lr';
assert_equals(c1.vertical, 'lr');
c1.vertical = 'rl\u0000';
assert_equals(c1.vertical, 'lr');
}, document.title+', script-created cue');
var t_parsed = async_test(document.title+', parsed cue');
t_parsed.step(function(){
var t = document.createElement('track');
t.onload = this.step_func(function(){
var c1 = t.track.cues[0];
var c2 = t.track.cues[1];
var c3 = t.track.cues[2];
assert_equals(c1.vertical, '');
assert_equals(c2.vertical, 'rl');
assert_equals(c3.vertical, 'lr');
this.done();
});
t.onerror = this.step_func(function() {
assert_unreached('got error event');
});
t.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:00.001\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 vertical:rl\ntest\n\n'+
'00:00:00.000 --> 00:00:00.001 vertical:lr\ntest');
t.track.mode = 'showing';
video.appendChild(t);
});
</script>

View file

@ -0,0 +1,18 @@
<!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_equals(region.width, 100);
assert_equals(region.lines, 3);
assert_equals(region.regionAnchorX, 0);
assert_equals(region.regionAnchorY, 100);
assert_equals(region.viewportAnchorX, 0);
assert_equals(region.viewportAnchorY, 100);
assert_equals(region.scroll, '');
}, document.title + ' initial values');
</script>

View file

@ -0,0 +1,37 @@
<!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://heycam.github.io/webidl/#abstract-opdef-converttoint
[[0, 0],
[-0, 0],
[101, 101],
[2147483647, 2147483647],
[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);
});
[-1, -100, -2147483648, 2147483648 /* wraps to -2147483648 */].forEach(function (invalid) {
assert_throws('IndexSizeError', function() {
region.lines = invalid;
}, invalid);
});
}, document.title + ' script-created region');
</script>

View file

@ -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('IndexSizeError', function() {
region.regionAnchorX = invalid;
});
});
}, document.title + ' script-created region');
</script>

View file

@ -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('IndexSizeError', function() {
region.regionAnchorY = invalid;
});
});
}, document.title + ' script-created region');
</script>

View file

@ -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>

View file

@ -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('IndexSizeError', function() {
region.viewportAnchorX = invalid;
});
});
}, document.title + ' script-created region');
</script>

View file

@ -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('IndexSizeError', function() {
region.viewportAnchorY = invalid;
});
});
}, document.title + ' script-created region');
</script>

View file

@ -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('IndexSizeError', function() {
region.width = invalid;
});
});
}, document.title + ' script-created region');
</script>

View file

@ -0,0 +1,5 @@
{
":subcategories": ["VTTCue/categories.json"],
"VTTCue/*": "cues",
"VTTRegion/*": "regions"
}

View file

@ -0,0 +1,165 @@
<!doctype html>
<meta charset=utf-8>
<title>WebVTT IDL tests</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>
<h1>WebVTT IDL tests</h1>
<div id=log></div>
<script type=text/plain id=untested>
// HTML
interface TextTrackCue : EventTarget {
readonly attribute TextTrack? track;
attribute DOMString id;
attribute double startTime;
attribute double endTime;
attribute boolean pauseOnExit;
attribute EventHandler onenter;
attribute EventHandler onexit;
};
[TreatNonObjectAsNull]
callback EventHandlerNonNull = any (Event event);
typedef EventHandlerNonNull? EventHandler;
// DOM
[Exposed=(Window,Worker)]
interface EventTarget {
void addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options);
void removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options);
boolean dispatchEvent(Event event);
};
callback interface EventListener {
void handleEvent(Event event);
};
dictionary EventListenerOptions {
boolean capture = false;
};
dictionary AddEventListenerOptions : EventListenerOptions {
boolean passive = false;
boolean once = false;
};
[Constructor,
Exposed=Window]
interface DocumentFragment : Node {
};
[Exposed=Window]
interface Node : EventTarget {
const unsigned short ELEMENT_NODE = 1;
const unsigned short ATTRIBUTE_NODE = 2;
const unsigned short TEXT_NODE = 3;
const unsigned short CDATA_SECTION_NODE = 4;
const unsigned short ENTITY_REFERENCE_NODE = 5; // historical
const unsigned short ENTITY_NODE = 6; // historical
const unsigned short PROCESSING_INSTRUCTION_NODE = 7;
const unsigned short COMMENT_NODE = 8;
const unsigned short DOCUMENT_NODE = 9;
const unsigned short DOCUMENT_TYPE_NODE = 10;
const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
const unsigned short NOTATION_NODE = 12; // historical
readonly attribute unsigned short nodeType;
readonly attribute DOMString nodeName;
readonly attribute USVString baseURI;
readonly attribute boolean isConnected;
readonly attribute Document? ownerDocument;
Node getRootNode(optional GetRootNodeOptions options);
readonly attribute Node? parentNode;
readonly attribute Element? parentElement;
boolean hasChildNodes();
[SameObject] readonly attribute NodeList childNodes;
readonly attribute Node? firstChild;
readonly attribute Node? lastChild;
readonly attribute Node? previousSibling;
readonly attribute Node? nextSibling;
[CEReactions] attribute DOMString? nodeValue;
[CEReactions] attribute DOMString? textContent;
[CEReactions] void normalize();
[CEReactions, NewObject] Node cloneNode(optional boolean deep = false);
boolean isEqualNode(Node? otherNode);
boolean isSameNode(Node? otherNode); // historical alias of ===
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
unsigned short compareDocumentPosition(Node other);
boolean contains(Node? other);
DOMString? lookupPrefix(DOMString? namespace);
DOMString? lookupNamespaceURI(DOMString? prefix);
boolean isDefaultNamespace(DOMString? namespace);
[CEReactions] Node insertBefore(Node node, Node? child);
[CEReactions] Node appendChild(Node node);
[CEReactions] Node replaceChild(Node node, Node child);
[CEReactions] Node removeChild(Node child);
};
dictionary GetRootNodeOptions {
boolean composed = false;
};
</script>
<script type=text/plain id=tested>
enum AutoKeyword { "auto" };
typedef (double or AutoKeyword) LineAndPositionSetting;
enum DirectionSetting { "" /* horizontal */, "rl", "lr" };
enum LineAlignSetting { "start", "center", "end" };
enum PositionAlignSetting { "line-left", "center", "line-right", "auto" };
enum AlignSetting { "start", "center", "end", "left", "right" };
[Constructor(double startTime, double endTime, DOMString text)]
interface VTTCue : TextTrackCue {
attribute VTTRegion? region;
attribute DirectionSetting vertical;
attribute boolean snapToLines;
attribute LineAndPositionSetting line;
attribute LineAlignSetting lineAlign;
attribute LineAndPositionSetting position;
attribute PositionAlignSetting positionAlign;
attribute double size;
attribute AlignSetting align;
attribute DOMString text;
DocumentFragment getCueAsHTML();
};
enum ScrollSetting { "" /* none */, "up" };
[Constructor]
interface VTTRegion {
attribute double width;
attribute long lines;
attribute double regionAnchorX;
attribute double regionAnchorY;
attribute double viewportAnchorX;
attribute double viewportAnchorY;
attribute ScrollSetting scroll;
};
</script>
<script>
"use strict";
setup(function() {
var idlArray = new IdlArray();
idlArray.add_untested_idls(document.getElementById("untested").textContent);
idlArray.add_idls(document.getElementById("tested").textContent);
idlArray.add_objects({
VTTCue: ['new VTTCue(0, 0, "")'],
VTTRegion: ['new VTTRegion()'],
});
idlArray.test();
});
</script>