tor-browser

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

pointerlock_unadjustedMovement.html (1592B)


      1 <!DOCTYPE html>
      2 <html>
      3 <body>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/resources/testdriver.js"></script>
      7 <script src="/resources/testdriver-actions.js"></script>
      8 <script src="/resources/testdriver-vendor.js"></script>
      9 </head>
     10 <body>
     11    <h2>Description</h2>
     12    <p>This test validates that pointer lock accepts the unadjustedMovement option.</p>
     13    <hr/>
     14 
     15    <button id="Button">lockTarget</button>
     16    <div id="target">Target</div>
     17 
     18    <script type="text/javascript" >
     19        const button = document.getElementById('Button');
     20        const target = document.getElementById('target');
     21 
     22        async_test(t => {
     23            button.addEventListener('mousedown', t.step_func(() => {
     24                const p = target.requestPointerLock({unadjustedMovement: true});
     25                p.then(t.step_func(() => {
     26                    assert_equals(document.pointerLockElement, target);
     27                    t.done();
     28                })).catch(t.step_func((error) => {
     29                    // requestPointerLock may throw NotSupportedError to say unadjustedMovement isn't supported.
     30                    assert_throws_dom("NotSupportedError", () => { throw error; });
     31                    // but to pass this test fully, it unadjustedMovement must be supported.
     32                    assert_unreached("unadjustedMovement must be implemented.");
     33                    t.done();
     34                }));
     35            }));
     36        });
     37 
     38        // Automated testing
     39        test_driver.click(button);
     40    </script>
     41    </body>
     42 </html>