test_bug622558.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=622558
  5. -->
  6. <head>
  7. <title>Test for Bug 622558</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=622558">Mozilla Bug 622558</a>
  14. <p id="display"></p>
  15. <div id="content">
  16. <form>
  17. <input>
  18. <textarea></textarea>
  19. <select><option>foo</option></select>
  20. </div>
  21. <pre id="test">
  22. <script type="application/javascript">
  23. // Bug 940203
  24. if (navigator.platform.startsWith("Win")) {
  25. SimpleTest.expectAssertions(0, 1);
  26. }
  27. /** Test for Bug 622558 **/
  28. function checkSelectors(aElement)
  29. {
  30. ok(aElement.matches(":-moz-ui-invalid"),
  31. ":-moz-ui-invalid should match for " + aElement);
  32. ok(!aElement.matches(":-moz-ui-valid"),
  33. ":-moz-ui-valid should not match for " + aElement);
  34. }
  35. var input = document.getElementsByTagName('input')[0];
  36. var textarea = document.getElementsByTagName('textarea')[0];
  37. var select = document.getElementsByTagName('select')[0];
  38. select.addEventListener("focus", function() {
  39. select.removeEventListener("focus", arguments.callee, false);
  40. SimpleTest.executeSoon(function() {
  41. select.setCustomValidity('foo');
  42. SimpleTest.executeSoon(function() {
  43. checkSelectors(select);
  44. SimpleTest.finish();
  45. });
  46. });
  47. }, false);
  48. textarea.addEventListener("focus", function() {
  49. textarea.removeEventListener("focus", arguments.callee, false);
  50. SimpleTest.executeSoon(function() {
  51. textarea.setCustomValidity('foo');
  52. SimpleTest.executeSoon(function() {
  53. checkSelectors(textarea);
  54. select.focus();
  55. });
  56. });
  57. }, false);
  58. input.addEventListener("focus", function() {
  59. input.removeEventListener("focus", arguments.callee, false);
  60. SimpleTest.executeSoon(function() {
  61. input.setCustomValidity('foo');
  62. SimpleTest.executeSoon(function() {
  63. checkSelectors(input);
  64. textarea.focus();
  65. });
  66. });
  67. }, false);
  68. SimpleTest.waitForExplicitFinish();
  69. SimpleTest.waitForFocus(function() {
  70. input.focus();
  71. });
  72. </script>
  73. </pre>
  74. </body>
  75. </html>