Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317

This commit is contained in:
Josh Matthews 2018-01-04 13:44:24 -05:00
parent aa199307c8
commit 2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions

View file

@ -0,0 +1,60 @@
<!doctype html>
<title>HTMLMediaElement.crossOrigin</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
var video = document.createElement('video');
assert_true('crossOrigin' in video);
});
test(function(){
var video = document.createElement('video');
assert_equals(video.crossOrigin, null);
}, document.title+', content attribute missing');
test(function(){
var video = document.createElement('video');
video.setAttribute('crossorigin', 'foo');
assert_equals(video.crossOrigin, 'anonymous');
}, document.title+', content attribute invalid value');
test(function(){
var video = document.createElement('video');
video.setAttribute('crossorigin', '');
assert_equals(video.crossOrigin, 'anonymous');
}, document.title+', content attribute empty string');
test(function(){
var video = document.createElement('video');
video.setAttribute('crossorigin', 'ANONYMOUS');
assert_equals(video.crossOrigin, 'anonymous');
}, document.title+', content attribute uppercase ANONYMOUS');
test(function(){
var video = document.createElement('video');
video.setAttribute('crossorigin', 'use-credentials');
assert_equals(video.crossOrigin, 'use-credentials');
}, document.title+', content attribute use-credentials');
test(function(){
var video = document.createElement('video');
video.crossOrigin = '';
assert_equals(video.getAttribute('crossorigin'), '');
}, document.title+', setting to empty string');
test(function(){
var video = document.createElement('video');
video.crossOrigin = null;
assert_false(video.hasAttribute('crossorigin'));
}, document.title+', setting to null');
test(function(){
var video = document.createElement('video');
video.crossOrigin = 'foo';
assert_equals(video.getAttribute('crossorigin'), 'foo');
}, document.title+', setting to invalid value');
test(function(){
var video = document.createElement('video');
video.crossOrigin = 'ANONYMOUS';
assert_equals(video.getAttribute('crossorigin'), 'ANONYMOUS');
}, document.title+', setting to uppercase ANONYMOUS');
test(function(){
var video = document.createElement('video');
video.crossOrigin = 'use-credentials';
assert_equals(video.getAttribute('crossorigin'), 'use-credentials');
}, document.title+', setting to use-credentials');
</script>

View file

@ -8,4 +8,11 @@ test(function(){
var track = document.createElement('track');
assert_equals(track.readyState, 0);
}, document.title + ' default value');
test(function(){
assert_equals(HTMLTrackElement.NONE, 0);
assert_equals(HTMLTrackElement.LOADING, 1);
assert_equals(HTMLTrackElement.LOADED, 2);
assert_equals(HTMLTrackElement.ERROR, 3);
}, document.title + ' values');
</script>

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>TextTrackCue constructor</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(function()
{
assert_not_equals(TextTrackCue, VTTCue);
}, "TextTrackCue and VTTCue are separate interfaces");
test(function()
{
assert_throws(new TypeError(), function()
{
new TextTrackCue(0, 0, "");
});
}, "TextTrackCue constructor should not be supported");
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
WEBVTT
Either one or both of positioning and alignment values are invalid.
1
00:00:00.000 --> 00:00:30.500 position:10% align: start
Bear is Coming!!!!!
Positioning on the left bottom, middle aligned,
because the alignment is mistyped.
2
00:00:31.000 --> 00:00:45.500 position:200% align:middle
I said Bear is coming!!!!
Positioning on the bottom middle, middle aligned,
because the positioning is off.
3
00:01:01.000 --> 00:02:00.500 position:-80% align:ends
I said Bear is coming now!!!!
Positioning on the bottom middle, middle aligned,
because both the alignment and positioning don't apply.

View file

@ -0,0 +1,20 @@
WEBVTT
Cues should position at different horizontal positions with different alignments.
1
00:00:00.000 --> 00:00:30.500 position:10% align:start
Bear is Coming!!!!!
Positioning on the left bottom, start aligned, and
first character rendering position is at 10% of width.
2
00:00:31.000 --> 00:00:45.500 position:20% align:middle
I said Bear is coming!!!!
Positioning on the bottom left, middle aligned, and
middle character rendering position of each line is at 20% of width.
3
00:01:01.000 --> 00:02:00.500 align:end position:80%
I said Bear is coming now!!!!
Positioning on the bottom right, end aligned, and
last character rendering position of each line is at 80% of width.

View file

@ -0,0 +1,21 @@
WEBVTT
One or more of line/text positioning and alignment values are invalid (settings are ignored).
1
00:00:00.000 --> 00:00:30.500 position: 0% align: start line: 0%
Bear is Coming!!!!!
None of the cue settings will be applied, just the default.
2
00:00:31.000 --> 00:00:01.500 position:0% align:end line:-30%
I said Bear is coming!!!!
The line position setting is ignored.
No text is visible though because it's off-screen at position
0 and the last character is at position 0%.
3
00:01:01.000 --> 00:01:30.000 line:-3 align:middler position:60%
I said Bear is coming now!!!!
Positioning on line 3 from the viewport bottom, middle aligned,
with middle character of cue at 60% width.
The alignment is ignored.

View file

@ -0,0 +1,28 @@
WEBVTT
Cues with valid alignment, line and text position settings.
1
00:00:00.000 --> 00:00:15.000 position:10% align:start line:0%
Bear is Coming!!!!!
Positioning on the top of the viewport at 10% horizontally,
start aligned.
00:00:15.500 --> 00:00:30.500 line:0 align:start
Bear is Coming!!!!!
This is line 0, middle aligned, first character at 50% width.
2
00:00:31.000 --> 00:00:45.500 position:80% line:80%
I said Bear is coming!!!!
Middle aligned, middle of cue's character is at 80% width and 80% height.
00:00:46.000 --> 00:01:00.500 line:5 align:end position:30%
I said Bear is coming!!!!
This is line 6 from the top of the video viewport,
end aligned with last character at 30% of viewport width.
3
00:01:01.000 --> 00:01:30.000 line:-3 align:middle position:60%
I said Bear is coming now!!!!
Positioning on line 3 from the viewport bottom, middle aligned,
with middle character of cue at 60% width.

View file

@ -0,0 +1,22 @@
WEBVTT
Cue alignment may only be start, middle, or end. These are all misspelled and so will default to middle.
1
00:00:00.000 --> 00:00:30.500 align:starta
Bear is Coming!!!!!
Erroneous alignment value -> middle.
2
00:00:31.000 --> 00:01:00.500 align:-start
I said Bear is coming!!!!
Erroneous alignment value --> middle.
3
00:01:01.000 --> 00:02:00.500 align: end
I said Bear is coming now!!!!
Erroneous alignment value with surplus whitespace --> middle.
4
00:02:01.000 --> 100:20:00.500 align:piugjk
I said Bear is coming now!!!!
Erroneous alignment value -> middle.

View file

@ -0,0 +1,22 @@
WEBVTT
Cue alignment may be start, middle, or end (default is middle).
1
00:00:00.000 --> 00:00:30.500 align:start
الدب قادم!!!!!
بدء محاذاته.
2
00:00:31.000 --> 00:01:00.500 align:middle
قلت الدب قادم!!
محاذاة الوسط.
3
00:01:01.000 --> 00:02:00.500 align:end
قلت الدب قادم الآن!!
محاذاة الغاية.
4
00:02:01.000 --> 100:20:00.500
قلت الدب قادم الآن!!
الافتراضية هي محاذاة الوسط.

View file

@ -0,0 +1,22 @@
WEBVTT
Cue alignment may be start, middle, or end (default is middle).
1
00:00:00.000 --> 00:00:30.500 align:start
Bear is Coming!!!!!
Start align.
2
00:00:31.000 --> 00:01:00.500 align:middle
I said Bear is coming!!!!
Middle align.
3
00:01:01.000 --> 00:02:00.500 align:end
I said Bear is coming now!!!!
End align.
4
00:02:01.000 --> 100:20:00.500
I said Bear is coming now!!!!
Default is middle alignment.

View file

@ -0,0 +1,10 @@
WEBVTT FILE
A BOM character at the start of a file should be ignored.
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:20:00.500
I said Bear is coming!!!!

View file

@ -0,0 +1,13 @@
WEBVTT
1
00:00:00.000 --> 00:00:00.300
Lorem
2
00:00:00.300 --> 00:00:00.700
ipsum
3
00:00:01.200 --> 00:00:01.500
dolor

View file

@ -0,0 +1,18 @@
WEBVTT
1
00:00:01.000 --> 00:00:02.000
Lorem ipsum dolor sit amet,
2
00:00:03.000 --> 00:00:04.000
consectetuer adipiscing elit,
3
00:00:05.000 --> 00:00:06.000
sed diam nonummy nibh euismod tincidunt
4
00:00:07.000 --> 00:00:08.000
ut laoreet dolore magna aliquam erat volutpat.

View file

