| OLD | NEW |
| (Empty) |
| 1 <p>Test that SELECT is in correct state when handling a DOM modification event f
or option removing.</p> | |
| 2 <form> | |
| 3 <select ><option selected>1</option><option>2</option></select> | |
| 4 <select multiple><option selected>1</option><option selected>2</option></select> | |
| 5 <select multiple></select> | |
| 6 </form> | |
| 7 <div id=res></div> | |
| 8 <script> | |
| 9 if (window.testRunner) | |
| 10 testRunner.dumpAsText(); | |
| 11 | |
| 12 function log(msg) | |
| 13 { | |
| 14 var r = document.getElementById('res'); | |
| 15 r.innerHTML = r.innerHTML + "<br>" + msg; | |
| 16 } | |
| 17 | |
| 18 var theSelect; | |
| 19 | |
| 20 function testResults(expectedArr) | |
| 21 { | |
| 22 var resultsArr = new Array(theSelect.options.length); | |
| 23 | |
| 24 var i; | |
| 25 for (i=0; i < theSelect.options.length; i++) { | |
| 26 resultsArr[i] = theSelect.options[i].selected; | |
| 27 } | |
| 28 var successString = "Failed"; | |
| 29 var success = false; | |
| 30 if (expectedArr.join() == resultsArr.join()) { | |
| 31 success = true; | |
| 32 successString = "Passed"; | |
| 33 } | |
| 34 | |
| 35 log(successString); | |
| 36 if (!success) { | |
| 37 log("<pre> Expected: " + expectedArr.join() + "<br>" + " Act
ual: " + resultsArr.join() + "</pre>"); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 function subtreeModified() | |
| 42 { | |
| 43 testResults([true], theSelect); | |
| 44 } | |
| 45 | |
| 46 function nodeInserted() | |
| 47 { | |
| 48 testResults([false], theSelect); | |
| 49 } | |
| 50 | |
| 51 try { | |
| 52 theSelect = document.forms[0].elements[0]; | |
| 53 theSelect.addEventListener("DOMSubtreeModified", subtreeModified, true); | |
| 54 theSelect.remove(theSelect.options[0]); | |
| 55 | |
| 56 theSelect = document.forms[0].elements[1]; | |
| 57 theSelect.addEventListener("DOMSubtreeModified", subtreeModified, true); | |
| 58 theSelect.remove(theSelect.options[0]); | |
| 59 | |
| 60 theSelect = document.forms[0].elements[2]; | |
| 61 theSelect.addEventListener("DOMNodeInserted", nodeInserted, true); | |
| 62 theSelect.options.add(new Option("2", "2", false, false), 0); | |
| 63 | |
| 64 } catch (ex) { | |
| 65 alert(ex); | |
| 66 } | |
| 67 </script> | |
| OLD | NEW |