Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=582771 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 582771</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=582771">Mozilla Bug 582771</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 582771 **/ |
michael@0 | 29 | |
michael@0 | 30 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 31 | var d1; |
michael@0 | 32 | var d2; |
michael@0 | 33 | var d1mousemovecount = 0; |
michael@0 | 34 | var d2mousemovecount = 0; |
michael@0 | 35 | |
michael@0 | 36 | function sendMouseMove(el) { |
michael@0 | 37 | var rect = el.getBoundingClientRect(); |
michael@0 | 38 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 39 | utils.sendMouseEvent('mousemove', rect.left + 5, rect.top + 5, 0, 0, 0); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | function sendMouseDown(el) { |
michael@0 | 43 | var rect = el.getBoundingClientRect(); |
michael@0 | 44 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 45 | utils.sendMouseEvent('mousedown', rect.left + 5, rect.top + 5, 0, 1, 0); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | function sendMouseUp(el) { |
michael@0 | 49 | var rect = el.getBoundingClientRect(); |
michael@0 | 50 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 51 | utils.sendMouseEvent('mouseup', rect.left + 5, rect.top + 5, 0, 1, 0); |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function log(s) { |
michael@0 | 55 | document.getElementById("l").textContent += s + "\n"; |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function d2Listener(e) { |
michael@0 | 59 | log(e.type + ", " + e.target.id); |
michael@0 | 60 | is(e.target, d2, "d2 should have got mousemove."); |
michael@0 | 61 | ++d2mousemovecount; |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | function d1Listener(e) { |
michael@0 | 65 | log(e.type + ", " + e.target.id); |
michael@0 | 66 | d1.setCapture(true); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function d1Listener2(e) { |
michael@0 | 70 | log(e.type + ", " + e.target.id); |
michael@0 | 71 | d2.setCapture(true); |
michael@0 | 72 | } |
michael@0 | 73 | |
michael@0 | 74 | function d1MouseMoveListener(e) { |
michael@0 | 75 | log(e.type + ", " + e.target.id); |
michael@0 | 76 | ++d1mousemovecount; |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | function runTest() { |
michael@0 | 80 | d1 = document.getElementById("d1"); |
michael@0 | 81 | d2 = document.getElementById("d2"); |
michael@0 | 82 | d2.addEventListener("mousemove", d2Listener, true); |
michael@0 | 83 | document.body.offsetLeft; |
michael@0 | 84 | sendMouseMove(d2); |
michael@0 | 85 | is(d2mousemovecount, 1, "Should have got mousemove"); |
michael@0 | 86 | |
michael@0 | 87 | // This shouldn't enable capturing, since we're not in a right kind of |
michael@0 | 88 | // event listener. |
michael@0 | 89 | d1.setCapture(true); |
michael@0 | 90 | sendMouseDown(d1); |
michael@0 | 91 | sendMouseMove(d2); |
michael@0 | 92 | sendMouseUp(d1); |
michael@0 | 93 | is(d2mousemovecount, 2, "Should have got mousemove"); |
michael@0 | 94 | |
michael@0 | 95 | d1.addEventListener("mousedown", d1Listener, true); |
michael@0 | 96 | d1.addEventListener("mousemove", d1MouseMoveListener, true); |
michael@0 | 97 | sendMouseDown(d1); |
michael@0 | 98 | sendMouseMove(d2); |
michael@0 | 99 | is(d2mousemovecount, 2, "Shouldn't have got mousemove"); |
michael@0 | 100 | is(d1mousemovecount, 1, "Should have got mousemove"); |
michael@0 | 101 | sendMouseUp(d1); |
michael@0 | 102 | d1.removeEventListener("mousedown", d1Listener, true); |
michael@0 | 103 | d1.removeEventListener("mousemove", d1MouseMoveListener, true); |
michael@0 | 104 | |
michael@0 | 105 | // Nothing should be capturing the event. |
michael@0 | 106 | sendMouseMove(d2); |
michael@0 | 107 | is(d2mousemovecount, 3, "Should have got mousemove"); |
michael@0 | 108 | |
michael@0 | 109 | |
michael@0 | 110 | d1.addEventListener("mousemove", d1Listener2, true); |
michael@0 | 111 | sendMouseDown(d1); |
michael@0 | 112 | sendMouseMove(d1); // This should call setCapture to d2! |
michael@0 | 113 | d1.removeEventListener("mousemove", d1Listener2, true); |
michael@0 | 114 | d1.addEventListener("mousemove", d1MouseMoveListener, true); |
michael@0 | 115 | sendMouseMove(d1); // This should send mouse event to d2. |
michael@0 | 116 | is(d1mousemovecount, 1, "Shouldn't have got mousemove"); |
michael@0 | 117 | is(d2mousemovecount, 4, "Should have got mousemove"); |
michael@0 | 118 | sendMouseUp(d1); |
michael@0 | 119 | |
michael@0 | 120 | SimpleTest.finish(); |
michael@0 | 121 | } |
michael@0 | 122 | |
michael@0 | 123 | </script> |
michael@0 | 124 | </pre> |
michael@0 | 125 | <div class="test" id="d1"> </div><br><div class="test" id="d2"> </div> |
michael@0 | 126 | <pre id="l"></pre> |
michael@0 | 127 | </body> |
michael@0 | 128 | </html> |