@ -0,0 +1,18 @@
WEBVTT
1
00:00:00.000 --> 00:00:01.000
Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit</i> amet,
2
00:00:03.000 --> 00:00:04.000
consectetuer adipiscing elit,
3
00:00:05.000 --> 00:00:06.000
sed diam nonummy nibh euismod tincidunt
4
00:00:07.000 --> 00:00:08.000
ut laoreet dolore magna aliquam erat volutpat.

View file

@ -0,0 +1,18 @@
WEBVTT
1
00:00:00.000 --> 00:00:01.000
Lorem
2
00:00:01.000 --> 00:00:02.000
ipsum
3
00:00:02.000 --> 00:00:03.000
dolor
4
00:00:03.000 --> 00:00:04.000
sit

View file

@ -0,0 +1,17 @@
WEBVTT
Invalid <c> class markup.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
<c .black>Bear is Coming!!!!!</c>
The space signified an annotation start.
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
<c.red&large>I said Bear is coming!!!!</c>
Probably should only allow characters that CSS allows in class names.
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
I said <c.9red.upper+case>Bear is coming now</c>!!!!
Probably should only allow characters that CSS allows in class names.

View file

@ -0,0 +1,14 @@
WEBVTT
Cue text fragment with <c> class markup is mapped to HTML <span> element with CSS classes.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
<c.black>Bear is Coming!!!!!</c>
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
<c.green>I said Bear is coming!!!!</c>
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
I said <c.red.uppercase>Bear is coming now</c>!!!!

View file

@ -0,0 +1,14 @@
WEBVTT
Cue identifiers cannot contain the string "-->".
-->random_id
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
another random identifier-->
00:00:31.000 --> 00:01:00.500
I said Bear is coming!!!!
identifier-->too
00:01:01.000 --> 00:20:00.500
I said Bear is coming now!!!!

View file

@ -0,0 +1,18 @@
WEBVTT
Random text is accepted for cue identifiers.
random_id
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
another random identifier
00:00:31.000 --> 00:01:00.500
I said Bear is coming!!!!
identifier--too
00:01:01.000 --> 00:02:00.500
I said Bear is coming now!!!!
identifier--too
00:02:01.000 --> 00:03:00.500
Duplicate identifier

View file

@ -0,0 +1,14 @@
WEBVTT
Cue identifiers cannot contain "-->". Whole cue is ignored.
-->
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
-->
00:00:31.000 --> 00:01:00.500
I said Bear is coming!!!!
-->
00:01:01.000 --> 00:20:00.500
I said Bear is coming now!!!!

View file

@ -0,0 +1,11 @@
WEBVTT
Cues don't have to have identifiers.
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
00:00:31.000 --> 00:01:00.500
I said Bear is coming!!!!
00:01:01.000 --> 00:20:00.500
I said Bear is coming now!!!!

View file

@ -0,0 +1,6 @@
WEBVTT
00:00.000 --> 00:01.000
Valid cue 1
00:02.000 --> 00:03.000
Valid cue 2

View file

@ -0,0 +1,6 @@
WEBVTT
00:00.000 --> 00:01.000
Valid cue 1
00:02.000 --> 00:03.000
Valid cue 2

View file

@ -0,0 +1,9 @@
WEBVTT
00:00.000 --> 00:01.000
Valid cue 1
NOTE about something
NOTE or something else - maybe an identifier
00:02.000 --> 00:03.000
Valid cue 2

View file

@ -0,0 +1,18 @@
WEBVTT
Either size or alignment are invalid.
1
00:00:00.000 --> 00:00:30.500 size:100% align:@start
Bear is Coming!!!!!
Box for the cue is 100% of the video viewport width, alignment is ignored.
2
00:00:31.000 --> 00:01:00.500 size:-10% align:end
I said Bear is coming!!!!
Box for the cue is as big as the text, no line wrapping,
(except if viewport is too small) and end aligned.
3
00:01:01.000 --> 00:02:00.500 size:110% align:@end
I said Bear is coming now!!!!
Both cue size and alignment are ignored.

View file

@ -0,0 +1,19 @@
WEBVTT
Valid cue size with alignment settings.
1
00:00:00.000 --> 00:00:30.500 size:100% align:start
Bear is Coming!!!!!
Box for the cue is 100% of the video viewport width
and because of the start align, all text is left aligned on the video viewport.
2
00:00:31.000 --> 00:01:00.500 size:10% align:end
I said Bear is coming!!!!
Box for the cue is 10% of the video viewport width, which will mean that automatic line wrapping will happen
and the text is aligned to the end.
3
00:01:01.000 --> 00:02:00.500 size:0% align:middle
I said Bear is coming now!!!!
Cue text box size of 0 is acceptable, even if not visible.

View file

@ -0,0 +1,17 @@
WEBVTT
Invalid cue sizes (all settings are ignored).
1
00:00:00.000 --> 00:00:30.500 size: 50%
Bear is Coming!!!!!
Cue size setting doesn't parse and is ignored.
2
00:00:31.000 --> 00:01:00.500 size:-10%
I said Bear is coming!!!!
Negative cue size setting is not acceptable and is ignored.
3
00:01:01.000 --> 00:02:00.500 size:4000%
I said Bear is coming now!!!!
Cue size beyond 100% is not acceptable and is ignored.

View file

@ -0,0 +1,19 @@
WEBVTT
Valid cue size values.
1
00:00:00.000 --> 00:00:30.500 size:100%
Bear is Coming!!!!!
Box for the cue is 100% of the video viewport width,
exemplified through background color,
even if the text needs less.
2
00:00:31.000 --> 00:01:00.500 size:10%
I said Bear is coming!!!!
Box for the cue is 10% of the video viewport width, which will mean that automatic line wrapping will happen.
3
00:01:01.000 --> 00:02:00.500 size:0%
I said Bear is coming now!!!!
Cue text box size of 0 is acceptable, even if not visible.

View file

@ -0,0 +1,11 @@
WEBVTT
Cues must be separated by at least one blank line, otherwise treated like one big cue.
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:01:00.500
I said Bear is coming!!!!
00:01:01.000 --> 100:20:00.500
I said Bear is coming now!!!!

View file

@ -0,0 +1,14 @@
WEBVTT
Cues that have overlapping time ranges.
1
00:00:01.000 --> 00:00:06.000
Bear is Coming!!!!!
2
00:00:01.500 --> 00:00:05.000
I said Bear is coming!!!!
3
00:00:02.000 --> 00:00:05.000
I said Bear is coming now!!!!

View file

@ -0,0 +1,17 @@
WEBVTT
Cues may be separated by one or more blank lines.
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:01:00.500
I said Bear is coming!!!!
3
00:01:01.000 --> 100:20:00.500
I said Bear is coming now!!!!

View file

@ -0,0 +1,19 @@
WEBVTT
COMMENT-->
this is a comment, that will parse as part of the header;
the STYLE and DEFAULTS below are parsed as invalid cues
STYLE-->
::cue(.narration) { color: blue; }
DEFAULTS -->
line:-1 align:middle size:50%
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:20:00.500
I said Bear is coming!!!!

View file

@ -0,0 +1,5 @@
WEBVTT
00:00.000 --> 00:01.000
00:02.000 --> 00:03.000
00:04.000 --> 00:05.000

View file

@ -0,0 +1,11 @@
WEBVTT
Empty cues should not be discarded.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
3
00:01:01.000 --> 00:02:00.500 align:start position:20%

View file

@ -0,0 +1,15 @@
WEBVTT
Invalid use of < and > characters.
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
This cue has a less than < character.
It turns everything from there on into an annotation
for an empty tag and ends only at the next &gt; or &amp; character.
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
This cue has a greater than > character.
Since it's not related to a &lt; character,
it's just interpreted as text.

View file

@ -0,0 +1,30 @@
WEBVTT
Cue content with escape characters for &, <, >, LRM, RLM and non-breaking space.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
This cue has an ampersand &amp; character.
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
This cue has a less than &lt; character.
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
This cue has a greater than &gt; character.
4
00:02:01.000 --> 00:02:30.500 align:start position:20%
This cue has a Left-to-Right Mark &lrm;.
5
00:02:31.000 --> 00:03:00.500 align:start position:20%
This cue has a Right-to-Left Mark &rlm;.
6
00:03:01.000 --> 00:03:30.500 align:start position:20%
This cue has a non-breaking space &nbsp;.
7
00:03:31.000 --> 00:04:00.500
This & is parsed to the same as &amp;.

View file

@ -0,0 +1,9 @@
WEBVTT
00:00.000 --> 00:01.000
First
Stray Id or other non-cue content
00:02.000 --> 00:03.000
Second

View file

