tor-browser

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

focus-visible-script-focus-017.tentative.html (2613B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8" />
      3 <title>CSS Test (Selectors): Script focus after blur after mouse click on a NOT focusable element after editing an input does match :focus-visible</title>
      4 <link rel="author" title="Manuel Rego Casasnovas" href="mailto:rego@igalia.com">
      5 <link rel="help" href="https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo" />
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script src="/resources/testdriver.js"></script>
      9 <script src="/resources/testdriver-vendor.js"></script>
     10 <script src="/css/support/parsing-testcommon.js"></script>
     11 <style>
     12  #warning {
     13    display: none;
     14    background: red;
     15  }
     16 
     17  @supports not selector(:focus-visible) {
     18    #instructions {
     19      display: none;
     20    }
     21 
     22    #warning {
     23      display: block;
     24    }
     25  }
     26 
     27  :focus-visible {
     28    outline: solid thick green;
     29  }
     30 
     31  :focus:not(:focus-visible) {
     32    background-color: red;
     33  }
     34 </style>
     35 
     36 <p>This test checks that a script focus after blur after a mouse click on a NOT focusable element after editing an input does match <code>:focus-visible</code>.</p>
     37 <ol id="instructions">
     38  <li>Click on the input below and type some letter.</li>
     39  <li>Then click on the element that says "Click me".</li>
     40  <li>If the element that says "Focused" has a red background then the test result is FAILURE, if it has a green outline then the test result is SUCCESS.</li>
     41 </ol>
     42 <p id="warning">Your user-agent does not support <code>:focus-visible</code> pseudo-class, please SKIP this test.</p>
     43 
     44 <input id="initial">
     45 <div id="trigger">Click me</div>
     46 <div id="target" tabindex="0">Focused</div>
     47 
     48 <script>
     49  setup({ explicit_done: true });
     50 
     51  // Check that :focus-visible is supported.
     52  test_valid_selector(':focus-visible');
     53 
     54  trigger.addEventListener("click", () => {
     55    document.activeElement.blur();
     56    target.focus();
     57  });
     58 
     59  async_test(function(t) {
     60    initial.addEventListener("keypress", () => {
     61      test_driver.click(trigger).then(() => done());
     62    });
     63 
     64    target.addEventListener("focus", t.step_func_done(function() {
     65      assert_equals(getComputedStyle(target).outlineColor, "rgb(0, 128, 0)", `outlineColor for ${target.tagName}#${target.id} should be green`);
     66      assert_not_equals(getComputedStyle(target).backgroundColor, "rgb(255, 0, 0)", `backgroundColor for ${target.tagName}#${target.id} should NOT be red`);
     67    }));
     68 
     69    initial.focus();
     70    test_driver.send_keys(initial, "a");
     71  }, "Script focus after blur after mouse click on a NOT focusable element after editing an input does match :focus-visible");
     72 </script>