test_bug1250401.html (2845B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1250401 5 --> 6 <head> 7 <title>Test for Bug 1250401</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1250401">Bug 1250401</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 </div> 16 <pre id="test"> 17 <script class="testbody" type="text/javascript"> 18 19 /** Test for Bug 1250401 */ 20 function test_add() { 21 var select = document.createElement("select"); 22 23 var g1 = document.createElement("optgroup"); 24 var o1 = document.createElement("option"); 25 g1.appendChild(o1); 26 select.appendChild(g1); 27 28 var g2 = document.createElement("optgroup"); 29 var o2 = document.createElement("option"); 30 g2.appendChild(o2); 31 select.add(g2, 0); 32 33 is(select.children.length, 1, "Select has 1 item"); 34 is(select.firstChild, g1, "First item is g1"); 35 is(select.firstChild.children.length, 2, "g2 has 2 children"); 36 is(select.firstChild.children[0], g2, "g1 has 2 children: g2"); 37 is(select.firstChild.children[1], o1, "g1 has 2 children: o1"); 38 is(o1.index, 0, "o1.index should be 0"); 39 is(o2.index, 0, "o2.index should be 0"); 40 } 41 42 function test_append() { 43 var select = document.createElement("select"); 44 45 var g1 = document.createElement("optgroup"); 46 var o1 = document.createElement("option"); 47 g1.appendChild(o1); 48 select.appendChild(g1); 49 50 var g2 = document.createElement("optgroup"); 51 var o2 = document.createElement("option"); 52 g2.appendChild(o2); 53 g1.appendChild(g2); 54 55 is(select.children.length, 1, "Select has 1 item"); 56 is(select.firstChild, g1, "First item is g1"); 57 is(select.firstChild.children.length, 2, "g2 has 2 children"); 58 is(select.firstChild.children[0], o1, "g1 has 2 children: o1"); 59 is(select.firstChild.children[1], g2, "g1 has 2 children: g1"); 60 is(o1.index, 0, "o1.index should be 0"); 61 is(o2.index, 0, "o2.index should be 0"); 62 } 63 64 function test_no_select() { 65 var g1 = document.createElement("optgroup"); 66 var o1 = document.createElement("option"); 67 g1.appendChild(o1); 68 69 var g2 = document.createElement("optgroup"); 70 var o2 = document.createElement("option"); 71 g2.appendChild(o2); 72 g1.appendChild(g2); 73 74 is(g1.children.length, 2, "g2 has 2 children"); 75 is(g1.children[0], o1, "g1 has 2 children: o1"); 76 is(g1.children[1], g2, "g1 has 2 children: g1"); 77 is(o1.index, 0, "o1.index should be 0"); 78 is(o2.index, 0, "o2.index should be 0"); 79 } 80 81 function test_no_parent() { 82 var o1 = document.createElement("option"); 83 var o2 = document.createElement("option"); 84 85 is(o1.index, 0, "o1.index should be 0"); 86 is(o2.index, 0, "o2.index should be 0"); 87 } 88 89 test_add(); 90 test_append(); 91 test_no_select(); 92 test_no_parent(); 93 94 </script> 95 </pre> 96 </body> 97 </html>