@ -0,0 +1,10 @@
WEBVTT FILE
Different encodings (iconv) should not be recognized as WebVTT a file.
1
00:00:00.000 --> 00:00:30.500
$B7J5$H=CG(B
2
00:00:31.000 --> 00:20:00.500
$BEENOITB-(B

View file

@ -0,0 +1,5 @@
WEBVTT
1
1234567:00:00.000 --> 1234567890:00:00.000
A very long cue.

View file

@ -0,0 +1,30 @@
WEBVTT
Invalid positioning values (all settings are ignored).
1
00:00:00.000 --> 00:00:15.000 line:-0%
Bear is Coming!!!!!
Negative percentages are not allowed.
Line position is ignored.
2
00:00:31.000 --> 00:00:45.500 line:+50%
I said Bear is coming!!!!
Non-numbers are not allowed.
Line position is ignored.
00:00:46.000 --> 00:01:00.500 line:+5
I said Bear is coming!!!!
Plus sign is not allowed.
Line position is ignored.
3
00:01:01.000 --> 00:01:30.000 line:10%0%
I said Bear is coming now!!!!
Doesn't parse into a percentage.
Line position is ignored.
00:01:31.000 --> 00:02:00.500 line:-10l
I said Bear is coming now!!!!
Doesn't parse into a number.
Line position is ignored.

View file

@ -0,0 +1,37 @@
WEBVTT
Cues with valid vertical line positioning values.
1
00:00:00.000 --> 00:00:15.000 line:0%
Bear is Coming!!!!!
Positioning on the top of the viewport, in the middle.
00:00:15.500 --> 00:00:30.500 line:0
Bear is Coming!!!!!
This is line 0.
Positioning on the top of the viewport, in the middle.
2
00:00:31.000 --> 00:00:45.500 line:50%
I said Bear is coming!!!!
Positioning on the center of the video.
00:00:46.000 --> 00:01:00.500 line:5
I said Bear is coming!!!!
This is line 6 from the top of the video viewport.
3
00:01:01.000 --> 00:01:30.000 line:100%
I said Bear is coming now!!!!
Positioning on the bottom middle.
00:01:31.000 --> 00:02:00.500 line:-1
I said Bear is coming now!!!!
This is the first line at the bottom of the video viewport.
Positioning on the bottom middle. Only 1 line shows.
00:02:01.000 --> 00:02:30.000 line:500
I said Bear is coming now!!!!
This is legal,
even though the line will likely not be within the video viewport.

View file

@ -0,0 +1,22 @@
WEBVTT
Cue text has invalid markup of <b>, <i>, <u>, <rt> and <ruby>. Has a bad effect on the remainder of the cue.
1
00:00:00.000 --> 00:00:15.000 align:start position:20%
The following bear starts bold but end is broken:
<b>Bear</ b> is Coming!!!!!
00:00:15.500 --> 00:00:30.500 align:start position:20%
The following bear is not in italics but the markup is removed:
< i>Bear</i> is Coming!!!!!
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
The following bear is not underlined and markup is removed:
I said < u >Bear</u> is coming!!!!
3
00:01:01.000 --> 00:01:30.000 align:start position:20%
The following bear is not ruby annotated and markup is removed:
I said <ru by>Bear<rt>bear with me</rt></ruby> is coming!!!!

View file

@ -0,0 +1,22 @@
WEBVTT
Cues with <b>, <i>, <u>, <rt> and <ruby> tags (all valid).
1
00:00:00.000 --> 00:00:15.000 align:start position:20%
The following bear is bold:
<b>Bear</b> is Coming!!!!!
00:00:15.500 --> 00:00:30.500 align:start position:20%
The following bear is in italics and has a class of "larger":
<i.larger>Bear</i> is Coming!!!!!
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
The following bear is underlined even though the element has a blank:
I said <u >Bear</u> is coming!!!!
3
00:01:01.000 --> 00:01:30.000 align:start position:20%
The following bear is ruby annotated:
I said <ruby>Bear<rt>bear with me</rt></ruby> is coming!!!!

View file

@ -0,0 +1,14 @@
WEBVTT
This is where metadata would go and these lines should be skipped.
author = silviapf@google.com
COMMENT-->
this is a comment, that will parse as part of the header;
the STYLE and DEFAULTS below are parsed as invalid cues
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:20:00.500
I said Bear is coming!!!!

View file

@ -0,0 +1,38 @@
WEBVTT
00:00:00.000 --> 00:00:01.000
Lorem ipsum dolor sit amet,
00:00:02.000 --> 00:00:03.000
consectetuer adipiscing elit,
00:00:04.000 --> 00:00:05.000
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
00:00:06.000 --> 00:00:07.000
Ut wisi enim ad minim veniam,
00:00:08.000 --> 00:00:09.000
quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
00:00:10.000 --> 00:00:11.000
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat,
00:00:12.000 --> 00:00:13.000
vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
00:00:14.000 --> 00:00:15.000
dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
00:00:16.000 --> 00:00:17.000
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id
00:00:18.000 --> 00:00:19.000
quod mazim placerat facer possim assum.
00:00:20.000 --> 00:00:21.000
Typi non habent claritatem insitam;
00:00:22.000 --> 00:00:23.000
est usus legentis in iis qui facit eorum claritatem.

View file

@ -0,0 +1,31 @@
WEBVTT
Events should be triggered for missed (skipped) cues during normal playback.
1
00:00:00.000 --> 00:00:01.500 align:start position:20%
Bear is Coming!!!!!
And what kind of a bear it is - just have look.
2
00:00:02.000 --> 00:00:02.500 align:start position:20%
I said Bear is coming!!!!
3
00:00:05.500 --> 00:00:05.501 align:start position:20%
I said Bear is coming now!!!!
4
00:00:05.700 --> 00:00:05.701 align:start position:20%
This is the second missed cue in the test.
5
00:00:05.800 --> 00:00:05.800 align:start position:20%
Third missed cue - zero-length cue.
6
00:00:05.850 --> 00:00:05.851 align:start position:20%
Fourth missed cue.
7
00:00:05.950 --> 00:00:01.100
Negative length cue. Should be treated correctly.

View file

@ -0,0 +1,6 @@
WEBVTT
A file with no line terminator at the end should be fine (last cue should be recognized).
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!

View file

@ -0,0 +1,13 @@
WEBVTT
Cues without timings are ignored.
1
00:00:00.000
Bear is Coming!!!!!
2
00h:00m:31s.000ms
I said Bear is coming!!!!
3
I said Bear is coming now!!!!

View file

@ -0,0 +1,10 @@
AWEBVTT FILE
A file with wrong file header should not be recognized as a webvtt file.
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:20:00.500
I said Bear is coming!!!!

View file

@ -0,0 +1,39 @@
WEBVTT
Invalid horizontal positioning values (all settings are ignored).
1
00:00:00.000 --> 00:00:15.500 position:-5%
Bear is Coming!!!!!
This would be off screen -> ignored.
00:00:16.000 --> 00:00:30.500 position:150%
Bear is Coming!!!!!
This would be off screen -> ignored.
2
00:00:31.000 --> 00:00:45.500 position:50
I said Bear is coming!!!!
Missing percent sign -> ignored.
2
00:00:46.000 --> 00:01:00.500 position:50a%
I said Bear is coming!!!!
Surplus character between number and percent sign -> ignored.
3
00:01:01.000 --> 00:01:30.500 position:100%-fj
I said Bear is coming now!!!!
Surplus characters after percent sign -> ignored.
00:01:31.000 --> 00:02:00.500 position:100asdf
I said Bear is coming now!!!!
Surplus characters and no percent sign -> ignored.
00:02:01.000 --> 00:02:02.000 position:e50%
I said Bear is coming now!!!!
Surplus characters at beginning of size string -> ignored.
00:02:02.100 --> 00:02:02.500 position:5g0%
I said Bear is coming now!!!!
Surplus characters in middle of size string -> ignored.

View file

@ -0,0 +1,21 @@
WEBVTT
Valid horizontal positioning values.
1
00:00:00.000 --> 00:00:30.500 position:0%
الدب قادم!!!!!
تحديد المواقع في أسفل اليمين.
2
00:00:31.000 --> 00:00:45.500 position:50%
قلت الدب قادم!!
تحديد المواقع في منتصف القاع.
00:00:46.000 --> 00:01:00.500
قلت الدب قادم!!
المواقع الافتراضية على منتصف أسفل تزال قائمة.
3
00:01:01.000 --> 00:02:00.500 position:100%
قلت الدب قادم الآن!!
غادر لتحديد المواقع في القاع.

View file

@ -0,0 +1,21 @@
WEBVTT
Valid horizontal positioning values.
1
00:00:00.000 --> 00:00:30.500 position:0%
Bear is Coming!!!!!
Positioning on the left bottom.
2
00:00:31.000 --> 00:00:45.500 position:50%
I said Bear is coming!!!!
Positioning on the bottom middle.
00:00:46.000 --> 00:01:00.500
I said Bear is coming!!!!
Default positioning on the bottom middle still.
3
00:01:01.000 --> 00:02:00.500 position:100%
I said Bear is coming now!!!!
Positioning on the bottom right.

View file

@ -0,0 +1,20 @@
WEBVTT
Cues settings may only be separated by spaces or tabs, but illegal characters
between settings are ignored.
1
00:00:00.000 --> 00:00:30.500 - line:43% position:10% -
Bear is Coming!!!!! Bad separator ignored.
2
00:00:31.000 --> 00:01:00.500 --> position:50% Vertical:lr align:end
I said Bear is coming!!!! Bad separator and setting ignored.
3
00:01:01.000 --> 00:02:00.500 <align:end> <position:90%>
I said Bear is coming now!!!! Bad setting markup. Not ignored because the settings are
not delimited by spaces or tabs.
4
00:02:01.000 --> 100:20:00.500 / vertical:lr | position:90%
I said Bear is coming now!!!! Bad separator ignored.

View file

@ -0,0 +1,18 @@
WEBVTT
Cue settings may be separated by spaces or tabs.
1
00:00:00.000 --> 00:00:30.500 line:100% align:start
Bear is Coming!!!!! One blank.
2
00:00:31.000 --> 00:01:00.500 position:40% vertical:rl line:15%
I said Bear is coming!!!! Several blanks.
3
00:01:01.000 --> 00:02:00.500 align:middle position:10%
I said Bear is coming now!!!! Tab separator.
4
00:02:01.000 --> 100:20:00.500 line:95% vertical:lr align:end
I said Bear is coming now!!!! Tab separators.

View file

@ -0,0 +1,17 @@
WEBVTT
0
00:00:04.000 --> 00:00:04.500
First cue
1
00:00:04.500 --> 00:00:05.000
Lorem
2
00:00:05.000 --> 00:00:05.500
ipsum
3
00:00:05.500 --> 00:00:05.501
Missed cue with pause-on-exit

View file

@ -0,0 +1,34 @@
WEBVTT
Enter and exit events should be dispatched in a sorted order according to their times.
0
00:00:04.000 --> 00:00:04.500
Missed cue that should not be considered because of seeking.
1
00:00:05.100 --> 00:00:05.800 align:start position:20%
Bear is Coming!!!!!
2
00:00:05.100 --> 00:00:05.101
Missed cue 1
3
00:00:05.100 --> 00:00:05.301
And what kind of a bear it is - just have look.
4
00:00:05.100 --> 00:00:05.101
Missed Cue 2
5
00:00:05.300 --> 00:00:05.800 align:start position:20%
I said Bear is coming!!!!
6
00:00:05.990 --> 00:00:05.993 align:start position:20%
I said Bear is coming now!!!!
7
00:00:05.994 --> 00:00:05.998 align:start position:20%
Bear is already here

View file

@ -0,0 +1,17 @@
WEBVTT
Invalid <timestamp> markup.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
This <00:00:05.000>cue <00:00:10.000>is <00:00:12.000>painted <00:00:08.000>on.
But since the last two timestamps are out of order, they are ignored.
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
I <00:00:20.000>said <00:00:22.000>Bear <00:00:24.000>is <00:00:26.000>coming!!!!
All of these timestamps are before the start of the cue, so get ignored.
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
I <00:02:05.000>said <00:02:10.000>Bear <00:02:15.000>is <00:02:20.000>coming <00:02:25.000>now!!!!
All of these timestamps are after the end of the cue, so get ignored.

View file

@ -0,0 +1,14 @@
WEBVTT
Paint-on text in cues with <timestamp> markup.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
This <00:00:05.000>cue <00:00:10.000>is <00:00:15.000>painted <00:00:20.000>on.
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
I <00:00:35.000>said <00:00:40.000>Bear <00:00:45.000>is <00:00:50.000>coming!!!!
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
I <00:01:05.000>said <00:01:10.000>Bear <00:01:15.000>is <00:01:20.000>coming <00:01:25.000>now!!!!

View file

@ -0,0 +1,22 @@
WEBVTT
These timings all have errors and all cues should be ignored.
1
00:00.00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:01:00:500
I said Bear is coming!!!!
3
00:01:01.000 --> 00:120:00.500
I said Bear is coming now!!!!
4
00:02:01.000 - 00:03:00.500
I said Bear is coming now!!!!
5
00h:03m:01s.000ms --> 00h:03m:00s.500ms
I said Bear is coming now!!!!

View file

@ -0,0 +1,14 @@
WEBVTT
Timings can optionally contain an hour.
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:01:00.500
I said Bear is coming!!!!
3
00:01:01.000 --> 100:20:00.500
I said Bear is coming now!!!!

View file

@ -0,0 +1,22 @@
WEBVTT
These timings all have errors and all cues should be ignored.
1
00.00.000 --> 00:30.500
Bear is Coming!!!!!
2
00:31.000 --> 01:00:500
I said Bear is coming!!!!
3
01:01.000 --> 120:00.500
I said Bear is coming now!!!!
4
01:01.000 - 02:00.500
I said Bear is coming now!!!!
5
02:01.000 --> 03m:00.500
I said Bear is coming now!!!!

View file

@ -0,0 +1,18 @@
WEBVTT
The hour of a timestamp is optional.
1
00:00.000 --> 00:30.500
Bear is Coming!!!!!
2
00:31.000 --> 01:00.500
I said Bear is coming!!!!
3
01:01.000 --> 02:00.500
I said Bear is coming now!!!!
4
02:01.000 --> 03:00.500
tab separators

View file

@ -0,0 +1,51 @@
WEBVTT
Whitespace (U+0020, U+0009, U+000C) surrounding cue-timings separator ("-->") is optional
1
00:00:00.100 -->00:00:01.500
Single U+0020 SPACE left of cue-timings separator
2
00:00:00.100--> 00:00:01.500
Single U+0020 SPACE right of cue-timings separator
3
00:00:00.100 -->00:00:01.500
Single U+0009 TAB left of cue-timings separator
4
00:00:00.100--> 00:00:01.500
Single U+0009 TAB right of cue-timings separator
5
00:00:00.100 -->00:00:01.500
Single U+000C FORM FEED left of cue-timings separator
6
00:00:00.100--> 00:00:01.500
Single U+000C FORM FEED right of cue-timings separator
7
00:00:00.100 -->00:00:01.500
Several U+0020 SPACE left of cue-timings separator
8
00:00:00.100--> 00:00:01.500
Several U+0020 SPACE right of cue-timings separator
9
00:00:00.100 -->00:00:01.500
Several U+0009 TAB left of cue-timings separator
10
00:00:00.100--> 00:00:01.500
Several U+0009 TAB right of cue-timings separator
11
00:00:00.100 -->00:00:01.500
Several U+000C FORM FEED left of cue-timings separator
12
00:00:00.100--> 00:00:01.500
Several U+000C FORM FEED right of cue-timings separator

View file

@ -0,0 +1,23 @@
WEBVTT
Any HTML markup that is not supported should be ignored.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
<h1>Bear is Coming!!!!!</h1>
<p>And what kind of a bear it is - just have <a href="webpage.html">look</a>.</p>
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
<ul>
<li>I said Bear is coming!!!!</li>
<li>I said Bear is still coming!!!!</li>
</ul>
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
<ol>
<li>I said Bear is coming now!!!!</li>
<li><img src="bear.png" alt="mighty bear"></li>
<li><video src="bear_ad.webm" controls></video></li>
</ol>

View file

@ -0,0 +1,10 @@
WEBVTT
UTF-8 encoded characters should be recognized.
1
00:00:00.000 --> 00:00:30.500
2
00:00:31.000 --> 00:20:00.500

View file

@ -0,0 +1,17 @@
WEBVTT
Invalid vertical direction settings (all settings are ignored).
1
00:00:00.000 --> 00:00:30.500 vertical:#vertical
Bear is Coming!!!!!
Normal rendering - direction setting is ignored.
2
00:00:31.000 --> 00:01:00.500 vertical:verticallr
I said Bear is coming!!!!
Normal rendering - direction setting is ignored.
3
00:01:01.000 --> 00:02:00.500 vertical:vertical-rl
I said Bear is coming now!!!!
Normal rendering - direction setting is ignored.

View file

@ -0,0 +1,20 @@
WEBVTT
Valid vertical direction settings.
1
00:00:00.000 --> 00:00:30.500 vertical:rl
الدب قادم!!!!!
يجعل على الجانب الأيمن من المعاينة الفيديو والمتوسطة الانحياز ،
أسفل إلى أعلى، وتزايد اليسار.
2
00:00:31.000 --> 00:01:00.500 vertical:lr
قلت الدب قادم!!
يجعل على الجانب الأيسر من المعاينة الفيديو والمتوسطة الانحياز ،
أسفل إلى أعلى، وتنامي اليمين.
3
00:01:01.000 --> 00:02:00.500 vertical:rl align:start position:0%
قلت الدب قادم الآن!!
يجعل على الجانب الأيمن من المعاينة الفيديو ، على حد سواء أسفل محاذاة
لمربع جديلة والنص داخل النص ، من أسفل إلى أعلى، وتزايد اليسار.

View file

@ -0,0 +1,20 @@
WEBVTT
Valid vertical direction settings.
1
00:00:00.000 --> 00:00:30.500 vertical:rl
Bear is Coming!!!!!
Renders on the right side of the video viewport, middle aligned,
top to bottom, growing left.
2
00:00:31.000 --> 00:01:00.500 vertical:lr
I said Bear is coming!!!!
Renders on the left side of the video viewport, middle aligned,
top to bottom, growing right.
3
00:01:01.000 --> 00:02:00.500 vertical:rl align:start position:0%
I said Bear is coming now!!!!
Renders on the right side of the video viewport, top aligned both
for the cue box and the text within, text from top to bottom, growing left.

View file

@ -0,0 +1,17 @@
WEBVTT
Invalid <v> voice markup.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
< v Speaker>Bear is Coming!!!!!</v>
This is two annotations for an empty tag.
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
<v&Doe Hunter>I said Bear is coming!!!!</v>
This does not parse as a voice tag.
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
I said <v-Speaker>Bear is coming now</v>!!!!
This does not parse as a voice tag.

View file

@ -0,0 +1,15 @@
WEBVTT
Cue text fragment with <v> voice markup mapped to HTML <q> element with @title for annotation.
1
00:00:00.000 --> 00:00:30.500 align:start position:20%
<v.blue Speaker>Bear is Coming!!!!!</v>
Text span with a class and an annotation.
2
00:00:31.000 --> 00:01:00.500 align:start position:20%
<v Doe Hunter>I said Bear is coming!!!!</v>
3
00:01:01.000 --> 00:02:00.500 align:start position:20%
I said <v.blue Speaker>Bear is coming now</v>!!!!

View file

@ -0,0 +1,9 @@
WEBVTT FILE
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:20:00.500
I said Bear is coming!!!!

View file

@ -0,0 +1,10 @@
WEBVTT asdfasdfauhio
Rubbish after the WEBVTT header should be ignored.
1
00:00:00.000 --> 00:00:30.500
Bear is Coming!!!!!
2
00:00:31.000 --> 00:20:00.500
I said Bear is coming!!!!

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<title>Ensure that no text track cues are active after the video is unloaded</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
var eventCount = 0;
function eventCallback() {
eventCount++;
if (eventCount == 3) {
assert_equals(trackElement.track.activeCues.length, 1);
video.src = '';
}
}
var video = document.createElement('video');
video.src = getVideoURI('/media/movie_5');
var trackElement = document.createElement('track');
trackElement.onload = t.step_func(eventCallback);
trackElement.oncuechange = t.step_func(eventCallback);
video.oncanplaythrough = t.step_func(eventCallback);
video.onerror = t.step_func_done(function() {
assert_equals(event.target, video);
assert_not_equals(video.error, null);
assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE);
assert_equals(trackElement.track.activeCues.length, 0);
});
trackElement.src = 'resources/captions-fast.vtt';
trackElement.kind = 'captions';
trackElement.default = true;
video.appendChild(trackElement);
});
</script>

