dom/tests/mochitest/pointerlock/file_infiniteMovement.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=633602
     5 -->
     6   <head>
     7     <title>Bug 633602 - file_movementXY.html</title>
     8     <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js">
     9     </script>
    10     <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js">
    11     </script>
    12     <script type="application/javascript" src="pointerlock_utils.js"></script>
    13     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    14   </head>
    15   <body>
    16     <a target="_blank"
    17       href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">
    18       Mozilla Bug 633602
    19     </a>
    20     <div id="div"></div>
    21     <pre id="test">
    22       <script type="application/javascript">
    23         /*
    24          * Test for Bug 633602
    25          * This test checks if mozMovementX and mozMovementY
    26          * are present in a mouse event object.
    27          * It also checks the values for mozMovementXY.
    28          * They should be equal to the current screenXY minus
    29          * the last screenXY
    30          * This test will also test that the incremental movement is
    31          * not constrained to the width of the screen.
    32          */
    34         SimpleTest.waitForExplicitFinish();
    36         var div = document.getElementById("div")
    37           , divCenterWidth = 0
    38           , divCenterHeight = 0
    39           , totalMovementX = 0
    40           , totalMovementY = 0;
    42         function runTests () {
    43           ok(totalMovementX > div.getBoundingClientRect().width,
    44                "Should have moved more than one screen's worth in width." +
    45                "TotalX: " + totalMovementX + " Screensize X: " + div.getBoundingClientRect().width);
    46           ok(totalMovementY > div.getBoundingClientRect().height,
    47              "Should have moved more than one screen's worth in height." +
    48              "TotalY: " + totalMovementY + " Screensize Y: " + div.getBoundingClientRect().height);
    49         }
    51         var firstMoveListener = function (e) {
    52           div.removeEventListener("mousemove", firstMoveListener, false);
    53           div.addEventListener("mousemove", secondMoveListener, false);
    55           synthesizeMouse(div,(divCenterWidth/2) * 3,
    56             (divCenterHeight/2) * 3, {
    57             type: "mousemove"
    58           }, window);
    59         }
    61         var secondMoveListener = function (e) {
    62           totalMovementX = divCenterWidth + ((divCenterWidth / 2) * 3);
    63           totalMovementY = divCenterHeight + ((divCenterHeight / 2) * 3);
    65           div.removeEventListener("mousemove", secondMoveListener, false);
    66           document.mozCancelFullScreen();
    67         }
    69         document.addEventListener("mozpointerlockchange", function (e) {
    70           if (document.mozPointerLockElement === div) {
    71             div.addEventListener("mousemove", firstMoveListener, false);
    73             divCenterWidth = Math.round(div.getBoundingClientRect().width / 2);
    74             divCenterHeight = Math.round(div.getBoundingClientRect().height / 2);
    76             synthesizeMouse(div, divCenterWidth, divCenterHeight, {
    77               type: "mousemove"
    78             }, window);
    79           }
    80         }, false);
    82         document.addEventListener("mozfullscreenchange", function() {
    83           if (document.mozFullScreenElement === div) {
    84             div.mozRequestPointerLock();
    85           }
    86           else {
    87             runTests();
    88             SimpleTest.finish();
    89           }
    90         }, false);
    92         function start() {
    93           div.mozRequestFullScreen();
    94         }
    95       </script>
    96     </pre>
    97   </body>
    98 </html>

mercurial