summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html
diff options
context:
space:
mode:
Diffstat (limited to 'dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html')
-rw-r--r--dom/tests/mochitest/pointerlock/file_suppressSomeMouseEvents.html158
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 0000000000..bc1e1e64a5
--- /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 src="/tests/SimpleTest/SimpleTest.js">
+ </script>
+ <script 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);
+
+ parent.addEventListener("mouseout", parentOutListener);
+ parent.addEventListener("mouseleave", parentLeaveListener);
+ parent.addEventListener("mouseover", parentOverListener);
+ parent.addEventListener("mouseenter", parentEnterListener);
+
+ child.addEventListener("mouseout", childOutListener);
+ child.addEventListener("mouseleave", childLeaveListener);
+ child.addEventListener("mouseover", childOverListener);
+ child.addEventListener("mouseenter", childEnterListener);
+ }
+
+ function removeEventListeners() {
+ parent.removeEventListener("mousemove", parentMoveListener);
+
+ parent.removeEventListener("mouseout", parentOutListener);
+ parent.removeEventListener("mouseleave", parentLeaveListener);
+ parent.removeEventListener("mouseover", parentOverListener);
+ parent.removeEventListener("mouseenter", parentEnterListener);
+
+ child.removeEventListener("mouseout", childOutListener);
+ child.removeEventListener("mouseleave", childLeaveListener);
+ child.removeEventListener("mouseover" , childOverListener);
+ child.removeEventListener("mouseenter", childEnterListener);
+ }
+
+ document.addEventListener("pointerlockchange", function (e) {
+ if (document.pointerLockElement === parent) {
+ addEventListeners();
+ synthesizeMouseAtCenter(child, { type: "mousemove" }, window);
+ }
+ else {
+ addFullscreenChangeContinuation("exit", function() {
+ runTests();
+ SimpleTest.finish();
+ });
+ document.exitFullscreen();
+ }
+ });
+
+ function start() {
+ parent = document.getElementById("parent");
+ child = document.getElementById("child");
+ addFullscreenChangeContinuation("enter", function() {
+ parent.requestPointerLock();
+ });
+ parent.requestFullscreen();
+ }
+ </script>
+</body>
+</html>