View file

@ -0,0 +1,92 @@
<!DOCTYPE html>
<title>TextTrack's addCue and removeCue</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
var video = document.createElement("video");
var trackElement = document.createElement("track");
trackElement.onload = t.step_func_done(function() {
var cues = trackElement.track.cues;
// Test cues loaded from the file.
assert_equals(cues.length, 4);
assert_equals(cues.getCueById("1").startTime, 0);
assert_equals(cues[1].startTime, 31);
assert_equals(cues[2].startTime, 61);
assert_equals(cues.getCueById("4").startTime, 121);
assert_object_equals(cues.getCueById("junk"), undefined);
// Create a new cue, check values.
var textCue = new VTTCue(33, 3.4, "Sausage?");
assert_equals(textCue.track, null);
assert_equals(textCue.id, "");
assert_equals(textCue.startTime, 33);
assert_equals(textCue.endTime, 3.4);
assert_equals(textCue.pauseOnExit, false);
assert_equals(textCue.vertical, "");
assert_equals(textCue.snapToLines, true);
assert_equals(textCue.line, "auto");
assert_equals(textCue.position, "auto");
assert_equals(textCue.size, 100);
assert_equals(textCue.align, "center");
// Remove the unadded track, make sure it throws correctly.
assert_throws("NotFoundError", function() { trackElement.track.removeCue(textCue); });
// Add the new cue to a track, make sure it is inserted correctly.
trackElement.track.addCue(textCue);
assert_equals(textCue.track, trackElement.track);
assert_equals(cues[1].startTime, 31);
assert_equals(cues[2].startTime, 33);
assert_equals(cues[3].startTime, 61);
// create a new cue and add it to a track created with
// video.addTextTrack, make sure it is inserted correctly.
var newTrack = video.addTextTrack("subtitles", "French subtitles", "fr");
newTrack.mode = "showing";
var newCue = new VTTCue(0, 1, "Test!");
newTrack.addCue(newCue);
assert_equals(newCue, newTrack.cues[0])
assert_equals(newCue.track, newTrack);
assert_equals(newCue.id, "");
assert_equals(newCue.startTime, 0);
assert_equals(newCue.endTime, 1);
assert_equals(newCue.pauseOnExit, false);
assert_equals(newCue.vertical, "");
assert_equals(newCue.snapToLines, true);
assert_equals(newCue.line, "auto");
assert_equals(newCue.position, "auto");
assert_equals(newCue.size, 100);
assert_equals(newCue.align, "center");
trackElement.track.removeCue(textCue);
assert_equals(textCue.track, null);
assert_equals(cues[1].startTime, 31);
assert_equals(cues[2].startTime, 61);
// Remove a cue added from the WebVTT file.
textCue = cues[2];
trackElement.track.removeCue(textCue);
assert_equals(textCue.track, null);
assert_equals(cues[1].startTime, 31);
assert_equals(cues[2].startTime, 121);
// Try to remove the cue again.
assert_throws("NotFoundError", function() { trackElement.track.removeCue(textCue); });
// Add a cue before all the existing cues.
trackElement.track.addCue(new VTTCue(0, 31, "I am first"));
assert_equals(cues[0].startTime, 0);
assert_equals(cues[0].endTime, 31);
assert_equals(cues[1].startTime, 0);
assert_equals(cues[1].endTime, 30.5);
assert_equals(cues[2].startTime, 31);
});
trackElement.src = "resources/settings.vtt";
trackElement.kind = "captions";
trackElement.default = true;
video.appendChild(trackElement);
});
</script>

