test_bug656954.html 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=656954
  5. -->
  6. <head>
  7. <title>Test for Bug 656954</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=656954">Mozilla Bug 656954</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. </div>
  16. <pre id="test">
  17. <script type="application/javascript">
  18. /** Test for Bug 656954 **/
  19. var e = document.createEvent("Event");
  20. is(e.defaultPrevented, false,
  21. "After creating event defaultPrevented should be false");
  22. e.initEvent("foo", true, true);
  23. var el = document.createElement("div");
  24. el.addEventListener("foo",
  25. function(evt) {
  26. evt.preventDefault();
  27. }, false);
  28. el.dispatchEvent(e);
  29. is(e.defaultPrevented, true, "preventDefault() should have been called!");
  30. e = document.createEvent("Event");
  31. e.initEvent("foo", true, false);
  32. el.dispatchEvent(e);
  33. is(e.defaultPrevented, false, "preventDefault() should not have any effect!");
  34. </script>
  35. </pre>
  36. </body>
  37. </html>