summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webvtt/webvtt-api-for-browsers/vttcue-interface/getCueAsHTML.html
blob: 5be09a5d3479f3ad82c3c76053e3e73de3d5e4d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!doctype html>
<title>VTTCue.getCueAsHTML()</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');
    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><00: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, '00:00:00.500', 'data');
    assert_true(frag.childNodes[8] instanceof ProcessingInstruction, 'instanceof');
}, document.title+', <00: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>