View file

@ -0,0 +1,34 @@
<!DOCTYPE html>
<title>'addtrack' event is fired when a TextTrack is created</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
var video = document.createElement('video');
var trackElement = document.createElement('track');
video.appendChild(trackElement);
var tracks = [];
tracks.push(trackElement.track);
// Register the 'addtrack' listener after creating the element
// to make sure the event is dispatched asynchronously.
video.textTracks.onaddtrack = t.step_func(function() {
assert_equals(event.target, video.textTracks);
assert_true(event instanceof TrackEvent, 'instanceof');
assert_equals(event.track, tracks[video.textTracks.length - 1]);
if (video.textTracks.length == 1) {
tracks.push(video.addTextTrack('captions', 'Caption Track', 'en'));
assert_equals(video.textTracks.length, 2);
} else {
t.done();
}
});
trackElement.src = 'resources/webvtt-file.vtt';
trackElement.track.mode = 'hidden';
assert_equals(video.textTracks.length, 1);
assert_equals(trackElement.readyState, HTMLTrackElement.NONE);
});
</script>

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<title>addTextTrack() only accepts known "kind" values</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var trackCount = 0;
function addTrack(type) {
video.addTextTrack(type);
assert_equals(video.textTracks.length, ++trackCount);
}
var video = document.createElement("video");
assert_equals(video.textTracks.length, 0);
assert_throws(new TypeError(), function() { video.addTextTrack("kaptions"); });
assert_equals(video.textTracks.length, 0);
addTrack("subtitles");
addTrack("captions");
addTrack("descriptions");
addTrack("chapters");
addTrack("metadata");
});
</script>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<title>Invoke getCueAsHTML() on an empty cue</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var emptyCue = new VTTCue(0, 0, "");
var fragment = emptyCue.getCueAsHTML();
// The getCueAsHTML() method should return a document fragment.
assert_true(fragment instanceof DocumentFragment);
// The document fragment should have one child, an empty Text node.
assert_equals(fragment.childNodes.length, 1);
assert_equals(fragment.childNodes[0].constructor.name, Text.name);
assert_equals(fragment.childNodes[0].length, 0);
assert_equals(fragment.childNodes[0].data, "");
});
</script>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<title>Add a track and change its mode through JS</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<source src="/media/test.mp4" type="video/mp4">
<source src="/media/test.ogv" type="video/ogg">
</video>
<script>
test(function() {
var video = document.querySelector('video');
var track = video.addTextTrack('captions', 'English', 'en');
track.addCue(new VTTCue(0.0, 10.0, 'wow wow'));
track.mode = 'showing';
});
</script>

View file

