file_suppressSomeMouseEvents.html (5515B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=633602 5 --> 6 <head> 7 <title>Bug 633602 - file_cursorPosEvents.html</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"> 9 </script> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 <script type="application/javascript" src="pointerlock_utils.js"></script> 12 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 13 <style type="text/css"> 14 #child { 15 width: 100px; 16 height: 100px; 17 background-color:Green; 18 } 19 </style> 20 </head> 21 <body> 22 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"> 23 Mozilla Bug 633602</a> 24 25 <div id="parent"> 26 <div id="child"></div> 27 </div> 28 29 <script type="application/javascript"> 30 /* 31 * Test for Bug 633602 32 * Test will check to make sure that the following mouse events are no 33 * longer executed in pointer lock. 34 * - mouseover, mouseout, mouseenter, mouseleave 35 */ 36 37 SimpleTest.waitForExplicitFinish(); 38 39 function PointerEventStats() { 40 this.mouseEnter = false; 41 this.mouseLeave = false; 42 this.mouseOver = false; 43 this.mouseOut = false; 44 } 45 46 var parent 47 , child 48 , parentStats = new PointerEventStats() 49 , childStats = new PointerEventStats() 50 , isPointerLocked = false; 51 52 function runTests () { 53 ok(isPointerLocked, "expected mouse to be locked, but wasn't."); 54 55 is(childStats.mouseEnter, false, 56 "child's mouseenter should not be firing in Full Screen and Pointer Lock."); 57 is(childStats.mouseOver, false, 58 "child's mouseover should not be firing in Full Screen and Pointer Lock."); 59 is(childStats.mouseLeave, false, 60 "child's mouseleave should not be firing in Full Screen and Pointer Lock."); 61 is(childStats.mouseOut, false, 62 "child's mouseout should not be firing in Full Screen and Pointer Lock."); 63 64 is(parentStats.mouseEnter, false, 65 "parent's mouseenter should not be firing in Full Screen and Pointer Lock."); 66 is(parentStats.mouseOver, false, 67 "parent's mouseover should not be firing in Full Screen and Pointer Lock."); 68 is(parentStats.mouseLeave, false, 69 "parent's mouseleave should not be firing in Full Screen and Pointer Lock."); 70 is(parentStats.mouseOut, false, 71 "parent's mouseout should not be firing in Full Screen and Pointer Lock."); 72 } 73 74 var parentMoveListener = function () { 75 isPointerLocked = !!document.pointerLockElement; 76 removeEventListeners(); 77 document.exitPointerLock(); 78 }; 79 80 var parentOutListener = function (e) { 81 parentStats.mouseOut = true; 82 }; 83 var parentLeaveListener = function (e) { 84 parentStats.mouseLeave = true; 85 }; 86 var parentOverListener = function (e) { 87 parentStats.mouseOver = true; 88 }; 89 var parentEnterListener = function (e) { 90 parentStats.mouseEnter = true; 91 }; 92 93 var childOutListener = function (e) { 94 childStats.mouseOut = true; 95 }; 96 var childLeaveListener = function (e) { 97 childStats.mouseLeave = true; 98 }; 99 var childOverListener = function (e) { 100 childStats.mouseOver = true; 101 }; 102 var childEnterListener = function (e) { 103 childStats.mouseEnter = true; 104 }; 105 106 function addEventListeners() { 107 parent.addEventListener("mousemove", parentMoveListener); 108 109 parent.addEventListener("mouseout", parentOutListener); 110 parent.addEventListener("mouseleave", parentLeaveListener); 111 parent.addEventListener("mouseover", parentOverListener); 112 parent.addEventListener("mouseenter", parentEnterListener); 113 114 child.addEventListener("mouseout", childOutListener); 115 child.addEventListener("mouseleave", childLeaveListener); 116 child.addEventListener("mouseover", childOverListener); 117 child.addEventListener("mouseenter", childEnterListener); 118 } 119 120 function removeEventListeners() { 121 parent.removeEventListener("mousemove", parentMoveListener); 122 123 parent.removeEventListener("mouseout", parentOutListener); 124 parent.removeEventListener("mouseleave", parentLeaveListener); 125 parent.removeEventListener("mouseover", parentOverListener); 126 parent.removeEventListener("mouseenter", parentEnterListener); 127 128 child.removeEventListener("mouseout", childOutListener); 129 child.removeEventListener("mouseleave", childLeaveListener); 130 child.removeEventListener("mouseover" , childOverListener); 131 child.removeEventListener("mouseenter", childEnterListener); 132 } 133 134 document.addEventListener("pointerlockchange", function (e) { 135 if (document.pointerLockElement === parent) { 136 addEventListeners(); 137 synthesizeMouseAtCenter(child, { type: "mousemove" }, window); 138 } 139 else { 140 addFullscreenChangeContinuation("exit", function() { 141 runTests(); 142 SimpleTest.finish(); 143 }); 144 document.exitFullscreen(); 145 } 146 }); 147 148 function start() { 149 parent = document.getElementById("parent"); 150 child = document.getElementById("child"); 151 addFullscreenChangeContinuation("enter", function() { 152 parent.requestPointerLock(); 153 }); 154 parent.requestFullscreen(); 155 } 156 </script> 157 </body> 158 </html>