dom/tests/mochitest/pointerlock/file_childIframe.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_childIframe.html</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js">
     9   </script>
    10   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    11   <script type="application/javascript" src="pointerlock_utils.js"></script>
    12   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    13   <style>
    14     #parent, #childDiv, #iframe, #table, #table td {
    15       margin: 0;
    16       padding: 0;
    17       border: none;
    18     }
    19     #iframe, #table {
    20       background-color: red;
    21       width: 100%;
    22       height: 100%;
    23     }
    24     #childDiv, #table td {
    25       background-color: blue;
    26       width: 50%;
    27       height: 50%;
    28     }
    29   </style>
    30 </head>
    31 <body>
    32   <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">
    33     Mozilla Bug 633602
    34   </a>
    36   <div id="parent">
    37     <table id="childTable">
    38       <tr>
    39         <td>
    40           <iframe id="iframe" src="iframe_differentDOM.html" onload="start();">
    41           </iframe>
    42         </td>
    43         <td>
    44           <div id="childDiv">
    45           </div>
    46         </td>
    47       </tr>
    48     </table>
    49   </div>
    51   <pre id="test">
    52     <script type="application/javascript">
    53       /*
    54        * Test for Bug 633602
    55        * Check if pointer is locked when over a child iframe of
    56        * the locked element
    57        * Check if pointer is being repositioned back to center of
    58        * the locked element even when pointer goes over a child ifame
    59        */
    61       SimpleTest.waitForExplicitFinish();
    63       var parent = document.getElementById("parent")
    64         , childDiv = document.getElementById("childDiv")
    65         , iframe = document.getElementById("iframe");
    67       function MozMovementStats() {
    68         this.mozMovementX = false;
    69         this.mozMovementY = false;
    70       }
    72       var firstMove = new MozMovementStats()
    73         , secondMove = new MozMovementStats()
    74         , hoverIframe = false;
    76       function runTests () {
    77         ok(hoverIframe, "Pointer should be locked even when pointer " +
    78           "hovers over a child iframe");
    79         is(firstMove.mozMovementX, secondMove.mozMovementX, "MovementX of first " +
    80           "move to childDiv should be equal to movementX of second move " +
    81           "to child div");
    82         is(firstMove.mozMovementY, secondMove.mozMovementY, "MovementY of first " +
    83           "move to childDiv should be equal to movementY of second move " +
    84           "to child div");
    85       }
    87       var firstMoveChild = function (e) {
    88         firstMove.mozMovementX = e.mozMovementX;
    89         firstMove.mozMovementY = e.mozMovementY;
    91         parent.removeEventListener("mousemove", firstMoveChild);
    92         parent.addEventListener("mousemove", moveIframe);
    94         synthesizeMouseAtCenter(iframe, {type: "mousemove"}, window);
    95       };
    97       var moveIframe = function (e) {
    98         hoverIframe = !!document.mozPointerLockElement;
   100         parent.removeEventListener("mousemove", moveIframe);
   101         parent.addEventListener("mousemove", secondMoveChild);
   103         synthesizeMouseAtCenter(childDiv, {type: "mousemove"}, window);
   104       };
   106       var secondMoveChild = function (e) {
   107         secondMove.mozMovementX = e.mozMovementX;
   108         secondMove.mozMovementY = e.mozMovementY;
   109         parent.removeEventListener("mousemove", secondMoveChild);
   111         document.mozCancelFullScreen();
   112       };
   114       document.addEventListener("mozpointerlockchange", function () {
   115         if (document.mozPointerLockElement === parent) {
   116           parent.addEventListener("mousemove", firstMoveChild);
   117           synthesizeMouseAtCenter(childDiv, {type: "mousemove"}, window);
   118         }
   119       }, false);
   121       document.addEventListener("mozpointerlockerror", function () {
   122         document.mozCancelFullScreen();
   123       }, false);
   125       document.addEventListener("mozfullscreenchange", function (e)  {
   126         if (document.mozFullScreenElement === parent) {
   127           parent.mozRequestPointerLock();
   128         }
   129         else {
   130           runTests();
   131           SimpleTest.finish();
   132         }
   133       }, false);
   135       function start() {
   136         parent.mozRequestFullScreen();
   137       }
   138     </script>
   139   </pre>
   140 </body>
   141 </html>

mercurial