test_bug583514.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=583514
  5. -->
  6. <head>
  7. <title>Test for Bug 583514</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=583514">Mozilla Bug 583514</a>
  13. <p id="display"></p>
  14. <div id="content">
  15. <input>
  16. </div>
  17. <pre id="test">
  18. <script type="application/javascript">
  19. /** Test for Bug 583514 **/
  20. var gExpectDivClick = false;
  21. var gExpectInputClick = false;
  22. var div = document.getElementById('content');
  23. var input = document.getElementsByTagName('input')[0];
  24. div.addEventListener('click', function() {
  25. ok(gExpectDivClick, "click event received on div and expected status was: " +
  26. gExpectDivClick);
  27. }, false);
  28. input.addEventListener('click', function() {
  29. ok(gExpectInputClick, "click event received on input and expected status was: " +
  30. gExpectInputClick);
  31. }, false);
  32. SimpleTest.waitForExplicitFinish();
  33. SimpleTest.waitForFocus(function() {
  34. var body = document.body;
  35. body.addEventListener('click', function(aEvent) {
  36. if (aEvent.target == input) {
  37. body.removeEventListener('click', arguments.callee, false);
  38. }
  39. ok(true, "click event received on body");
  40. SimpleTest.executeSoon(function() {
  41. isnot(document.activeElement, input, "input shouldn't have been focused");
  42. isnot(document.activeElement, div, "div shouldn't have been focused");
  43. if (aEvent.target == input) {
  44. SimpleTest.finish();
  45. } else {
  46. gExpectDivClick = true;
  47. gExpectInputClick = true;
  48. input.click();
  49. }
  50. });
  51. }, false);
  52. gExpectDivClick = true;
  53. div.click();
  54. });
  55. </script>
  56. </pre>
  57. </body>
  58. </html>