tor-browser

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

mouse_buttons_back_forward.html (2281B)


      1 <!DOCTYPE html>
      2 <html>
      3    <head>
      4        <meta charset="utf-8" />
      5        <title>Mouse Button Back/Forward</title>
      6        <link rel="author" title="Google" href="http://www.google.com/" />
      7        <script src="/resources/testharness.js"></script>
      8        <script src="/resources/testharnessreport.js"></script>
      9        <script src="/resources/testdriver.js"></script>
     10        <script src="/resources/testdriver-actions.js"></script>
     11        <script src="/resources/testdriver-vendor.js"></script>
     12        <script>
     13            var testMouseUp = async_test('Tests that the mouseup is preventable.');
     14            var received_back = false;
     15            var received_forward = false;
     16            const backButton = 3;
     17            const forwardButton = 4;
     18            var actions_promise;
     19            window.addEventListener('mouseup', function(e) {
     20              if (e.button == backButton) {
     21                received_back = true;
     22                e.preventDefault();
     23              } else if (e.button == forwardButton) {
     24                received_forward = true;
     25                e.preventDefault();
     26              }
     27              if (received_back && received_forward) {
     28                // Make sure the test finishes after all the input actions are completed.
     29                actions_promise.then( () => {
     30                  testMouseUp.done();
     31                });
     32              }
     33            });
     34 
     35            function inject_input() {
     36                // First click on back button and then forward button.
     37                var actions = new test_driver.Actions();
     38                actions_promise = actions.pointerMove(0, 0, {origin: target})
     39                    .pointerDown({button: actions.ButtonType.BACK})
     40                    .pointerUp({button: actions.ButtonType.BACK})
     41                    .pointerDown({button: actions.ButtonType.FORWARD})
     42                    .pointerUp({button: actions.ButtonType.FORWARD})
     43                    .send();
     44            }
     45        </script>
     46 
     47    </head>
     48    <body id="target" onload="inject_input()">
     49        <h4>Test Description: Tests that the mouseup event is prevented.
     50            <ol>
     51                <li>Click the back mouse button</li>
     52                <li>Click the back mouse forward</li>
     53            </ol>
     54        </h4>
     55    </body>
     56 </html>