@ -0,0 +1,85 @@
<!DOCTYPE html>
<title>Cue fragment is mutable</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
p, div { display: none; }
</style>
<video>
<track src="resources/captions-html.vtt" kind="captions" default>
<script>
async_test(function(t) {
var video = document.querySelector("video");
var testTrack = document.querySelector("track");
video.oncanplaythrough = t.step_func(testMutability);
testTrack.onload = t.step_func(testMutability);
var fragment;
var eventCount = 0;
function testMutability() {
eventCount++;
if (eventCount != 2)
return;
var testCue = testTrack.track.cues[0];
// Test initial cue contents.
assert_equals(testCue.text, "Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit</i> amet,");
// Cue getCueAsHTML() should return a correct fragment.
createExpectedFragment(document.createDocumentFragment());
assert_true(fragment.isEqualNode(testCue.getCueAsHTML()));
// Appending getCuesAsHTML() twice to the DOM should be succesful.
document.getElementsByTagName("div")[0].appendChild(testCue.getCueAsHTML());
document.getElementsByTagName("div")[1].appendChild(testCue.getCueAsHTML());
createExpectedFragment(document.createElement("div"));
assert_true(fragment.isEqualNode(document.getElementsByTagName("div")[0]));
assert_true(fragment.isEqualNode(document.getElementsByTagName("div")[1]));
// The fragment returned by getCuesAsHTML() should be independently mutable.
document.getElementsByTagName("div")[0].firstChild.textContent = "Different text ";
assert_false(fragment.isEqualNode(document.getElementsByTagName("div")[0]));
assert_true(fragment.isEqualNode(document.getElementsByTagName("div")[1]));
// Calling twice getCueAsHTML() should not return the same fragment.
assert_not_equals(testCue.getCueAsHTML(), testCue.getCueAsHTML());
t.done();
}
function createExpectedFragment(rootNode) {
fragment = rootNode;
fragment.appendChild(document.createTextNode("Lorem "));
var bold = document.createElement("b");
bold.appendChild(document.createTextNode("ipsum"));
fragment.appendChild(bold);
fragment.appendChild(document.createTextNode(" "));
var underline = document.createElement("u");
underline.appendChild(document.createTextNode("dolor"));
fragment.appendChild(underline);
fragment.appendChild(document.createTextNode(" "));
var italics = document.createElement("i");
italics.className = "sit";
italics.appendChild(document.createTextNode("sit"));
fragment.appendChild(italics);
fragment.appendChild(document.createTextNode(" amet,"));
}
video.src = getVideoURI("/media/counting");
});
</script>
</video>
<p>Fragment 1</p>
<div></div>
<p>Fragment 2</p>
<div></div>

View file

@ -0,0 +1,99 @@
<!DOCTYPE html>
<title>Modifying attributes of a VTTCue</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track id="captions" src="resources/captions.vtt" kind="captions" default>
<script>
async_test(function(t) {
var track = document.querySelector("track");
track.onload = t.step_func_done(function() {
var cues = track.track.cues;
// Test initial values.
textCue = cues.getCueById("1");
assert_equals(textCue.startTime, 0);
assert_equals(textCue.endTime, 1.0);
assert_equals(textCue.pauseOnExit, false);
assert_equals(textCue.vertical, "");
assert_equals(textCue.snapToLines, true);
assert_equals(textCue.line, "auto");
assert_equals(textCue.position, "auto");
assert_equals(textCue.size, 100);
assert_equals(textCue.align, "center");
// Modify cue values.
textCue.startTime = 1.1;
assert_equals(textCue.startTime, 1.1);
textCue.endTime = 3.9;
assert_equals(textCue.endTime, 3.9);
textCue.pauseOnExit = true;
assert_equals(textCue.pauseOnExit, true);
// http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-vertical
// On setting, the text track cue writing direction must be
// set to the value given in the first cell of the row in
// the table above whose second cell is a case-sensitive
// match for the new value.
textCue.vertical = "RL";
assert_equals(textCue.vertical, "");
textCue.vertical = "rl";
assert_equals(textCue.vertical, "rl");
textCue.snapToLines = false;
assert_equals(textCue.snapToLines, false);
// http://dev.w3.org/html5/webvtt/#dfn-vttcue-line
// On setting, the text track cue line position must be set
// to the new value; if the new value is the string "auto",
// then it must be interpreted as the special value auto.
assert_equals(textCue.line, "auto");
assert_throws(new TypeError, function() { textCue.line = "gazonk"; });
assert_equals(textCue.line, "auto");
textCue.line = 42;
assert_equals(textCue.line, 42);
textCue.line = -2;
assert_equals(textCue.line, -2);
textCue.line = 102;
assert_equals(textCue.line, 102);
textCue.snapToLines = true;
textCue.line = -2;
assert_equals(textCue.line, -2);
textCue.line = 102;
assert_equals(textCue.line, 102);
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
// On setting, if the new value is negative or greater than 100,
// then throw an IndexSizeError exception.
// Otherwise, set the text track cue text position to the new value.
assert_throws("IndexSizeError", function() { textCue.position = -200; });
assert_throws("IndexSizeError", function() { textCue.position = 110; });
textCue.position = 11;
assert_equals(textCue.position, 11);
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
// On setting, if the new value is negative or greater than 100,
// then throw an IndexSizeError exception.
// Otherwise, set the text track cue size to the new value.
assert_throws("IndexSizeError", function() { textCue.size = -200 });
assert_throws("IndexSizeError", function() { textCue.size = 110 });
textCue.size = 57;
assert_equals(textCue.size, 57);
// http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-align
// On setting, the text track cue text alignment must be
// set to the value given in the first cell of the row
// in the table above whose second cell is a case-sensitive
// match for the new value.
textCue.align = "End";
assert_equals(textCue.align, "center");
textCue.align = "end";
assert_equals(textCue.align, "end");
});
});
</script>
</video>

View file

@ -0,0 +1,59 @@
<!DOCTYPE html>
<title>Events are triggered for missed (skipped) cues during normal playback</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/missed-cues.vtt" default>
<script>
async_test(function(t) {
var video = document.querySelector("video");
var testTrack = document.querySelector("track");
video.src = getVideoURI("/media/test");
video.onended = t.step_func_done();
video.oncanplaythrough = t.step_func(function() {
video.oncanplaythrough = null;
video.currentTime = 5.00;
runTests();
});
testTrack.onload = t.step_func(runTests);
var cueCount;
var eventCount = 0;
function runTests() {
eventCount++;
if(eventCount != 2)
return;
assert_equals(testTrack.track.cues.length, 7);
for (cueCount = 2; cueCount < testTrack.track.cues.length; cueCount++) {
var cue = testTrack.track.cues[cueCount];
cue.onenter = t.step_func(cueEnteredOrExited);
cue.onexit = t.step_func(cueEnteredOrExited);
}
// Test events for missed cues, which are cues with ids
// from 3 to 7 in the file resources/missed-cues.vtt.
cueCount = 3;
video.play();
}
function cueEnteredOrExited() {
var currentCue = event.target;
assert_equals(testTrack.track.cues.getCueById(cueCount).text, currentCue.text);
assert_equals(currentCue.id, cueCount.toString());
if (event.type == "exit")
cueCount++;
}
});
</script>
</video>

View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<title>Video is paused after cues having pause-on-exit flag are processed</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/simple-captions.vtt" default>
<script>
async_test(function(t) {
var video = document.querySelector("video");
var track = document.querySelector("track");
track.onload = t.step_func(function() {
assert_equals(track.track.cues.length, 4);
for (var i = 0; i < track.track.cues.length; ++i) {
var cue = track.track.cues[i];
if (i % 2 == 0) {
cue.pauseOnExit = true;
cue.onexit = t.step_func(function(event) {
assert_true(video.paused);
video.play();
if (event.target.id == 2)
t.done();
});
}
}
video.src = getVideoURI("/media/test");
video.currentTime = 4.00;
video.play();
assert_false(video.paused);
});
});
</script>
</video>

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<title>TextTrack's activeCues are indexed and updated during video playback</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/cues-overlapping.vtt" kind="subtitles" default>
<script>
async_test(function(t) {
var video = document.querySelector("video");
var track = document.querySelector("track");
track.onload = t.step_func(function() {
assert_equals(track.track.cues.length, 3);
video.src = getVideoURI("/media/test");
video.currentTime = 0.5;
});
var seekedCount = 0;
video.onseeked = t.step_func(function() {
++seekedCount;
assert_equals(video.currentTime, seekedCount * 0.5);
assert_equals(track.track.activeCues.length, seekedCount - 1);
video.currentTime = (seekedCount + 1) * 0.5;
if (seekedCount == 4)
t.done();
});
});
</script>
</video>

View file

