tor-browser

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

focus-management-expectations.html (1613B)


      1 <!DOCTYPE html>
      2 <html>
      3 
      4 <head>
      5  <meta charset="utf-8">
      6  <title>Focus management event expectations</title>
      7  <link rel="author" title="Mu-An Chiou" href="https://muan.co">
      8  <link rel="help" href="https://w3c.github.io/uievents/#event-flow-activation">
      9  <script src="/resources/testharness.js"></script>
     10  <script src="/resources/testharnessreport.js"></script>
     11  <script src="/resources/testdriver.js"></script>
     12  <script src="/resources/testdriver-actions.js"></script>
     13  <script src="/resources/testdriver-vendor.js"></script>
     14 </head>
     15 
     16 <body>
     17  <button type="button" id="fromEl">Focus management from button</button>
     18  <button type="button" id="toEl">To button</button>
     19  <button type="button" id="EndTestEl">End test button</button>
     20 </body>
     21 
     22 <script>
     23  const from = document.getElementById("fromEl")
     24  const to = document.getElementById("toEl")
     25  const endTest = document.getElementById("EndTestEl")
     26 
     27  from.addEventListener("keydown", function (event) {
     28    if (event.key === " ") to.focus()
     29  })
     30 
     31  async_test(function (t) {
     32    let buttonFocused = false
     33    to.addEventListener("click", t.unreached_func("Button should not be clicked"))
     34    to.addEventListener("focus", () => buttonFocused = true)
     35    endTest.addEventListener('click', t.step_func(() => {
     36      assert_true(buttonFocused, "Button should be focused")
     37      t.step_timeout(() => t.done(), 200)
     38    }))
     39 
     40    // execute test
     41    from.focus()
     42    new test_driver.Actions().keyDown("\ue00d").keyUp("\ue00d").send().then(() =>
     43      new test_driver.click(endTest)
     44    )
     45  }, "Keydown to focus should not trigger activation")
     46 </script>
     47 
     48 </html>