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=968148 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 968148</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> |
michael@0 | 20 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=968148">Mozilla Bug 968148</a> |
michael@0 | 21 | <p id="display"></p> |
michael@0 | 22 | <div id="content" style="display: none"> |
michael@0 | 23 | </div> |
michael@0 | 24 | <pre id="test"> |
michael@0 | 25 | <script type="application/javascript"> |
michael@0 | 26 | |
michael@0 | 27 | /** |
michael@0 | 28 | * Test for Bug 968148, test orignally copied from test_bug582771.html. |
michael@0 | 29 | * Mouse functionality converted to pointer and all steps duplicated in order to run them in parallel for two different pointer Id's |
michael@0 | 30 | **/ |
michael@0 | 31 | |
michael@0 | 32 | function ok(condition, msg) { |
michael@0 | 33 | parent.ok(condition, msg); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function is(a, b, msg) { |
michael@0 | 37 | parent.is(a, b, msg); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | var test1d1; |
michael@0 | 41 | var test1d2; |
michael@0 | 42 | var test2d1; |
michael@0 | 43 | var test2d2; |
michael@0 | 44 | var test1d1pointermovecount = 0; |
michael@0 | 45 | var test1d2pointermovecount = 0; |
michael@0 | 46 | var test2d1pointermovecount = 0; |
michael@0 | 47 | var test2d2pointermovecount = 0; |
michael@0 | 48 | |
michael@0 | 49 | var test1d1pointerlostcapture = 0; |
michael@0 | 50 | var test1d2pointerlostcapture = 0; |
michael@0 | 51 | var test2d1pointerlostcapture = 0; |
michael@0 | 52 | var test2d2pointerlostcapture = 0; |
michael@0 | 53 | var test1d1pointergotcapture = 0; |
michael@0 | 54 | var test1d2pointergotcapture = 0; |
michael@0 | 55 | var test2d1pointergotcapture = 0; |
michael@0 | 56 | var test2d2pointergotcapture = 0; |
michael@0 | 57 | var test1PointerId = 1; |
michael@0 | 58 | var test2PointerId = 2; |
michael@0 | 59 | |
michael@0 | 60 | function sendPointerMove(el, id) { |
michael@0 | 61 | var rect = el.getBoundingClientRect(); |
michael@0 | 62 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 63 | utils.sendPointerEvent('pointermove', rect.left + 5, rect.top + 5, 0, 0, 0, false, 0, SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH, id); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | function sendPointerDown(el, id) { |
michael@0 | 67 | var rect = el.getBoundingClientRect(); |
michael@0 | 68 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 69 | utils.sendPointerEvent('pointerdown', rect.left + 5, rect.top + 5, 0, 1, 0, false, 0, SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH, id); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function sendPointerUp(el, id) { |
michael@0 | 73 | var rect = el.getBoundingClientRect(); |
michael@0 | 74 | var utils = SpecialPowers.getDOMWindowUtils(window); |
michael@0 | 75 | utils.sendPointerEvent('pointerup', rect.left + 5, rect.top + 5, 0, 1, 0, false, 0, SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH, id); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | function log(s) { |
michael@0 | 79 | document.getElementById("l").textContent += s + "\n"; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | function test1d2Listener(e) { |
michael@0 | 83 | log(e.type + ", " + e.target.id); |
michael@0 | 84 | is(e.target, test1d2, "test1d2 should have got pointermove."); |
michael@0 | 85 | ++test1d2pointermovecount; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | function test2d2Listener(e) { |
michael@0 | 89 | log(e.type + ", " + e.target.id); |
michael@0 | 90 | is(e.target, test2d2, "test2d2 should have got pointermove."); |
michael@0 | 91 | ++test2d2pointermovecount; |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | function test1d1DownListener(e) { |
michael@0 | 95 | log(e.type + ", " + e.target.id); |
michael@0 | 96 | test1d1.setPointerCapture(e.pointerId); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | function test1d1MoveListener(e) { |
michael@0 | 100 | log(e.type + ", " + e.target.id); |
michael@0 | 101 | test1d2.setPointerCapture(e.pointerId); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | function test2d1DownListener(e) { |
michael@0 | 105 | log(e.type + ", " + e.target.id); |
michael@0 | 106 | test2d1.setPointerCapture(e.pointerId); |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | function test2d1MoveListener(e) { |
michael@0 | 110 | log(e.type + ", " + e.target.id); |
michael@0 | 111 | test2d2.setPointerCapture(e.pointerId); |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | function test1d1PointerGotCapture(e) { |
michael@0 | 115 | log(e.type + ", " + e.target.id); |
michael@0 | 116 | ++test1d1pointergotcapture; |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | function test1d1PointerLostCapture(e) { |
michael@0 | 120 | log(e.type + ", " + e.target.id); |
michael@0 | 121 | ++test1d1pointerlostcapture; |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | function test2d1PointerGotCapture(e) { |
michael@0 | 125 | log(e.type + ", " + e.target.id); |
michael@0 | 126 | ++test2d1pointergotcapture; |
michael@0 | 127 | } |
michael@0 | 128 | |
michael@0 | 129 | function test2d1PointerLostCapture(e) { |
michael@0 | 130 | log(e.type + ", " + e.target.id); |
michael@0 | 131 | ++test2d1pointerlostcapture; |
michael@0 | 132 | } |
michael@0 | 133 | |
michael@0 | 134 | function test1d2PointerGotCapture(e) { |
michael@0 | 135 | log(e.type + ", " + e.target.id); |
michael@0 | 136 | ++test1d2pointergotcapture; |
michael@0 | 137 | } |
michael@0 | 138 | |
michael@0 | 139 | function test1d2PointerLostCapture(e) { |
michael@0 | 140 | log(e.type + ", " + e.target.id); |
michael@0 | 141 | ++test1d2pointerlostcapture; |
michael@0 | 142 | } |
michael@0 | 143 | |
michael@0 | 144 | function test2d2PointerGotCapture(e) { |
michael@0 | 145 | log(e.type + ", " + e.target.id); |
michael@0 | 146 | ++test2d2pointergotcapture; |
michael@0 | 147 | } |
michael@0 | 148 | |
michael@0 | 149 | function test2d2PointerLostCapture(e) { |
michael@0 | 150 | log(e.type + ", " + e.target.id); |
michael@0 | 151 | ++test2d2pointerlostcapture; |
michael@0 | 152 | } |
michael@0 | 153 | |
michael@0 | 154 | function test1d1PointerMoveListener(e) { |
michael@0 | 155 | log(e.type + ", " + e.target.id); |
michael@0 | 156 | ++test1d1pointermovecount; |
michael@0 | 157 | } |
michael@0 | 158 | |
michael@0 | 159 | function test2d1PointerMoveListener(e) { |
michael@0 | 160 | log(e.type + ", " + e.target.id); |
michael@0 | 161 | ++test2d1pointermovecount; |
michael@0 | 162 | } |
michael@0 | 163 | |
michael@0 | 164 | function runTests() { |
michael@0 | 165 | test1d1 = document.getElementById("test1d1"); |
michael@0 | 166 | test1d2 = document.getElementById("test1d2"); |
michael@0 | 167 | test2d1 = document.getElementById("test2d1"); |
michael@0 | 168 | test2d2 = document.getElementById("test2d2"); |
michael@0 | 169 | |
michael@0 | 170 | test1d2.addEventListener("pointermove", test1d2Listener, true); |
michael@0 | 171 | test2d2.addEventListener("pointermove", test2d2Listener, true); |
michael@0 | 172 | |
michael@0 | 173 | test1d1.addEventListener("gotpointercapture", test1d1PointerGotCapture, true); |
michael@0 | 174 | test1d1.addEventListener("lostpointercapture", test1d1PointerLostCapture, true); |
michael@0 | 175 | |
michael@0 | 176 | test2d1.addEventListener("gotpointercapture", test2d1PointerGotCapture, true); |
michael@0 | 177 | test2d1.addEventListener("lostpointercapture", test2d1PointerLostCapture, true); |
michael@0 | 178 | |
michael@0 | 179 | test1d2.addEventListener("gotpointercapture", test1d2PointerGotCapture, true); |
michael@0 | 180 | test1d2.addEventListener("lostpointercapture", test1d2PointerLostCapture, true); |
michael@0 | 181 | |
michael@0 | 182 | test2d2.addEventListener("gotpointercapture", test2d2PointerGotCapture, true); |
michael@0 | 183 | test2d2.addEventListener("lostpointercapture", test2d2PointerLostCapture, true); |
michael@0 | 184 | |
michael@0 | 185 | document.body.offsetLeft; |
michael@0 | 186 | sendPointerMove(test1d2, test1PointerId); |
michael@0 | 187 | sendPointerMove(test2d2, test2PointerId); |
michael@0 | 188 | is(test1d2pointermovecount, 1, "Should have got pointermove"); |
michael@0 | 189 | is(test2d2pointermovecount, 1, "Should have got pointermove"); |
michael@0 | 190 | |
michael@0 | 191 | // This shouldn't enable capturing, since we're not in a right kind of |
michael@0 | 192 | // event listener. |
michael@0 | 193 | sendPointerDown(test1d1, test1PointerId); |
michael@0 | 194 | sendPointerDown(test2d1, test2PointerId); |
michael@0 | 195 | |
michael@0 | 196 | sendPointerMove(test1d2, test1PointerId); |
michael@0 | 197 | sendPointerMove(test2d2, test2PointerId); |
michael@0 | 198 | |
michael@0 | 199 | sendPointerUp(test1d1, test1PointerId); |
michael@0 | 200 | sendPointerUp(test2d1, test2PointerId); |
michael@0 | 201 | |
michael@0 | 202 | is(test1d2pointermovecount, 2, "Should have got pointermove"); |
michael@0 | 203 | is(test2d2pointermovecount, 2, "Should have got pointermove"); |
michael@0 | 204 | |
michael@0 | 205 | test1d1.addEventListener("pointerdown", test1d1DownListener, true); |
michael@0 | 206 | test1d1.addEventListener("pointermove", test1d1PointerMoveListener, true); |
michael@0 | 207 | test2d1.addEventListener("pointerdown", test2d1DownListener, true); |
michael@0 | 208 | test2d1.addEventListener("pointermove", test2d1PointerMoveListener, true); |
michael@0 | 209 | |
michael@0 | 210 | sendPointerDown(test1d1, test1PointerId); |
michael@0 | 211 | sendPointerDown(test2d1, test2PointerId); |
michael@0 | 212 | sendPointerMove(test1d2, test1PointerId); |
michael@0 | 213 | sendPointerMove(test2d2, test2PointerId); |
michael@0 | 214 | is(test1d2pointermovecount, 2, "Shouldn't have got pointermove"); |
michael@0 | 215 | is(test1d1pointermovecount, 1, "Should have got pointermove"); |
michael@0 | 216 | is(test1d1pointergotcapture, 1, "Should have got pointergotcapture"); |
michael@0 | 217 | |
michael@0 | 218 | is(test2d2pointermovecount, 2, "Shouldn't have got pointermove"); |
michael@0 | 219 | is(test2d1pointermovecount, 1, "Should have got pointermove"); |
michael@0 | 220 | is(test2d1pointergotcapture, 1, "Should have got pointergotcapture"); |
michael@0 | 221 | |
michael@0 | 222 | sendPointerUp(test1d1, test1PointerId); |
michael@0 | 223 | sendPointerUp(test2d1, test2PointerId); |
michael@0 | 224 | test1d1.removeEventListener("pointerdown", test1d1DownListener, true); |
michael@0 | 225 | test1d1.removeEventListener("pointermove", test1d1PointerMoveListener, true); |
michael@0 | 226 | test2d1.removeEventListener("pointerdown", test2d1DownListener, true); |
michael@0 | 227 | test2d1.removeEventListener("pointermove", test2d1PointerMoveListener, true); |
michael@0 | 228 | |
michael@0 | 229 | // Nothing should be capturing the event. |
michael@0 | 230 | sendPointerMove(test1d2, test1PointerId); |
michael@0 | 231 | sendPointerMove(test2d2, test2PointerId); |
michael@0 | 232 | |
michael@0 | 233 | is(test1d2pointermovecount, 3, "Should have got pointermove"); |
michael@0 | 234 | is(test1d1pointerlostcapture, 1, "Should have got pointerlostcapture"); |
michael@0 | 235 | is(test2d2pointermovecount, 3, "Should have got pointermove"); |
michael@0 | 236 | is(test2d1pointerlostcapture, 1, "Should have got pointerlostcapture"); |
michael@0 | 237 | |
michael@0 | 238 | test1d1.addEventListener("pointermove", test1d1MoveListener, true); |
michael@0 | 239 | test2d1.addEventListener("pointermove", test2d1MoveListener, true); |
michael@0 | 240 | |
michael@0 | 241 | sendPointerDown(test1d1, test1PointerId); |
michael@0 | 242 | sendPointerDown(test2d1, test2PointerId); |
michael@0 | 243 | |
michael@0 | 244 | sendPointerMove(test1d1, test1PointerId); // This should call setPointerCapture to test1d2! |
michael@0 | 245 | sendPointerMove(test2d1, test2PointerId); // This should call setPointerCapture to test2d2! |
michael@0 | 246 | |
michael@0 | 247 | test1d1.removeEventListener("pointermove", test1d1MoveListener, true); |
michael@0 | 248 | test1d1.addEventListener("pointermove", test1d1PointerMoveListener, true); |
michael@0 | 249 | |
michael@0 | 250 | test2d1.removeEventListener("pointermove", test2d1MoveListener, true); |
michael@0 | 251 | test2d1.addEventListener("pointermove", test2d1PointerMoveListener, true); |
michael@0 | 252 | |
michael@0 | 253 | sendPointerMove(test1d1, test1PointerId); // This should send pointer event to test1d2. |
michael@0 | 254 | sendPointerMove(test2d1, test2PointerId); // This should send pointer event to test2d2. |
michael@0 | 255 | |
michael@0 | 256 | is(test1d1pointermovecount, 1, "Shouldn't have got pointermove"); |
michael@0 | 257 | is(test1d2pointermovecount, 4, "Should have got pointermove"); |
michael@0 | 258 | is(test1d2pointergotcapture, 1, "Should have got pointergotcapture"); |
michael@0 | 259 | |
michael@0 | 260 | is(test2d1pointermovecount, 1, "Shouldn't have got pointermove"); |
michael@0 | 261 | is(test2d2pointermovecount, 4, "Should have got pointermove"); |
michael@0 | 262 | is(test2d2pointergotcapture, 1, "Should have got pointergotcapture"); |
michael@0 | 263 | |
michael@0 | 264 | sendPointerUp(test1d1, test1PointerId); |
michael@0 | 265 | sendPointerUp(test2d1, test2PointerId); |
michael@0 | 266 | |
michael@0 | 267 | finishTest(); |
michael@0 | 268 | } |
michael@0 | 269 | |
michael@0 | 270 | function finishTest() { |
michael@0 | 271 | // Let window.onerror have a chance to fire |
michael@0 | 272 | setTimeout(function() { |
michael@0 | 273 | setTimeout(function() { |
michael@0 | 274 | window.parent.postMessage("SimpleTest.finish();", "*"); |
michael@0 | 275 | }, 0); |
michael@0 | 276 | }, 0); |
michael@0 | 277 | } |
michael@0 | 278 | |
michael@0 | 279 | window.onload = function () { |
michael@0 | 280 | SpecialPowers.pushPrefEnv({ |
michael@0 | 281 | "set": [ |
michael@0 | 282 | ["dom.w3c_pointer_events.enabled", true], |
michael@0 | 283 | ] |
michael@0 | 284 | }, runTests); |
michael@0 | 285 | } |
michael@0 | 286 | |
michael@0 | 287 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 288 | |
michael@0 | 289 | </script> |
michael@0 | 290 | </pre> |
michael@0 | 291 | <div class="test" id="test1d1"> </div><br><div class="test" id="test1d2"> </div> |
michael@0 | 292 | <div class="test" id="test2d1"> </div><br><div class="test" id="test2d2"> </div> |
michael@0 | 293 | <pre id="l"></pre> |
michael@0 | 294 | </body> |
michael@0 | 295 | </html> |