tor-browser

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

summary-untrusted-key-event.html (2037B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4 <title>Summary</title>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 </head>
      8 <body>
      9 <div id="log"></div>
     10 <details>
     11  <summary>Summary</summary>
     12  Details
     13 </details>
     14 <script type="module">
     15 const details = document.querySelector("details");
     16 details.addEventListener("toggle",
     17  (e) => assert_true(false, 'details should not be toggled'));
     18 
     19 const summary = document.querySelector("summary");
     20 summary.addEventListener("click",
     21  (e) => assert_true(false, `summary should not be clicked`));
     22 
     23 test(() => {
     24  // keyCode: Enter
     25  summary.dispatchEvent(
     26    new KeyboardEvent("keypress", {
     27      keyCode: 13,
     28    })
     29  );
     30 
     31  // key: Enter
     32  summary.dispatchEvent(
     33    new KeyboardEvent("keypress", {
     34      key: "Enter",
     35    })
     36  );
     37 
     38  // keyCode: Space
     39  summary.dispatchEvent(
     40    new KeyboardEvent("keypress", {
     41      keyCode: 32,
     42    })
     43  );
     44 
     45  // key: Space
     46  summary.dispatchEvent(
     47    new KeyboardEvent("keypress", {
     48      key: " ",
     49    })
     50  );
     51 }, `Dispatching untrusted keypress events to summary should not cause click event`);
     52 
     53 test(() => {
     54  // keyCode: Enter
     55  summary.dispatchEvent(
     56    new KeyboardEvent("keydown", {
     57      keyCode: 13,
     58    })
     59  );
     60  summary.dispatchEvent(
     61    new KeyboardEvent("keyup", {
     62      keyCode: 13,
     63    })
     64  );
     65 
     66  // key: Enter
     67  summary.dispatchEvent(
     68    new KeyboardEvent("keydown", {
     69      key: "Enter",
     70    })
     71  );
     72  summary.dispatchEvent(
     73    new KeyboardEvent("keyup", {
     74      key: "Enter",
     75    })
     76  );
     77 
     78  // keyCode: Space
     79  summary.dispatchEvent(
     80    new KeyboardEvent("keydown", {
     81      keyCode: 32,
     82    })
     83  );
     84  summary.dispatchEvent(
     85    new KeyboardEvent("keyup", {
     86      keyCode: 32,
     87    })
     88  );
     89 
     90  // key: Space
     91  summary.dispatchEvent(
     92    new KeyboardEvent("keydown", {
     93      key: " ",
     94    })
     95  );
     96  summary.dispatchEvent(
     97    new KeyboardEvent("keyup", {
     98      key: " ",
     99    })
    100  );
    101 }, `Dispatching untrusted keyup/keydown events to summary should not cause click event`);
    102 </script>
    103 </body>
    104 </html>