@ -0,0 +1,48 @@
<!DOCTYPE html>
<title>All events are triggered in chronological order</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/sorted-dispatch.vtt" default>
<script>
async_test(function(t) {
var video = document.querySelector("video");
video.src = getVideoURI("/media/test");
var track = document.querySelector("track");
track.onload = t.step_func(function() {
var cues = track.track.cues;
assert_equals(cues.length, 8);
for (var i = 0; i < cues.length; ++i) {
cues[i].onenter = t.step_func(cueEnteredOrExited);
cues[i].onexit = t.step_func(cueEnteredOrExited);
}
video.play();
});
var cueTimings = [];
function cueEnteredOrExited(event) {
var currentCue = event.target;
if (event.type == "exit")
cueTimings.push(currentCue.endTime);
else
cueTimings.push(currentCue.startTime);
}
video.onended = t.step_func_done(function() {
assert_equals(cueTimings.length, 14);
var time = 0;
for (var i = 0; i < cueTimings.length; ++i) {
assert_less_than_equal(time, cueTimings[i], "cueTimings[" + i + "]");
time = cueTimings[i];
}
});
video.currentTime = 5;
});
</script>
</video>

View file

@ -0,0 +1,33 @@
<!DOCTYPE html>
<title>Adding cues to a disabled text track</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(function(t) {
var cueDuration = 0.1;
var video = document.createElement("video");
var track = video.addTextTrack("subtitles");
track.mode = "disabled";
for (var i = 0; i < 10; ++i) {
var start = i * cueDuration;
var end = start + cueDuration;
track.addCue(new VTTCue(start, end, "Test Cue " + i));
}
// Waiting for 2 cue durations to elapse.
video.ontimeupdate = t.step_func(function(event) {
if (event.target.currentTime < (2 * cueDuration))
return;
// End test after at least 2 cueDurations to make sure the test
// would have gone through the period where the first 2 cues would
// have been rendered if the track was not disabled.
t.done();
});
video.src = getVideoURI("/media/test");
video.play();
});
</script>

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<title>Disabling a track</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track kind="subtitles" src="resources/captions.vtt"/>
</video>
<script>
async_test(function(t) {
var video = document.querySelector("video");
video.textTracks[0].mode = "disabled";
// Waiting for the duration of the first cue to elapse.
video.ontimeupdate = t.step_func(function (event) {
if (event.target.currentTime < 1)
return;
// End test after the duration of the first cue to make sure
// the test would have gone through the period where this cue
// would have been rendered if the track was not disabled.
t.done();
});
video.src = getVideoURI("/media/test");
video.play();
});
</script>

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<title>Simple DOM mutations with track element</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(function() {
var video = document.createElement("video");
var testTrack = document.createElement("track");
// Append the track element to the video element.
video.appendChild(testTrack);
// Set the mode of the text track to "showing".
testTrack.track.mode = "showing";
});
</script>

View file

@ -0,0 +1,92 @@
<!DOCTYPE html>
<title>HTMLTrackElement 'src' attribute mutations</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/settings.vtt" default>
<script>
async_test(function(t) {
var cues = null;
var testTrack = document.querySelector("track");
var stage = 0;
var timer = null;
function step_onLoad() {
switch (stage) {
case 0:
cues = testTrack.track.cues;
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after first loading of the track");
assert_equals(cues.length, 4, "Number of cues after first loading of the track");
++stage;
testTrack.src = "resources/non-existing-file.vtt"; // this should fail
break;
case 1:
case 3:
case 5:
assert_unreached("'error' event did not fire, stage = " + stage);
break;
case 2:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after loading of the second track");
assert_equals(cues.length, 4, "Number of cues after loading of the second track");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
++stage;
testTrack.src = ""; // this should fail
// CuesList will be cleared in the next tick. Spec claims that this should happen immediately,
// but all implementations are doing this asynchronously.
assert_equals(cues.length, 4, "Number of cues immediately after 'src' mutation with the empty URL");
// This should raise onError event. If no, we'll know about this after some time.
timer = t.step_timeout(t.unreached_func("'error' event is not fired when an empty URL is set"), 100);
break;
case 4:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after loading of the second track");
assert_equals(cues.length, 4, "Number of cues after loading of the second track");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
++stage;
testTrack.removeAttribute('src');
// This should raise onError event, so we'll wait for it for some time
timer = t.step_timeout(t.unreached_func("'error' event is not fired when an empty URL is set"), 100);
break;
default:
assert_unreached("unexpected stage number = " + stage);
break;
}
}
function step_onError() {
switch (stage) {
case 0:
case 2:
case 4:
assert_unreached("'error' event fired, stage = " + stage);
break;
case 1:
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 0, "Number of cues after trying to load non-existing url");
assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after trying to load non-existing url");
++stage;
testTrack.src = "resources/settings.vtt";
break;
case 3:
clearTimeout(timer);
assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after setting an empty URL");
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 0, "Number of cues with an empty URL set");
++stage;
testTrack.src = "resources/settings.vtt";
break;
case 5:
clearTimeout(timer);
assert_equals(testTrack.readyState, HTMLTrackElement.ERROR, "readyState after removing 'src' attr");
assert_equals(cues.length, 0, "Number of cues after removing 'src' attr");
t.done();
break;
default:
assert_unreached("unexpected stage number = " + stage);
break;
}
}
testTrack.onload = t.step_func(step_onLoad);
testTrack.onerror = t.step_func(step_onError);
});
</script>
</video>

View file

@ -0,0 +1,57 @@
<!DOCTYPE html>
<title>HTMLTrackElement 'src' attribute mutations</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/settings.vtt" default>
<script>
async_test(function(t) {
var cues = null;
var testTrack = document.querySelector("track");
var stage = 0;
function step_onLoad() {
switch (stage) {
case 0:
cues = testTrack.track.cues;
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after first loading of the track");
assert_equals(cues.length, 4, "Number of cues after first loading of the track");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
++stage;
testTrack.src = "resources/entities.vtt";
// CuesList will be cleared in a microtask. Spec claims that this should happen immediately,
// but all known implementations are doing this asynchronously.
assert_equals(cues.length, 4, "Number of cues immediately after 'src' mutation with the new URL");
break;
case 1:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED), "readyState after loading of the second track";
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 7, "Number of cues after loading of the second track");
assert_equals(cues[cues.length-1].text, 'This & is parsed to the same as &amp;.', "Last cue content check");
++stage;
testTrack.src = "resources/settings.vtt";
break;
case 2:
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after after loading of the first track again");
assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 4, "Number of cues after loading of the first track");
++stage;
testTrack.src = "resources/settings.vtt";
// This should not raise onLoad or onError event, so we'll wait for it for some time
t.step_timeout(t.step_func_done(function() {
assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after changing 'src' to the same value");
assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
assert_equals(cues.length, 4, "Number of cues after changing 'src' to the same value");
}, 100));
break;
case 3:
assert_unreached("'load' event should not fire, stage = " + stage);
break;
}
}
testTrack.onload = t.step_func(step_onLoad);
testTrack.onerror = t.unreached_func("'error' event should not fire");
});
</script>
</video>

View file

@ -0,0 +1,83 @@
function enableAllTextTracks(textTracks) {
for (var i = 0; i < textTracks.length; i++) {
var track = textTracks[i];
if (track.mode == "disabled")
track.mode = "hidden";
}
}
function assert_cues_equal(cues, expected) {
assert_equals(cues.length, expected.length);
for (var i = 0; i < cues.length; i++) {
assert_equals(cues[i].id, expected[i].id);
assert_equals(cues[i].startTime, expected[i].startTime);
assert_equals(cues[i].endTime, expected[i].endTime);
assert_equals(cues[i].text, expected[i].text);
}
}
function assert_cues_match(cues, expected) {
assert_equals(cues.length, expected.length);
for (var i = 0; i < cues.length; i++) {
var cue = cues[i];
var expectedItem = expected[i];
for (var property of Object.getOwnPropertyNames(expectedItem))
assert_equals(cue[property], expectedItem[property]);
}
}
function assert_cues_html_content(cues, expected) {
assert_equals(cues.length, expected.length);
for (var i = 0; i < cues.length; i++) {
var expectedItem = expected[i];
var property = Object.getOwnPropertyNames(expectedItem)[0];
var propertyValue = expectedItem[property];
assert_equals(propertyValue(cues[i]), expectedItem.expected);
}
}
function check_cues_from_track(src, func) {
async_test(function(t) {
var video = document.createElement("video");
var trackElement = document.createElement("track");
trackElement.src = src;
trackElement.default = true;
video.appendChild(trackElement);
trackElement.onload = t.step_func_done(function() {
func(trackElement.track);
});
}, "Check cues from " + src);
}
function assert_cue_fragment(cue, children) {
var fragment = createFragment(children);
assert_true(fragment.isEqualNode(cue.getCueAsHTML()));
}
function assert_cue_fragment_as_textcontent(cue, children) {
var fragment = createFragment(children);
assert_equals(cue.getCueAsHTML().textContent, fragment.textContent);
}
function createFragment(children) {
var fragment = document.createDocumentFragment();
cloneChildrenToFragment(fragment, children);
return fragment;
}
function cloneChildrenToFragment(root, children) {
for (var child of children) {
var childElement;
if (child.type == "text") {
childElement = document.createTextNode(child.value);
} else {
childElement = document.createElement(child.type);
var styles = child.style || {};
for (var attr of Object.getOwnPropertyNames(styles))
childElement[attr] = styles[attr];
cloneChildrenToFragment(childElement, child.value);
}
root.appendChild(childElement);
}
}

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<title>Very large timestamp is parsed correctly</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/large-timestamp.vtt" default>
<script>
async_test(function(t) {
var testTrack = document.querySelector("track");
testTrack.onload = t.step_func_done(function() {
assert_equals(testTrack.track.cues.length, 1);
var cue = testTrack.track.cues[0];
assert_equals(parseInt(cue.id), 1);
assert_equals(cue.startTime / 3600, 1234567);
assert_equals(cue.endTime / 3600, 1234567890);
});
});
</script>
</video>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Error event on HTMLTrackElement and ERROR readyState on TextTrack</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="junk" default>
<script>
async_test(function(t) {
var track = document.querySelector("track");
track.onerror = t.step_func_done(function() {
assert_equals(track.readyState, HTMLTrackElement.ERROR);
});
});
</script>
</video>

