dom/tests/mochitest/pointerlock/file_childIframe.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/pointerlock/file_childIframe.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,141 @@
     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_childIframe.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"></script>
    1.14 +  <script type="application/javascript" src="pointerlock_utils.js"></script>
    1.15 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.16 +  <style>
    1.17 +    #parent, #childDiv, #iframe, #table, #table td {
    1.18 +      margin: 0;
    1.19 +      padding: 0;
    1.20 +      border: none;
    1.21 +    }
    1.22 +    #iframe, #table {
    1.23 +      background-color: red;
    1.24 +      width: 100%;
    1.25 +      height: 100%;
    1.26 +    }
    1.27 +    #childDiv, #table td {
    1.28 +      background-color: blue;
    1.29 +      width: 50%;
    1.30 +      height: 50%;
    1.31 +    }
    1.32 +  </style>
    1.33 +</head>
    1.34 +<body>
    1.35 +  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">
    1.36 +    Mozilla Bug 633602
    1.37 +  </a>
    1.38 +
    1.39 +  <div id="parent">
    1.40 +    <table id="childTable">
    1.41 +      <tr>
    1.42 +        <td>
    1.43 +          <iframe id="iframe" src="iframe_differentDOM.html" onload="start();">
    1.44 +          </iframe>
    1.45 +        </td>
    1.46 +        <td>
    1.47 +          <div id="childDiv">
    1.48 +          </div>
    1.49 +        </td>
    1.50 +      </tr>
    1.51 +    </table>
    1.52 +  </div>
    1.53 +
    1.54 +  <pre id="test">
    1.55 +    <script type="application/javascript">
    1.56 +      /*
    1.57 +       * Test for Bug 633602
    1.58 +       * Check if pointer is locked when over a child iframe of
    1.59 +       * the locked element
    1.60 +       * Check if pointer is being repositioned back to center of
    1.61 +       * the locked element even when pointer goes over a child ifame
    1.62 +       */
    1.63 +
    1.64 +      SimpleTest.waitForExplicitFinish();
    1.65 +
    1.66 +      var parent = document.getElementById("parent")
    1.67 +        , childDiv = document.getElementById("childDiv")
    1.68 +        , iframe = document.getElementById("iframe");
    1.69 +
    1.70 +      function MozMovementStats() {
    1.71 +        this.mozMovementX = false;
    1.72 +        this.mozMovementY = false;
    1.73 +      }
    1.74 +
    1.75 +      var firstMove = new MozMovementStats()
    1.76 +        , secondMove = new MozMovementStats()
    1.77 +        , hoverIframe = false;
    1.78 +
    1.79 +      function runTests () {
    1.80 +        ok(hoverIframe, "Pointer should be locked even when pointer " +
    1.81 +          "hovers over a child iframe");
    1.82 +        is(firstMove.mozMovementX, secondMove.mozMovementX, "MovementX of first " +
    1.83 +          "move to childDiv should be equal to movementX of second move " +
    1.84 +          "to child div");
    1.85 +        is(firstMove.mozMovementY, secondMove.mozMovementY, "MovementY of first " +
    1.86 +          "move to childDiv should be equal to movementY of second move " +
    1.87 +          "to child div");
    1.88 +      }
    1.89 +
    1.90 +      var firstMoveChild = function (e) {
    1.91 +        firstMove.mozMovementX = e.mozMovementX;
    1.92 +        firstMove.mozMovementY = e.mozMovementY;
    1.93 +
    1.94 +        parent.removeEventListener("mousemove", firstMoveChild);
    1.95 +        parent.addEventListener("mousemove", moveIframe);
    1.96 +
    1.97 +        synthesizeMouseAtCenter(iframe, {type: "mousemove"}, window);
    1.98 +      };
    1.99 +
   1.100 +      var moveIframe = function (e) {
   1.101 +        hoverIframe = !!document.mozPointerLockElement;
   1.102 +
   1.103 +        parent.removeEventListener("mousemove", moveIframe);
   1.104 +        parent.addEventListener("mousemove", secondMoveChild);
   1.105 +
   1.106 +        synthesizeMouseAtCenter(childDiv, {type: "mousemove"}, window);
   1.107 +      };
   1.108 +
   1.109 +      var secondMoveChild = function (e) {
   1.110 +        secondMove.mozMovementX = e.mozMovementX;
   1.111 +        secondMove.mozMovementY = e.mozMovementY;
   1.112 +        parent.removeEventListener("mousemove", secondMoveChild);
   1.113 +
   1.114 +        document.mozCancelFullScreen();
   1.115 +      };
   1.116 +
   1.117 +      document.addEventListener("mozpointerlockchange", function () {
   1.118 +        if (document.mozPointerLockElement === parent) {
   1.119 +          parent.addEventListener("mousemove", firstMoveChild);
   1.120 +          synthesizeMouseAtCenter(childDiv, {type: "mousemove"}, window);
   1.121 +        }
   1.122 +      }, false);
   1.123 +
   1.124 +      document.addEventListener("mozpointerlockerror", function () {
   1.125 +        document.mozCancelFullScreen();
   1.126 +      }, false);
   1.127 +
   1.128 +      document.addEventListener("mozfullscreenchange", function (e)  {
   1.129 +        if (document.mozFullScreenElement === parent) {
   1.130 +          parent.mozRequestPointerLock();
   1.131 +        }
   1.132 +        else {
   1.133 +          runTests();
   1.134 +          SimpleTest.finish();
   1.135 +        }
   1.136 +      }, false);
   1.137 +
   1.138 +      function start() {
   1.139 +        parent.mozRequestFullScreen();
   1.140 +      }
   1.141 +    </script>
   1.142 +  </pre>
   1.143 +</body>
   1.144 +</html>

mercurial