dom/tests/mochitest/pointerlock/file_escapeKey.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/pointerlock/file_escapeKey.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--https://bugzilla.mozilla.org/show_bug.cgi?id=633602-->
     1.7 +<head>
     1.8 +  <title>Bug 633602</title>
     1.9 +  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js">
    1.10 +  </script>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js">
    1.12 +  </script>
    1.13 +  <script type="application/javascript" src="pointerlock_utils.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.15 +</head>
    1.16 +<body>
    1.17 +  <a target="_blank"
    1.18 +    href="https://bugzilla.mozilla.org/show_bug.cgi?id=633602">
    1.19 +    Mozilla Bug 633602
    1.20 +  </a>
    1.21 +  <div id="div"></div>
    1.22 +  <pre id="test">
    1.23 +    <script type="text/javascript">
    1.24 +      /*
    1.25 +       * Test for Bug 633602
    1.26 +       * Escape key should unlock the pointer
    1.27 +       */
    1.28 +
    1.29 +      SimpleTest.waitForExplicitFinish();
    1.30 +
    1.31 +      var div = document.getElementById("div")
    1.32 +        , pointerUnLocked = false;
    1.33 +
    1.34 +      function runTests () {
    1.35 +        ok(pointerUnLocked, "Pressing Escape key should unlock the pointer");
    1.36 +      }
    1.37 +
    1.38 +      document.addEventListener("mozpointerlockchange", function (e) {
    1.39 +        if (document.mozPointerLockElement === div) {
    1.40 +          synthesizeKey("VK_ESCAPE", {});
    1.41 +        }
    1.42 +        else {
    1.43 +          pointerUnLocked = true;
    1.44 +          document.mozCancelFullScreen();
    1.45 +        }
    1.46 +      }, false);
    1.47 +
    1.48 +      document.addEventListener("mozfullscreenchange", function(e) {
    1.49 +        if (document.mozFullScreenElement === div) {
    1.50 +          div.mozRequestPointerLock();
    1.51 +        }
    1.52 +        else {
    1.53 +          runTests();
    1.54 +          SimpleTest.finish();
    1.55 +        }
    1.56 +      }, false);
    1.57 +
    1.58 +      function start() {
    1.59 +        div.mozRequestFullScreen();
    1.60 +      }
    1.61 +    </script>
    1.62 +  </pre>
    1.63 +</body>
    1.64 +</html>

mercurial