test_bug618948.html (1656B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=618948 5 --> 6 <head> 7 <title>Test for Bug 618948</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=618948">Mozilla Bug 618948</a> 14 <p id="display"></p> 15 <div id="content"> 16 <form> 17 <input type='email' id='i'> 18 <button>submit</button> 19 </form> 20 </div> 21 <pre id="test"> 22 <script type="application/javascript"> 23 24 /** Test for Bug 618948 */ 25 26 var events = ["focus", "input", "change", "invalid" ]; 27 28 var handled = ({}); 29 30 function eventHandler(event) 31 { 32 dump("\n" + event.type + "\n"); 33 handled[event.type] = true; 34 } 35 36 function beginTest() 37 { 38 for (var e of events) { 39 handled[e] = false; 40 } 41 42 i.focus(); 43 } 44 45 function endTest() 46 { 47 for (var e of events) { 48 ok(handled[e], "on" + e + " should have been called"); 49 } 50 51 SimpleTest.finish(); 52 } 53 54 var i = document.getElementsByTagName('input')[0]; 55 var b = document.getElementsByTagName('button')[0]; 56 57 i.onfocus = function(event) { 58 eventHandler(event); 59 sendString("f"); 60 i.onfocus = null; 61 }; 62 63 i.oninput = function(event) { 64 eventHandler(event); 65 b.focus(); 66 i.oninput = null; 67 }; 68 69 i.onchange = function(event) { 70 eventHandler(event); 71 i.onchange = null; 72 synthesizeMouseAtCenter(b, {}); 73 }; 74 75 i.oninvalid = function(event) { 76 eventHandler(event); 77 i.oninvalid = null; 78 endTest(); 79 }; 80 81 SimpleTest.waitForExplicitFinish(); 82 83 SimpleTest.waitForFocus(beginTest); 84 85 </script> 86 </pre> 87 </body> 88 </html>