test_integer_attr_with_leading_zero.html (1525B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>Test for parsing of integer attributes with leading zero</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <div id="log"></div> 7 <script> 8 var td = document.createElement("td"); 9 var li = document.createElement("li"); 10 // Array of tests: "values" are the values to set, "tdreflection" is the 11 // corresponding td.rowspan value, "lireflection" is the corresponding li.value 12 // value. 13 var testData = [ 14 { 15 values: [ 16 "2", 17 "02", 18 "002", 19 "00002", 20 ], 21 tdreflection: 2, 22 lireflection: 2, 23 }, 24 { 25 values: [ 26 "-2", 27 "-02", 28 "-002", 29 "-00002", 30 ], 31 tdreflection: 1, 32 lireflection: -2, 33 }, 34 { 35 values: [ 36 "-0", 37 "-00", 38 "0", 39 "00", 40 ], 41 tdreflection: 0, 42 lireflection: 0, 43 }, 44 ]; 45 46 for (var data of testData) { 47 for (var value of data.values) { 48 td.setAttribute("rowspan", value); 49 li.setAttribute("value", value); 50 test(function() { 51 assert_equals(td.rowSpan, data.tdreflection); 52 }, `<td> reflection for ${value}`); 53 test(function() { 54 assert_equals(td.getAttribute("rowspan"), value); 55 }, `<td> setAttribute roundtripping for ${value}`); 56 test(function() { 57 assert_equals(li.value, data.lireflection); 58 }, `<li> reflection for ${value}`); 59 test(function() { 60 assert_equals(li.getAttribute("value"), value); 61 }, `<li> setAttribute roundtripping for ${value}`); 62 } 63 } 64 </script>