View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Load event on HTMLTrackElement and LOADED readyState on TextTrack when src is set on the element</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/webvtt-file.vtt" default>
<script>
async_test(function(t) {
var track = document.querySelector("track");
track.onload = t.step_func_done(function() {
assert_equals(track.readyState, HTMLTrackElement.LOADED);
});
});
</script>
</video>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<title>Load event on HTMLTrackElement and LOADED readyState on TextTrack when src is set from JavaScript</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track>
</video>
<script>
async_test(function(t) {
var track = document.querySelector("track");
assert_equals(track.readyState, HTMLTrackElement.NONE);
track.onload = t.step_func_done(function() {
assert_equals(track.readyState, HTMLTrackElement.LOADED);
});
track.src = "resources/webvtt-file.vtt";
track.track.mode = "hidden";
});
</script>

View file

@ -0,0 +1,34 @@
<!DOCTYPE html>
<title>Cues are properly removed from the active cue list when their track changes mode to disabled</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/captions-gaps.vtt" kind="captions" default >
<script>
async_test(function(t) {
var video = document.querySelector("video");
var testTrack = document.querySelector("track");
video.src = getVideoURI("/media/counting");
video.oncanplaythrough = t.step_func(startTest);
video.onseeked = t.step_func_done(seeked);
function startTest() {
// Set the mode of the text track to "showing".
testTrack.track.mode = "showing";
// Seek to a time with a caption.
video.currentTime = 1.5;
}
function seeked() {
// Set the mode of the text track to "hidden", then to "showing" again.
testTrack.track.mode = "hidden";
testTrack.track.mode = "showing";
// Set the mode of the text track to "disabled".
testTrack.track.mode = "disabled";
}
});
</script>
</video>

View file

@ -0,0 +1,73 @@
<!DOCTYPE html>
<title>A track appended after the initial track configuration does not change other tracks</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track kind="metadata" src="resources/metadata.vtt">
</video>
<script>
async_test(function(t) {
var video = document.querySelector('video');
var track1 = document.querySelectorAll('track')[0];
assert_equals(track1.readyState, HTMLTrackElement.NONE);
assert_equals(track1.track.mode, 'disabled');
video.src = getVideoURI('/media/test');
video.oncanplaythrough = t.step_func(canplaythrough);
track1.onload = t.step_func(metadataTrackLoaded);
function canplaythrough() {
// check initial metadata track state.
assert_equals(track1.readyState, HTMLTrackElement.NONE);
assert_equals(track1.track.mode, 'disabled');
assert_equals(track1.track.cues, null);
track1.track.mode = 'hidden';
}
function metadataTrackLoaded() {
// check metadata track state.
assert_equals(track1.readyState, HTMLTrackElement.LOADED);
assert_equals(track1.track.mode, 'hidden');
assert_equals(track1.track.cues.length, 12);
assert_equals(track1.track.cues[11].startTime, 22);
// Add a caption track, configured to load automatically.
track2 = document.createElement('track');
track2.setAttribute('kind', 'captions');
track2.setAttribute('default', 'default');
track2.setAttribute('src', 'resources/webvtt-file.vtt');
track2.onload = t.step_func(captionsTrackLoaded);
video.appendChild(track2);
}
function captionsTrackLoaded() {
// Check that metadata track state has not changed.
assert_equals(track1.readyState, HTMLTrackElement.LOADED);
assert_equals(track1.track.mode, 'hidden');
// and that the caption track state is correct.
assert_equals(track2.readyState, HTMLTrackElement.LOADED);
assert_equals(track2.track.mode, 'showing');
video.textTracks.onaddtrack = t.step_func_done(trackAdded);
// add a subtitle track with video.addTextTrack().
track3 = video.addTextTrack('subtitles', 'Subtitle Track', 'en');
track3.mode = 'showing';
}
function trackAdded() {
// Check that metadata track state has not changed.
assert_equals(track1.readyState, HTMLTrackElement.LOADED);
assert_equals(track1.track.mode, 'hidden');
// and that the caption track state has not changed.
assert_equals(track2.readyState, HTMLTrackElement.LOADED);
assert_equals(track2.track.mode, 'showing');
// and that the subtitle track state is correct.
assert_equals(event.target, video.textTracks);
assert_true(event instanceof window.TrackEvent);
assert_equals(event.track, video.textTracks[video.textTracks.length - 1]);
assert_equals(track3.mode, 'showing');
}
});
</script>

View file

@ -0,0 +1,37 @@
<!DOCTYPE html>
<title>A "metadata" track does not load automatically, but it does load when the mode is changed</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track kind="metadata" src="resources/metadata.vtt">
</video>
<script>
async_test(function(t) {
var video = document.querySelector("video");
// Check initial metadata track state.
var track = document.querySelectorAll("track")[0];
assert_equals(track.readyState, HTMLTrackElement.NONE);
assert_equals(video.textTracks[0].mode, "disabled");
video.src = getVideoURI("/media/test");
video.oncanplaythrough = t.step_func(canplaythrough);
track.onload = t.step_func_done(trackLoaded);
function trackLoaded() {
assert_equals(track.readyState, HTMLTrackElement.LOADED);
assert_equals(track.track.mode, "hidden");
assert_equals(video.textTracks[0].cues.length, 12);
assert_equals(video.textTracks[0].cues[11].startTime, 22);
}
function canplaythrough() {
assert_equals(track.readyState, HTMLTrackElement.NONE);
assert_equals(video.textTracks[0].mode, "disabled");
assert_equals(video.textTracks[0].cues, null);
// Change metadata track mode so it loads.
video.textTracks[0].mode = "hidden";
}
});
</script>

View file

@ -0,0 +1,61 @@
<!DOCTYPE html>
<title>TextTrack mode attribute</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
<track src="resources/captions-fast.vtt" default>
<script>
async_test(function(t) {
var video = document.querySelector("video");
var track = document.querySelector("track");
track.onload = t.step_func(trackLoaded);
var cueCount = 0;
var textTrack;
function trackLoaded() {
textTrack = track.track;
// Test default attribute value.
assert_equals(textTrack.mode, "showing");
assert_equals(video.textTracks[0].mode, "showing");
// Set to bogus value, should return default.
var value = "bogus";
textTrack.mode = value;
assert_equals(textTrack.mode, "showing");
assert_equals(video.textTracks[0].mode, "showing");
// Set to numeric value (no longer supported), should return default.
textTrack.mode = 2;
assert_equals(textTrack.mode, "showing");
assert_equals(video.textTracks[0].mode, "showing");
// Set to known values.
setModeAndCheck("disabled");
video.src = getVideoURI("/media/test");
video.play();
// Wait for end of first cue (no events should fire while track is disabled).
t.step_timeout(testHiddenAndShowing, 400);
}
track.oncuechange = t.step_func(function(event) {
cueCount++;
if (cueCount == textTrack.cues.length)
t.done();
});
function setModeAndCheck(value) {
textTrack.mode = value;
assert_equals(textTrack.mode, value);
assert_equals(video.textTracks[0].mode, value);
if (value == "disabled")
assert_equals(textTrack.cues, null);
}
function testHiddenAndShowing() {
setModeAndCheck("hidden");
setModeAndCheck("showing");
}
});
</script>
</video>

View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<title>Removing an active cue</title>
<script src="/common/media.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(function(t) {
var video = document.querySelector("video");
video.src = getVideoURI("/media/test");
// Add a text track to the video element.
video.addTextTrack("captions", "regular captions track", "en");
// Add a cue to the track with enter event listener.
var cue = new VTTCue(0, 4, "Random");
cue.onenter = t.step_func_done(removeActiveCue);
var track = video.textTracks[0];
track.addCue(cue);
function removeActiveCue() {
assert_equals(track.activeCues.length, 1);
// Remove the cue while it is active.
track.removeCue(track.activeCues[0]);
// No crash. PASS.
}
// Play the video and remove cue when it becomes active.
video.play();
track.mode = "showing";
});
</script>

Some files were not shown because too many files have changed in this diff Show more