tor-browser

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

test_keyboard_event.html (1784B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1222285
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 1222285</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="/tests/SimpleTest/EventUtils.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12  <script type="application/javascript">
     13 
     14  /** Test for Bug 1222285 */
     15  SimpleTest.waitForExplicitFinish();
     16 
     17  window.onload = () => {
     18    SpecialPowers.pushPrefEnv({"set":
     19      [
     20        ["privacy.resistFingerprinting", true],
     21      ],
     22    }, doTestForSystemEventGroup);
     23  };
     24 
     25  // This test makes sure that system event group will still get real keyboard event.
     26  function doTestForSystemEventGroup() {
     27    SpecialPowers.wrap(document).addEventListener("keydown",
     28      function eventHandler(aEvent) {
     29        is(aEvent.code, "Minus", "The system group event should get real code.");
     30        is(aEvent.keyCode, 63, "The system group event should get real keyCode.");
     31 
     32        doTestModifiersForSystemEventGroup();
     33      }, { once: true, capture: true, mozSystemGroup: true });
     34 
     35    // Send key event to the system group.
     36    synthesizeKey("\u00DF", {code: "Minus", keyCode: 63});
     37  }
     38 
     39  // Test that will system group event still get suppressed modifier keys
     40  function doTestModifiersForSystemEventGroup() {
     41    SpecialPowers.wrap(document).addEventListener("keydown",
     42      function eventHandler(aEvent) {
     43        is(aEvent.key, "Alt", "The system group event get the suppressed keyboard event.");
     44 
     45        SimpleTest.finish();
     46      }, { once: true, capture: true, mozSystemGroup: true });
     47 
     48    // Send key event to the system group.
     49    synthesizeKey("KEY_Alt", {altKey: true});
     50  }
     51 
     52  </script>
     53 </head>
     54 <body>
     55 </body>
     56 </html>