tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

getCueAsHTML.html (5520B)


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