Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <!--
- https://bugzilla.mozilla.org/show_bug.cgi?id=633602
- -->
- <head>
- <title>Test for Bug 633602</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <!--<script type="text/javascript" src="mouselock_util.js"></script>-->
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
- </head>
- <body onload="start();">
- <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">Mozilla Bug 633602</a>
- <p id="display"></p>
- <div id="content" style="display: none">
- </div>
- <div id="div"></div>
- <pre id="test">
- <script type="application/javascript">
- /** Test for Bug 633602 **/
- /**
- The mouse is moved when it's not locked
- Then the mouse is moved when it is locked
- When the mouse isn't locked, the clientXY and screenXY should
- have values representing their respectives positions on the screen
- However, when the mouse is locked, they all should be equal to zero
- **/
- SimpleTest.waitForExplicitFinish();
- var pointer = navigator.pointer;
- var div;
- var countMoves = 0;
- // The width and height of a div element
- // These values will be used to move the mouse
- var divWidth = 0;
- var divHeight = 0;
- SpecialPowers.setBoolPref("full-screen-api.allow-trusted-requests-only",
- false);
- var moveFirst = function (e) {
- console.log("moveFirst");
- console.log("e.screenX: " + e.screenX + " e.screenY: " + e.screenY);
- console.log("e.clientX: " + e.clientX + " e.clientY: " + e.clientY);
- console.log("e.movementX: " + e.movementX + " e.movementY: " + e.movementY);
- // Remove the current mousemove listener from "div" and add a new one
- div.removeEventListener("mousemove", moveFirst, false);
- div.addEventListener("mousemove", moveAgain, false);
- synthesizeMouse(div, div.offsetWidth-10, div.offsetHeight-10, {
- type: "mousemove"
- }, window);
- };
- var moveAgain = function (e) {
- console.log("moveAgain");
- console.log("e.screenX: " + e.screenX + " e.screenY: " + e.screenY);
- console.log("e.clientX: " + e.clientX + " e.clientY: " + e.clientY);
- console.log("e.movementX: " + e.movementX + " e.movementY: " + e.movementY);
- // Remove the current mousemove listener from "div" and add a new one
- div.removeEventListener("mousemove", moveAgain, false);
- div.addEventListener("mousemove", moveLast, false);
- synthesizeMouse(div, 10, 10, {
- type: "mousemove"
- }, window);
- };
- var moveLast = function (e) {
- console.log("moveLast");
- console.log("e.screenX: " + e.screenX + " e.screenY: " + e.screenY);
- console.log("e.clientX: " + e.clientX + " e.clientY: " + e.clientY);
- console.log("e.movementX: " + e.movementX + " e.movementY: " + e.movementY);
- document.mozCancelFullScreen();
- };
- document.addEventListener("mozfullscreenchange", function() {
- if (document.mozFullScreenElement === div) {
- // Set the values for divWidth and divHeight
- // It's dividing by two to make sure the value is a valid coord
- // The value is being rounded since it's not possible to move
- // the mouse to broken values
- divWidth = Math.round(div.offsetWidth / 2);
- divHeight = Math.round(div.offsetHeight / 2);
- console.log("div.oofsetHeight: " + div.offsetHeight);
- console.log("div.oofsetWidth: " + div.offsetWidth);
- console.log("divWidth: " + divWidth);
- console.log("divHeight: " + divHeight);
- // Moving the mouse when the pointer is not locked
- synthesizeMouse(div, divWidth, divHeight, {
- type: "mousemove"
- }, window);
- } else {
- SimpleTest.finish();
- }
- }, false);
- function start() {
- console.log("start");
- div = document.getElementById("div");
- console.log("start");
- div.addEventListener("mousemove", moveFirst, false);
- SimpleTest.waitForFocus(function() {
- div.mozRequestFullScreen();
- });
- }
- </script>
- </pre>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement