deleteRow.html (1636B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>HTMLTableSectionElement#deleteRow</title> 4 <link rel="author" title="Intel" href="http://www.intel.com/"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <div id ="log"></div> 9 10 <table> 11 <tbody id="testBody"> 12 <tr><td>ABCDEF</td></tr> 13 <tr><td>12345</td></tr> 14 <tr><td>ABC12345DEF</td></tr> 15 </tbody> 16 </table> 17 18 <script> 19 20 var tbody = document.getElementById("testBody"); 21 22 test(function () { 23 tbody.deleteRow(0); 24 assert_equals(tbody.rows.length, 2); 25 assert_equals(tbody.rows[0].childNodes[0].innerHTML, "12345"); 26 }, "HTMLTableSectionElement deleteRow(0)"); 27 28 test(function () { 29 tbody.deleteRow(-1); 30 assert_equals(tbody.rows.length, 1); 31 assert_equals(tbody.rows[0].childNodes[0].innerHTML, "12345"); 32 }, "HTMLTableSectionElement deleteRow(-1)"); 33 34 test(function () { 35 assert_throws_dom("IndexSizeError", function () { 36 tbody.deleteRow(tbody.rows.length); 37 }); 38 }, "HTMLTableSectionElement deleteRow(rows.length)"); 39 40 test(function () { 41 assert_throws_dom("IndexSizeError", function () { 42 tbody.deleteRow(-2); 43 }); 44 }, "HTMLTableSectionElement deleteRow(-2)"); 45 46 test(function () { 47 assert_equals(tbody.rows.length, 1); 48 tbody.deleteRow(-1); 49 assert_equals(tbody.rows.length, 0); 50 tbody.deleteRow(-1); 51 assert_equals(tbody.rows.length, 0); 52 }, "HTMLTableSectionElement deleteRow(-1) with no rows"); 53 54 test(function () { 55 assert_equals(tbody.rows.length, 0); 56 assert_throws_dom("IndexSizeError", function () { 57 tbody.deleteRow(0); 58 }); 59 }, "HTMLTableSectionElement deleteRow(0) with no rows"); 60 61 </script>