test_bug618948.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <script type="application/javascript" 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. /** Test for Bug 618948 **/
  24. var events = ["focus", "input", "change", "invalid" ];
  25. var handled = ({});
  26. function eventHandler(event)
  27. {
  28. dump("\n" + event.type + "\n");
  29. handled[event.type] = true;
  30. }
  31. function beginTest()
  32. {
  33. for (var e of events) {
  34. handled[e] = false;
  35. }
  36. i.focus();
  37. }
  38. function endTest()
  39. {
  40. for (var e of events) {
  41. ok(handled[e], "on" + e + " should have been called");
  42. }
  43. SimpleTest.finish();
  44. }
  45. var i = document.getElementsByTagName('input')[0];
  46. var b = document.getElementsByTagName('button')[0];
  47. i.onfocus = function(event) {
  48. eventHandler(event);
  49. synthesizeKey('f', {});
  50. i.onfocus = null;
  51. };
  52. i.oninput = function(event) {
  53. eventHandler(event);
  54. b.focus();
  55. i.oninput = null;
  56. };
  57. i.onchange = function(event) {
  58. eventHandler(event);
  59. i.onchange = null;
  60. synthesizeMouseAtCenter(b, {});
  61. };
  62. i.oninvalid = function(event) {
  63. eventHandler(event);
  64. i.oninvalid = null;
  65. endTest();
  66. };
  67. SimpleTest.waitForExplicitFinish();
  68. SimpleTest.waitForFocus(beginTest);
  69. </script>
  70. </pre>
  71. </body>
  72. </html>