tor-browser

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

tBodies.html (1300B)


      1 <!DOCTYPE html>
      2 <title>HTMLTableElement.tBodies</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 text =
      9    '<html xmlns="http://www.w3.org/1999/xhtml">' +
     10    '  <head>' +
     11    '    <title>Virtual Library</title>' +
     12    '  </head>' +
     13    '  <body>' +
     14    '    <table id="mytable" border="1">' +
     15    '      <tbody>' +
     16    '        <tr><td>Cell 1</td><td>Cell 2</td></tr>' +
     17    '        <tr><td>Cell 3</td><td>Cell 4</td></tr>' +
     18    '      </tbody>' +
     19    '    </table>' +
     20    '  </body>' +
     21    '</html>';
     22 
     23  var parser = new DOMParser();
     24  var doc = parser.parseFromString(text, "text/xml");
     25 
     26  // import <table>
     27  var table = doc.documentElement.getElementsByTagName('table')[0];
     28  var mytable = document.body.appendChild(document.importNode(table, true));
     29 
     30  assert_equals(mytable.tBodies.length, 1);
     31  var tbody = document.createElement('tbody');
     32  mytable.appendChild(tbody);
     33  var tr = tbody.insertRow(-1);
     34  tr.insertCell(-1).appendChild(document.createTextNode('Cell 5'));
     35  tr.insertCell(-1).appendChild(document.createTextNode('Cell 6'));
     36  assert_equals(mytable.tBodies.length, 2);
     37  assert_equals(mytable.rows.length, 3);
     38  assert_equals(tr.rowIndex, 2);
     39 });
     40 </script>