diff options
Diffstat (limited to 'dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html')
-rw-r--r-- | dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html b/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html new file mode 100644 index 000000000..5df31d99c --- /dev/null +++ b/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html @@ -0,0 +1,158 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=633602 +--> +<head> + <title>Bug 633602 - file_cursorPosEvents.html</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> + </script> + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <script type="application/javascript" src="pointerlock_utils.js"></script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> + <style type="text/css"> + #child { + width: 100px; + height: 100px; + background-color:Green; + } + </style> +</head> +<body> + <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602"> + Mozilla Bug 633602</a> + + <div id="parent"> + <div id="child"></div> + </div> + + <script type="application/javascript"> + /* + * Test for Bug 633602 + * Test will check to make sure that the following mouse events are no + * longer executed in pointer lock. + * - mouseover, mouseout, mouseenter, mouseleave + */ + + SimpleTest.waitForExplicitFinish(); + + function PointerEventStats() { + this.mouseEnter = false; + this.mouseLeave = false; + this.mouseOver = false; + this.mouseOut = false; + } + + var parent + , child + , parentStats = new PointerEventStats() + , childStats = new PointerEventStats() + , isPointerLocked = false; + + function runTests () { + ok(isPointerLocked, "expected mouse to be locked, but wasn't."); + + is(childStats.mouseEnter, false, + "child's mouseenter should not be firing in Full Screen and Pointer Lock."); + is(childStats.mouseOver, false, + "child's mouseover should not be firing in Full Screen and Pointer Lock."); + is(childStats.mouseLeave, false, + "child's mouseleave should not be firing in Full Screen and Pointer Lock."); + is(childStats.mouseOut, false, + "child's mouseout should not be firing in Full Screen and Pointer Lock."); + + is(parentStats.mouseEnter, false, + "parent's mouseenter should not be firing in Full Screen and Pointer Lock."); + is(parentStats.mouseOver, false, + "parent's mouseover should not be firing in Full Screen and Pointer Lock."); + is(parentStats.mouseLeave, false, + "parent's mouseleave should not be firing in Full Screen and Pointer Lock."); + is(parentStats.mouseOut, false, + "parent's mouseout should not be firing in Full Screen and Pointer Lock."); + } + + var parentMoveListener = function () { + isPointerLocked = !!document.pointerLockElement; + removeEventListeners(); + document.exitPointerLock(); + }; + + var parentOutListener = function (e) { + parentStats.mouseOut = true; + }; + var parentLeaveListener = function (e) { + parentStats.mouseLeave = true; + }; + var parentOverListener = function (e) { + parentStats.mouseOver = true; + }; + var parentEnterListener = function (e) { + parentStats.mouseEnter = true; + }; + + var childOutListener = function (e) { + childStats.mouseOut = true; + }; + var childLeaveListener = function (e) { + childStats.mouseLeave = true; + }; + var childOverListener = function (e) { + childStats.mouseOver = true; + }; + var childEnterListener = function (e) { + childStats.mouseEnter = true; + }; + + function addEventListeners() { + parent.addEventListener("mousemove", parentMoveListener, false); + + parent.addEventListener("mouseout", parentOutListener, false); + parent.addEventListener("mouseleave", parentLeaveListener, false); + parent.addEventListener("mouseover", parentOverListener, false); + parent.addEventListener("mouseenter", parentEnterListener, false); + + child.addEventListener("mouseout", childOutListener, false); + child.addEventListener("mouseleave", childLeaveListener, false); + child.addEventListener("mouseover", childOverListener, false); + child.addEventListener("mouseenter", childEnterListener, false); + } + + function removeEventListeners() { + parent.removeEventListener("mousemove", parentMoveListener, false); + + parent.removeEventListener("mouseout", parentOutListener, false); + parent.removeEventListener("mouseleave", parentLeaveListener, false); + parent.removeEventListener("mouseover", parentOverListener, false); + parent.removeEventListener("mouseenter", parentEnterListener, false); + + child.removeEventListener("mouseout", childOutListener, false); + child.removeEventListener("mouseleave", childLeaveListener, false); + child.removeEventListener("mouseover" , childOverListener, false); + child.removeEventListener("mouseenter", childEnterListener, false); + } + + document.addEventListener("pointerlockchange", function (e) { + if (document.pointerLockElement === parent) { + addEventListeners(); + synthesizeMouseAtCenter(child, { type: "mousemove" }, window); + } + else { + addFullscreenChangeContinuation("exit", function() { + runTests(); + SimpleTest.finish(); + }); + document.exitFullscreen(); + } + }, false); + + function start() { + parent = document.getElementById("parent"); + child = document.getElementById("child"); + addFullscreenChangeContinuation("enter", function() { + parent.requestPointerLock(); + }); + parent.requestFullscreen(); + } + </script> +</body> +</html> |