tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

file_targetOutOfFocus.html (1969B)


      1 <!DOCTYPE HTML>
      2 <html>
      3  <!--
      4  https://bugzilla.mozilla.org/show_bug.cgi?id=633602
      5  -->
      6  <head>
      7    <title>Bug 633602 - file_targetOutOfFocus.html</title>
      8    <script src="/tests/SimpleTest/SimpleTest.js">
      9    </script>
     10    <script 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    <p id="display"></p>
     21    <div id="content">
     22    </div>
     23    <div id="div">
     24      <input id="input" type="text" />
     25    </div>
     26    <pre id="test">
     27      <script type="application/javascript">
     28        /*
     29         * Test for Bug 633602
     30         * Element doesn't need to have focus to request
     31         * pointer lock
     32        */
     33 
     34        SimpleTest.waitForExplicitFinish();
     35 
     36        var div = document.getElementById("div")
     37          , input = document.getElementById("input")
     38          , divPointerLock = false;
     39 
     40        function runTests () {
     41          ok(divPointerLock, "Pointer should be locked even if " +
     42            "the element being locked is not focused");
     43        }
     44 
     45        input.addEventListener("focus", function() {
     46          div.requestPointerLock();
     47        }, { once: true });
     48 
     49        document.addEventListener("pointerlockchange", function (e) {
     50          if (document.pointerLockElement === div) {
     51            divPointerLock = true;
     52            addFullscreenChangeContinuation("exit", function() {
     53              runTests();
     54              SimpleTest.finish();
     55            });
     56            document.exitFullscreen();
     57          }
     58        });
     59 
     60        function start() {
     61          addFullscreenChangeContinuation("enter", function() {
     62            input.focus();
     63          });
     64          div.requestFullscreen();
     65        }
     66      </script>
     67    </pre>
     68  </body>
     69 </html>