remove-row.html (1452B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>Delete Row tests</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 7 <table id="element"> 8 <thead> 9 <th>First column</th> 10 <th>Second column</th> 11 </thead> 12 <tbody> 13 <tr> 14 <td>1.1</td> 15 <td>1.2</td> 16 </tr> 17 <tr> 18 <td>2.1</td> 19 <td>2.2</td> 20 </tr> 21 </tbody> 22 </table> 23 24 <script> 25 var el = document.getElementById('element'); 26 27 test(function() { 28 assert_throws_dom("IndexSizeError", function() { 29 el.deleteRow(-2) 30 }) 31 }, 'deleteRow function invalid argument'); 32 test(function() { 33 assert_throws_dom("IndexSizeError", function() { 34 el.deleteRow(el.rows.length) 35 }) 36 }, 'deleteRow function invalid argument bis'); 37 38 test(function() { 39 var old_length = el.rows.length; 40 el.insertRow(-1); 41 el.deleteRow(-1); 42 assert_equals(old_length, el.rows.length); 43 }, "check normal deleteRow"); 44 test(function() { 45 assert_equals(el.rows.length, 3); 46 do { 47 var old_length = el.rows.length; 48 el.deleteRow(-1); 49 assert_equals(el.rows.length, old_length - 1); 50 } while (el.rows.length); 51 }, "check normal deleteRow bis"); 52 53 test(function() { 54 assert_equals(el.rows.length, 0); 55 el.deleteRow(-1); 56 }, 'deleteRow(-1) with no rows'); 57 58 test(function() { 59 assert_equals(el.rows.length, 0); 60 assert_throws_dom("IndexSizeError", function() { 61 el.deleteRow(0); 62 }); 63 }, 'deleteRow(0) with no rows'); 64 </script>