Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=603550 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 603550</title> |
michael@0 | 8 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 10 | <style> |
michael@0 | 11 | .test { |
michael@0 | 12 | width: 20px; |
michael@0 | 13 | height: 20px; |
michael@0 | 14 | border: 1px solid black; |
michael@0 | 15 | -moz-user-select: none; |
michael@0 | 16 | } |
michael@0 | 17 | </style> |
michael@0 | 18 | </head> |
michael@0 | 19 | <body onload="setTimeout('runTest()', 0)"> |
michael@0 | 20 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=603550">Mozilla Bug 603550</a> |
michael@0 | 21 | <p id="display"></p> |
michael@0 | 22 | <div id="content" style="display: none"> |
michael@0 | 23 | |
michael@0 | 24 | </div> |
michael@0 | 25 | <pre id="test"> |
michael@0 | 26 | <script type="application/javascript"> |
michael@0 | 27 | |
michael@0 | 28 | /** Test for Bug 603550 **/ |
michael@0 | 29 | |
michael@0 | 30 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 31 | |
michael@0 | 32 | function sendMouseMoveFaraway(el) { |
michael@0 | 33 | var rect = el.getBoundingClientRect(); |
michael@0 | 34 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 35 | utils.sendMouseEvent('mousemove', rect.left + 5000, rect.top + 5000, 0, 0, 0); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function sendMouseDown(el) { |
michael@0 | 39 | var rect = el.getBoundingClientRect(); |
michael@0 | 40 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 41 | utils.sendMouseEvent('mousedown', rect.left + 5, rect.top + 5, 0, 1, 0); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function sendMouseUp(el) { |
michael@0 | 45 | var rect = el.getBoundingClientRect(); |
michael@0 | 46 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 47 | utils.sendMouseEvent('mouseup', rect.left + 5, rect.top + 5, 0, 1, 0); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | function fireEvent(target, event) { |
michael@0 | 51 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 52 | utils.dispatchDOMEventViaPresShell(target, event, true); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function fireDrop(element) { |
michael@0 | 56 | var ds = SpecialPowers.Cc["@mozilla.org/widget/dragservice;1"]. |
michael@0 | 57 | getService(SpecialPowers.Ci.nsIDragService); |
michael@0 | 58 | |
michael@0 | 59 | ds.startDragSession(); |
michael@0 | 60 | |
michael@0 | 61 | var event = document.createEvent("DragEvents"); |
michael@0 | 62 | event.initDragEvent("dragover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null); |
michael@0 | 63 | fireEvent(element, event); |
michael@0 | 64 | |
michael@0 | 65 | event = document.createEvent("DragEvents"); |
michael@0 | 66 | event.initDragEvent("drop", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null); |
michael@0 | 67 | fireEvent(element, event); |
michael@0 | 68 | |
michael@0 | 69 | ds.endDragSession(false); |
michael@0 | 70 | ok(!ds.getCurrentSession(), "There shouldn't be a drag session anymore!"); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function runTest() { |
michael@0 | 74 | var d1 = document.getElementById("d1"); |
michael@0 | 75 | var didGetMouseMove = false; |
michael@0 | 76 | sendMouseDown(d1); |
michael@0 | 77 | document.addEventListener("mousemove", |
michael@0 | 78 | function (e) { |
michael@0 | 79 | didGetMouseMove = (e.target == document); |
michael@0 | 80 | }, |
michael@0 | 81 | true); |
michael@0 | 82 | sendMouseMoveFaraway(d1); |
michael@0 | 83 | ok(didGetMouseMove, "Should have got mousemove!"); |
michael@0 | 84 | sendMouseUp(d1); |
michael@0 | 85 | |
michael@0 | 86 | didGetMouseMove = false; |
michael@0 | 87 | document.addEventListener("mousedown", |
michael@0 | 88 | function (e) { |
michael@0 | 89 | e.preventDefault(); |
michael@0 | 90 | }, |
michael@0 | 91 | true); |
michael@0 | 92 | sendMouseDown(d1); |
michael@0 | 93 | sendMouseMoveFaraway(d1); |
michael@0 | 94 | ok(didGetMouseMove, "Should have got mousemove! (2)"); |
michael@0 | 95 | sendMouseUp(d1); |
michael@0 | 96 | |
michael@0 | 97 | didGetMouseMove = false; |
michael@0 | 98 | sendMouseDown(d1); |
michael@0 | 99 | fireDrop(d1); |
michael@0 | 100 | sendMouseMoveFaraway(d1); |
michael@0 | 101 | ok(!didGetMouseMove, "Shouldn't have got mousemove!"); |
michael@0 | 102 | |
michael@0 | 103 | |
michael@0 | 104 | |
michael@0 | 105 | SimpleTest.finish(); |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | |
michael@0 | 109 | </script> |
michael@0 | 110 | </pre> |
michael@0 | 111 | <div class="test" id="d1"> </div> |
michael@0 | 112 | </body> |
michael@0 | 113 | </html> |