file_infiniteMovement.html (4193B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=633602 5 --> 6 <head> 7 <title>Bug 633602 - file_movementXY.html</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"> 9 </script> 10 <script src="/tests/SimpleTest/EventUtils.js"> 11 </script> 12 <script type="application/javascript" src="pointerlock_utils.js"></script> 13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 14 </head> 15 <body> 16 <a target="_blank" 17 href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"> 18 Mozilla Bug 633602 19 </a> 20 <div id="div"></div> 21 <pre id="test"> 22 <script type="application/javascript"> 23 /* 24 * Test for Bug 633602 25 * This test checks if movementX and movementY 26 * are present in a mouse event object. 27 * It also checks the values for movementXY. 28 * They should be equal to the current screenXY minus 29 * the last screenXY 30 * This test will also test that the incremental movement is 31 * not constrained to the width of the screen. 32 */ 33 34 SimpleTest.waitForExplicitFinish(); 35 36 var div = document.getElementById("div") 37 , divCenterWidth = 0 38 , divCenterHeight = 0 39 , totalMovementX = 0 40 , totalMovementY = 0 41 , mouseMoveIntervalID; 42 43 function runTests () { 44 ok(totalMovementX > div.getBoundingClientRect().width, 45 "Should have moved more than one screen's worth in width." + 46 "TotalX: " + totalMovementX + " Screensize X: " + div.getBoundingClientRect().width); 47 ok(totalMovementY > div.getBoundingClientRect().height, 48 "Should have moved more than one screen's worth in height." + 49 "TotalY: " + totalMovementY + " Screensize Y: " + div.getBoundingClientRect().height); 50 } 51 52 var firstMoveListener = function (e) { 53 info("Got first mousemove"); 54 clearInterval(mouseMoveIntervalID); 55 div.removeEventListener("mousemove", firstMoveListener); 56 div.addEventListener("mousemove", secondMoveListener); 57 58 // Bug 1357082 59 // Retrigger synthesizeMouse until it actually happens. 60 mouseMoveIntervalID = setInterval(() => { 61 synthesizeMouse(div,(divCenterWidth/2) * 3, 62 (divCenterHeight/2) * 3, { 63 type: "mousemove" 64 }, window); 65 }, 100); 66 } 67 68 var secondMoveListener = function (e) { 69 info("Got second mousemove"); 70 clearInterval(mouseMoveIntervalID); 71 totalMovementX = divCenterWidth + ((divCenterWidth / 2) * 3); 72 totalMovementY = divCenterHeight + ((divCenterHeight / 2) * 3); 73 74 div.removeEventListener("mousemove", secondMoveListener); 75 addFullscreenChangeContinuation("exit", function() { 76 info("Got fullscreenchange for exiting"); 77 runTests(); 78 SimpleTest.finish(); 79 }); 80 document.exitFullscreen(); 81 } 82 83 document.addEventListener("pointerlockchange", function (e) { 84 if (document.pointerLockElement === div) { 85 info("Got pointerlockchange for entering"); 86 div.addEventListener("mousemove", firstMoveListener); 87 88 divCenterWidth = Math.round(div.getBoundingClientRect().width / 2); 89 divCenterHeight = Math.round(div.getBoundingClientRect().height / 2); 90 91 // Bug 1357082 92 // Retrigger synthesizeMouse until it actually happens. 93 mouseMoveIntervalID = setInterval(() => { 94 synthesizeMouse(div, divCenterWidth, divCenterHeight, { 95 type: "mousemove" 96 }, window); 97 }, 100); 98 } else { 99 info("Got pointerlockchange for exiting"); 100 } 101 }); 102 103 function start() { 104 info("Requesting fullscreen on parent"); 105 addFullscreenChangeContinuation("enter", function() { 106 info("Got fullscreenchange for entering"); 107 div.requestPointerLock(); 108 }); 109 div.requestFullscreen(); 110 } 111 </script> 112 </pre> 113 </body> 114 </html>