options-length-too-large.html (1557B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="timeout" content="long"> 6 <title>select options.length too large</title> 7 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 </head> 11 <body> 12 <select id="test"> 13 <option value="1"></option> 14 <option value="2"></option> 15 <option value="3"></option> 16 </select> 17 18 <script> 19 var mySelect = document.getElementById("test"); 20 21 test(function() { 22 mySelect.options.length = -1; 23 assert_equals(mySelect.options.length, 3, "Length of <select> should remain unchanged"); 24 }); 25 26 test(function() { 27 mySelect.options.length = 100001; 28 assert_equals(mySelect.options.length, 3, "Length of <select> should remain unchanged"); 29 }); 30 31 test(function() { 32 mySelect.options.length = Number.MAX_SAFE_INTEGER; 33 assert_equals(mySelect.options.length, 3, "Length of <select> should remain unchanged"); 34 }); 35 36 test(function() { 37 mySelect.options.length = 100000; 38 assert_equals(mySelect.options.length, 100000, "Length of <select> should be 100,000"); 39 }); 40 41 test(function() { 42 mySelect.appendChild(new Option()); 43 mySelect.appendChild(new Option()); 44 assert_equals(mySelect.options.length, 100002, "Manual expansion still works"); 45 mySelect.options.length = 100001; 46 assert_equals(mySelect.options.length, 100001, "Truncation works if over the limit"); 47 }); 48 </script> 49 </body> 50 </html>