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