dom/tests/mochitest/pointerlock/file_movementXY.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/pointerlock/file_movementXY.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,113 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=633602
     1.8 +-->
     1.9 +  <head>
    1.10 +    <title>Bug 633602 - file_movementXY.html</title>
    1.11 +    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js">
    1.12 +    </script>
    1.13 +    <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js">
    1.14 +    </script>
    1.15 +    <script type="application/javascript" src="pointerlock_utils.js"></script>
    1.16 +    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.17 +  </head>
    1.18 +  <body>
    1.19 +    <a target="_blank"
    1.20 +      href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">
    1.21 +      Mozilla Bug 633602
    1.22 +    </a>
    1.23 +    <div id="div"></div>
    1.24 +    <pre id="test">
    1.25 +      <script type="application/javascript">
    1.26 +        /*
    1.27 +         * Test for Bug 633602
    1.28 +         * Checks if mozMovementX and mozMovementY are present
    1.29 +         * in the mouse event object.
    1.30 +         * It also checks the values for mozMovementXY.
    1.31 +         * They should be equal to the current screenXY minus
    1.32 +         * the last screenXY
    1.33 +         */
    1.34 +
    1.35 +        SimpleTest.waitForExplicitFinish();
    1.36 +
    1.37 +        function MouseMovementStats() {
    1.38 +          this.screenX = false;
    1.39 +          this.screenY = false;
    1.40 +          this.mozMovementX = false;
    1.41 +          this.mozMovementY = false;
    1.42 +        }
    1.43 +
    1.44 +        var div = document.getElementById("div")
    1.45 +          , divCenterWidth = 0
    1.46 +          , divCenterHeight = 0
    1.47 +          , mozMovementX = false
    1.48 +          , mozMovementY = false
    1.49 +          , firstMove = new MouseMovementStats()
    1.50 +          , secondMove = new MouseMovementStats();
    1.51 +
    1.52 +        function runTests () {
    1.53 +          ok(mozMovementX && mozMovementY, "mozMovementX and " +
    1.54 +            "mozMovementY should exist in mouse events objects.");
    1.55 +          is(secondMove.mozMovementX, secondMove.screenX - firstMove.screenX,
    1.56 +           "mozMovementX should be equal to eNow.screenX-ePrevious.screenX");
    1.57 +          is(secondMove.mozMovementY, secondMove.screenY - firstMove.screenY,
    1.58 +           "mozMovementY should be equal to eNow.screenY-ePrevious.screenY");
    1.59 +        }
    1.60 +
    1.61 +        var moveMouse = function(e) {
    1.62 +          mozMovementX = ("mozMovementX" in e);
    1.63 +          mozMovementY = ("mozMovementY" in e);
    1.64 +
    1.65 +          div.removeEventListener("mousemove", moveMouse, false);
    1.66 +          div.addEventListener("mousemove", moveMouseAgain, false);
    1.67 +
    1.68 +          firstMove.screenX = e.screenX;
    1.69 +          firstMove.screenY = e.screenY;
    1.70 +
    1.71 +          divCenterWidth = Math.round(div.getBoundingClientRect().width / 2);
    1.72 +          divCenterHeight = Math.round(div.getBoundingClientRect().height / 2);
    1.73 +
    1.74 +          synthesizeMouse(div, (divCenterWidth + 10), (divCenterHeight + 10), {
    1.75 +            type: "mousemove"
    1.76 +          }, window);
    1.77 +        };
    1.78 +
    1.79 +        var moveMouseAgain = function(e) {
    1.80 +          secondMove.screenX = e.screenX;
    1.81 +          secondMove.screenY = e.screenY;
    1.82 +          secondMove.mozMovementX = e.mozMovementX;
    1.83 +          secondMove.mozMovementY = e.mozMovementY;
    1.84 +
    1.85 +          div.removeEventListener("mousemove", moveMouseAgain, false);
    1.86 +          document.mozCancelFullScreen();
    1.87 +        };
    1.88 +
    1.89 +        function fullscreenchange() {
    1.90 +          if (document.mozFullScreenElement === div) {
    1.91 +            var screenX = window.screenX;
    1.92 +            var screenY = window.screenY;
    1.93 +            if (screenX != 0 || screenY != 0) {
    1.94 +              todo(screenX == 0 && screenY == 0,
    1.95 +                "We should only receive fullscreenchange once we've finished fullscreen transition");
    1.96 +              setTimeout(fullscreenchange, 250);
    1.97 +              return;
    1.98 +            } 
    1.99 +            div.addEventListener("mousemove", moveMouse, false);
   1.100 +            synthesizeMouseAtCenter(div, {type: "mousemove"}, window);
   1.101 +          }
   1.102 +          else {
   1.103 +            runTests();
   1.104 +            SimpleTest.finish();
   1.105 +          }
   1.106 +        }
   1.107 +        
   1.108 +        document.addEventListener("mozfullscreenchange", fullscreenchange, false);
   1.109 +
   1.110 +        function start() {
   1.111 +          div.mozRequestFullScreen();
   1.112 +        }
   1.113 +      </script>
   1.114 +    </pre>
   1.115 +  </body>
   1.116 +</html>

mercurial