test_fromUserInput.html (3124B)
1 <html> 2 3 <head> 4 <title>Testing of isFromUserInput in text events</title> 5 6 <link rel="stylesheet" type="text/css" 7 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 8 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> 11 12 <script type="application/javascript" 13 src="../common.js"></script> 14 <script type="application/javascript" 15 src="../events.js"></script> 16 17 <script type="application/javascript"> 18 19 /** 20 * Remove text data from HTML input. 21 */ 22 function removeTextFromInput(aID, aStart, aEnd, aText, aFromUser) { 23 this.DOMNode = getNode(aID); 24 25 this.eventSeq = [ 26 new textChangeChecker(aID, aStart, aEnd, aText, false, aFromUser), 27 ]; 28 29 this.invoke = function removeTextFromInput_invoke() { 30 this.DOMNode.focus(); 31 this.DOMNode.setSelectionRange(aStart, aEnd); 32 33 synthesizeKey("KEY_Delete"); 34 }; 35 36 this.getID = function removeTextFromInput_getID() { 37 return "Remove text from " + aStart + " to " + aEnd + " for " + 38 prettyName(aID); 39 }; 40 } 41 42 /** 43 * Remove text data from text node. 44 */ 45 function removeTextFromContentEditable(aID, aStart, aEnd, aText, aFromUser) { 46 this.DOMNode = getNode(aID); 47 48 this.eventSeq = [ 49 new textChangeChecker(aID, aStart, aEnd, aText, false, aFromUser), 50 ]; 51 52 this.invoke = function removeTextFromContentEditable_invoke() { 53 this.DOMNode.focus(); 54 this.textNode = getNode(aID).firstChild; 55 var selection = window.getSelection(); 56 var range = document.createRange(); 57 range.setStart(this.textNode, aStart); 58 range.setEnd(this.textNode, aEnd); 59 selection.addRange(range); 60 61 synthesizeKey("KEY_Delete"); 62 }; 63 64 this.getID = function removeTextFromContentEditable_getID() { 65 return "Remove text from " + aStart + " to " + aEnd + " for " + 66 prettyName(aID); 67 }; 68 } 69 70 // ////////////////////////////////////////////////////////////////////////// 71 // Do tests 72 // gA11yEventDumpID = "eventdump"; // debug stuff 73 74 var gQueue = null; 75 76 function doTests() { 77 gQueue = new eventQueue(); 78 79 // Focused editable text node 80 gQueue.push(new removeTextFromContentEditable("div", 0, 3, "hel", true)); 81 82 // Focused editable HTML input 83 gQueue.push(new removeTextFromInput("input", 1, 2, "n", true)); 84 85 gQueue.invoke(); // Will call SimpleTest.finish() 86 } 87 88 SimpleTest.waitForExplicitFinish(); 89 addA11yLoadEvent(doTests); 90 91 </script> 92 </head> 93 94 95 <body> 96 <a target="_blank" 97 href="https://bugzilla.mozilla.org/show_bug.cgi?id=686909" 98 title="isFromUserInput flag on accessible text change events not correct"> 99 Mozilla Bug 686909 100 </a> 101 102 <p id="display"></p> 103 <div id="content" style="display: none"></div> 104 <pre id="test"></pre> 105 <div id="eventdump"></div> 106 107 <div id="div" contentEditable="true">hello</div> 108 <input id="input" value="input"> 109 110 </body> 111 112 </html>