dom/tests/mochitest/pointerlock/file_nestedFullScreen.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/pointerlock/file_nestedFullScreen.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,79 @@
     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_nestedFullScreen.html</title>
    1.11 +    <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js">
    1.12 +    </script>
    1.13 +    <script type="application/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 +
    1.24 +    <div id="parentDiv">
    1.25 +      <div id="childDiv"></div>
    1.26 +    </div>
    1.27 +
    1.28 +    <script type="application/javascript">
    1.29 +      /*
    1.30 +       * Test for Bug 633602
    1.31 +       * Requesting fullscreen on a child element of the element with
    1.32 +       * the pointer locked should unlock the pointer
    1.33 +       */
    1.34 +
    1.35 +      SimpleTest.waitForExplicitFinish();
    1.36 +
    1.37 +      var parentDiv = document.getElementById("parentDiv")
    1.38 +        , childDiv = document.getElementById("childDiv")
    1.39 +        , parentDivLocked = false
    1.40 +        , parentDivFullScreen = false
    1.41 +        , pointerLocked = false;
    1.42 +
    1.43 +      function runTests () {
    1.44 +        ok(parentDivLocked, "After requesting pointerlock on parentDiv " +
    1.45 +          "document.mozPointerLockElement should be equal to " +
    1.46 +          " parentDiv element");
    1.47 +        isnot(pointerLocked, true, "Requesting fullscreen on " +
    1.48 +          "childDiv while parentDiv still in fullscreen should " +
    1.49 +          "unlock the pointer");
    1.50 +      }
    1.51 +
    1.52 +      document.addEventListener("mozpointerlockchange", function (e) {
    1.53 +        if (document.mozPointerLockElement === parentDiv) {
    1.54 +          parentDivLocked = true;
    1.55 +          childDiv.mozRequestFullScreen();
    1.56 +        }
    1.57 +      }, false);
    1.58 +
    1.59 +      document.addEventListener("mozfullscreenchange", function() {
    1.60 +        if (document.mozFullScreenElement === parentDiv) {
    1.61 +          if (parentDivFullScreen === true) {
    1.62 +            document.mozCancelFullScreen();
    1.63 +          }
    1.64 +          parentDivFullScreen = true;
    1.65 +          parentDiv.mozRequestPointerLock();
    1.66 +        }
    1.67 +        else if (document.mozFullScreenElement === childDiv) {
    1.68 +          pointerLocked = !!document.mozPointerLockElement;
    1.69 +          document.mozCancelFullScreen();
    1.70 +        }
    1.71 +        else {
    1.72 +          runTests();
    1.73 +          SimpleTest.finish();
    1.74 +        }
    1.75 +      }, false);
    1.76 +
    1.77 +      function start() {
    1.78 +        parentDiv.mozRequestFullScreen();
    1.79 +      }
    1.80 +    </script>
    1.81 +  </body>
    1.82 +</html>

mercurial