| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body onload="startTests()"> | |
| 7 <input id="inputId" value="abcd"></input> | |
| 8 <textarea id="textAreaId">abcd</textarea> | |
| 9 <script> | |
| 10 description("Test select event is triggered on input and textarea Elements."); | |
| 11 var input = document.getElementById("inputId"); | |
| 12 var textarea = document.getElementById("textAreaId"); | |
| 13 var jsTestIsAsync = true; | |
| 14 var currentCase; | |
| 15 var lastCase; | |
| 16 | |
| 17 var tests = [ | |
| 18 function() { | |
| 19 input.focus(); | |
| 20 return "input.focus()"; | |
| 21 }, | |
| 22 function() { | |
| 23 input.select(); | |
| 24 return "input.select()"; | |
| 25 }, | |
| 26 function() { | |
| 27 input.setSelectionRange(1, 2); | |
| 28 return "input.setSelectionRange()"; | |
| 29 }, | |
| 30 function() { | |
| 31 input.setRangeText("efgh"); | |
| 32 return "input.setRangeText()"; | |
| 33 }, | |
| 34 function() { | |
| 35 input.selectionStart = 1; | |
| 36 return "input.selectionStart"; | |
| 37 }, | |
| 38 function() { | |
| 39 input.selectionEnd = 3; | |
| 40 return "input.selectionEnd"; | |
| 41 }, | |
| 42 function() { | |
| 43 input.selectionDirection = "forward"; | |
| 44 return "input.selectionDirection"; | |
| 45 }, | |
| 46 function() { | |
| 47 textarea.focus(); | |
| 48 return "textarea.focus()"; | |
| 49 }, | |
| 50 function() { | |
| 51 textarea.select(); | |
| 52 return "textarea.select()"; | |
| 53 }, | |
| 54 function() { | |
| 55 textarea.setSelectionRange(1, 2); | |
| 56 return "textarea.setSelectionRange()"; | |
| 57 }, | |
| 58 function() { | |
| 59 textarea.setRangeText("efgh"); | |
| 60 return "textarea.setRangeText()"; | |
| 61 }, | |
| 62 function() { | |
| 63 textarea.selectionStart = 1; | |
| 64 return "textarea.selectionStart"; | |
| 65 }, | |
| 66 function() { | |
| 67 textarea.selectionEnd = 3; | |
| 68 return "textarea.selectionEnd"; | |
| 69 }, | |
| 70 function() { | |
| 71 textarea.selectionDirection = "forward"; | |
| 72 return "textarea.selectionDirection"; | |
| 73 } | |
| 74 ]; | |
| 75 | |
| 76 function runNext() { | |
| 77 if (tests.length <= 0) | |
| 78 finishJSTest(); | |
| 79 currentCase = tests.shift()(); | |
| 80 } | |
| 81 | |
| 82 function handleSelectEvent() { | |
| 83 if (lastCase == currentCase) { | |
| 84 testFailed("The above test dispatched mulitiple select events."); | |
| 85 return; | |
| 86 } | |
| 87 testPassed(currentCase); | |
| 88 lastCase = currentCase; | |
| 89 setTimeout(runNext, 0); | |
| 90 } | |
| 91 | |
| 92 function startTests() { | |
| 93 input.addEventListener("select", handleSelectEvent); | |
| 94 textarea.addEventListener("select", handleSelectEvent); | |
| 95 runNext(); | |
| 96 } | |
| 97 </script> | |
| 98 </body> | |
| 99 </html> | |
| OLD | NEW |