test_bug591815.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=591815
  5. -->
  6. <head>
  7. <title>Test for Bug 591815</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 onload="setTimeout(runTest, 0)">
  13. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=591815">Mozilla Bug 591815</a>
  14. <p id="display"></p>
  15. <div id="content">
  16. <div id="wrapper">
  17. <!-- 20x20 of red -->
  18. <img id="image" ondragstart="fail();"
  19. src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAAG0lEQVR42mP8z0A%2BYKJA76jmUc2jmkc1U0EzACKcASfOgGoMAAAAAElFTkSuQmCC"/>
  20. </div>
  21. </div>
  22. <pre id="test">
  23. <script type="application/javascript">
  24. /** Test for Bug 591815 **/
  25. SimpleTest.waitForExplicitFinish();
  26. function fail() {
  27. ok(false, "drag started but should not have");
  28. }
  29. function runTest() {
  30. var image = document.getElementById("image");
  31. var wrapper = document.getElementById("wrapper");
  32. var preventDefault = function(event) {
  33. event.preventDefault();
  34. };
  35. wrapper.addEventListener('mousedown', preventDefault, false);
  36. synthesizeMouse(image, 3, 3, { type: "mousedown"});
  37. synthesizeMouse(image, 53, 53, { type: "mousemove"});
  38. synthesizeMouse(image, 53, 53, { type: "mouseup"});
  39. wrapper.removeEventListener('mousedown', preventDefault, false);
  40. var relocateElementAndPreventDefault = function(event) {
  41. document.body.appendChild(wrapper);
  42. event.preventDefault();
  43. }
  44. wrapper.addEventListener('mousedown', relocateElementAndPreventDefault, false);
  45. synthesizeMouse(image, 3, 3, { type: "mousedown"});
  46. synthesizeMouse(image, 53, 53, { type: "mousemove"});
  47. synthesizeMouse(image, 53, 53, { type: "mouseup"});
  48. wrapper.removeEventListener('mousedown', relocateElementAndPreventDefault, false);
  49. ok(true, "passed the test");
  50. SimpleTest.finish();
  51. }
  52. </script>
  53. </pre>
  54. </body>
  55. </html>