insertRow-method-02.html (1100B)
1 <!DOCTYPE html> 2 <title>insertRow(): Empty table</title> 3 <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-insertrow"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <div id="log"></div> 8 <div id="test"> 9 <table></table> 10 </div> 11 <script> 12 var HTML = "http://www.w3.org/1999/xhtml"; 13 test(function() { 14 var table = document.getElementById("test").getElementsByTagName("table")[0]; 15 test(function() { 16 assert_equals(table.childNodes.length, 0); 17 assert_equals(table.rows.length, 0); 18 }, "table should start out empty") 19 20 var tr; 21 test(function() { 22 tr = table.insertRow(0); 23 assert_equals(tr.localName, "tr"); 24 assert_equals(tr.namespaceURI, HTML); 25 }, "insertRow should insert a tr element") 26 27 var tbody = tr.parentNode; 28 test(function() { 29 assert_equals(tbody.localName, "tbody"); 30 assert_equals(tbody.namespaceURI, HTML); 31 assert_equals(tbody.parentNode, table); 32 }, "insertRow should insert a tbody element") 33 }); 34 </script>