OLD | NEW |
| (Empty) |
1 <!doctype html> | |
2 <title>TextTrackCue.getCueAsHTML()</title> | |
3 <script src=../../../../../resources/testharness.js></script> | |
4 <script src=../../../../../resources/testharnessreport.js></script> | |
5 <div id=log></div> | |
6 <script> | |
7 test(function(){ | |
8 var video = document.createElement('video'); | |
9 var t1 = video.addTextTrack('subtitles'); | |
10 document.body.appendChild(video); | |
11 var c1 = new TextTrackCue(0, 1, '<c></c><c.a.b></c><i></i><b></b><u></u><rub
y><rt></rt></ruby><v></v><v a b></v><00:00:00.500>x\0'); | |
12 t1.addCue(c1); | |
13 window.frag = c1.getCueAsHTML(); | |
14 assert_equals(frag.childNodes.length, 10, 'childNodes.length'); | |
15 assert_true(frag instanceof DocumentFragment, 'getCueAsHTML() should return
DocumentFragment'); | |
16 }, document.title+', creating the cue'); | |
17 test(function(){ | |
18 assert_equals(frag.childNodes[0].namespaceURI, 'http://www.w3.org/1999/xhtml
', 'namespaceURI'); | |
19 assert_equals(frag.childNodes[0].localName, 'span', 'localName'); | |
20 assert_equals(frag.childNodes[0].attributes.length, 0, 'attributes'); | |
21 assert_false(frag.childNodes[0].hasChildNodes(), 'hasChildNodes()'); | |
22 assert_true(frag.childNodes[0] instanceof HTMLElement, 'instanceof'); | |
23 }, document.title+', <c>'); | |
24 test(function(){ | |
25 assert_equals(frag.childNodes[1].namespaceURI, 'http://www.w3.org/1999/xhtml
', 'namespaceURI'); | |
26 assert_equals(frag.childNodes[1].localName, 'span', 'localName'); | |
27 assert_equals(frag.childNodes[1].attributes.length, 1, 'attributes'); | |
28 assert_equals(frag.childNodes[1].getAttributeNS('', 'class'), 'a b', 'class
attribute'); | |
29 assert_false(frag.childNodes[1].hasChildNodes(), 'hasChildNodes()'); | |
30 assert_true(frag.childNodes[1] instanceof HTMLElement, 'instanceof'); | |
31 }, document.title+', <c.a.b>'); | |
32 test(function(){ | |
33 assert_equals(frag.childNodes[2].namespaceURI, 'http://www.w3.org/1999/xhtml
', 'namespaceURI'); | |
34 assert_equals(frag.childNodes[2].localName, 'i', 'localName'); | |
35 assert_equals(frag.childNodes[2].attributes.length, 0, 'attributes'); | |
36 assert_false(frag.childNodes[2].hasChildNodes(), 'hasChildNodes()'); | |
37 assert_true(frag.childNodes[2] instanceof HTMLElement, 'instanceof'); | |
38 }, document.title+', <i>'); | |
39 test(function(){ | |
40 assert_equals(frag.childNodes[3].namespaceURI, 'http://www.w3.org/1999/xhtml
', 'namespaceURI'); | |
41 assert_equals(frag.childNodes[3].localName, 'b', 'localName'); | |
42 assert_equals(frag.childNodes[3].attributes.length, 0, 'attributes'); | |
43 assert_false(frag.childNodes[3].hasChildNodes(), 'hasChildNodes()'); | |
44 assert_true(frag.childNodes[3] instanceof HTMLElement, 'instanceof'); | |
45 }, document.title+', <b>'); | |
46 test(function(){ | |
47 assert_equals(frag.childNodes[4].namespaceURI, 'http://www.w3.org/1999/xhtml
', 'namespaceURI'); | |
48 assert_equals(frag.childNodes[4].localName, 'u', 'localName'); | |
49 assert_equals(frag.childNodes[4].attributes.length, 0, 'attributes'); | |
50 assert_false(frag.childNodes[4].hasChildNodes(), 'hasChildNodes()'); | |
51 assert_true(frag.childNodes[4] instanceof HTMLElement, 'instanceof'); | |
52 }, document.title+', <u>'); | |
53 test(function(){ | |
54 assert_equals(frag.childNodes[5].namespaceURI, 'http://www.w3.org/1999/xhtml
', 'namespaceURI'); | |
55 assert_equals(frag.childNodes[5].localName, 'ruby', 'localName'); | |
56 assert_equals(frag.childNodes[5].attributes.length, 0, 'attributes'); | |
57 assert_true(frag.childNodes[5].hasChildNodes(), 'hasChildNodes()'); | |
58 assert_true(frag.childNodes[5] instanceof HTMLElement, 'instanceof'); | |
59 }, document.title+', <ruby>'); | |
60 test(function(){ | |
61 assert_equals(frag.childNodes[5].firstChild.namespaceURI, 'http://www.w3.org
/1999/xhtml', 'namespaceURI'); | |
62 assert_equals(frag.childNodes[5].firstChild.localName, 'rt', 'localName'); | |
63 assert_equals(frag.childNodes[5].firstChild.attributes.length, 0, 'attribute
s'); | |
64 assert_false(frag.childNodes[5].firstChild.hasChildNodes(), 'hasChildNodes()
'); | |
65 assert_true(frag.childNodes[5].firstChild instanceof HTMLElement, 'instanceo
f'); | |
66 }, document.title+', <rt>'); | |
67 test(function(){ | |
68 assert_equals(frag.childNodes[6].namespaceURI, 'http://www.w3.org/1999/xhtml
', 'namespaceURI'); | |
69 assert_equals(frag.childNodes[6].localName, 'span', 'localName'); | |
70 assert_equals(frag.childNodes[6].attributes.length, 1, 'attributes'); | |
71 assert_equals(frag.childNodes[6].getAttributeNS('', 'title'), '', 'title att
ribute'); | |
72 assert_false(frag.childNodes[6].hasChildNodes(), 'hasChildNodes()'); | |
73 assert_true(frag.childNodes[6] instanceof HTMLElement, 'instanceof'); | |
74 }, document.title+', <v>'); | |
75 test(function(){ | |
76 assert_equals(frag.childNodes[7].namespaceURI, 'http://www.w3.org/1999/xhtml
', 'namespaceURI'); | |
77 assert_equals(frag.childNodes[7].localName, 'span', 'localName'); | |
78 assert_equals(frag.childNodes[7].attributes.length, 1, 'attributes'); | |
79 assert_equals(frag.childNodes[7].getAttributeNS('', 'title'), 'a b', 'title
attribute'); | |
80 assert_false(frag.childNodes[7].hasChildNodes(), 'hasChildNodes()'); | |
81 assert_true(frag.childNodes[7] instanceof HTMLElement, 'instanceof'); | |
82 }, document.title+', <v a b>'); | |
83 test(function(){ | |
84 assert_equals(frag.childNodes[8].target, 'timestamp', 'target'); | |
85 assert_equals(frag.childNodes[8].data, '00:00:00.500', 'data'); | |
86 assert_true(frag.childNodes[8] instanceof ProcessingInstruction, 'instanceof
'); | |
87 }, document.title+', <00:00:00.500>'); | |
88 test(function(){ | |
89 assert_equals(frag.childNodes[9].data, 'x\0', 'data'); | |
90 assert_true(frag.childNodes[9] instanceof Text, 'instanceof'); | |
91 }, document.title+', x\\0'); | |
92 </script> | |
OLD | NEW |