tor-browser

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

focus-within-display-none-001.html (2696B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Selectors Level 4: focus-within</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/#focus-within-pseudo">
      6 <link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule">
      7 <meta name="assert" content="Checks ':focus-within' pseudo-class after 'display: none'.">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <div id="wrapper">
     11  <input id="input">
     12 </div>
     13 <script>
     14  "use strict";
     15 
     16  const wrapper = document.getElementById("wrapper");
     17  const input = document.getElementById("input");
     18 
     19  async_test((t) => {
     20    input.focus();
     21    window.requestAnimationFrame(() => {
     22      t.step(() => assert_true(input.matches(":focus-within"),
     23                               "Check input matches ':focus-within' after being focused"));
     24      t.step(() => assert_true(wrapper.matches(":focus-within"),
     25                               "Check wrapper matches ':focus-within' after child was focused"));
     26 
     27      input.style.display = "none";
     28      window.requestAnimationFrame(() => {
     29        t.step(() => assert_false(input.matches(":focus-within"),
     30                                  "Check input doesn't match ':focus-within' after getting 'display: none'"));
     31        t.step(() => assert_false(wrapper.matches(":focus-within"),
     32                                 "Check wrapper doesn't match ':focus-within' after child got 'display: none'"));
     33        input.style.display = "inline";
     34        t.done();
     35      });
     36    });
     37  }, "Test ':focus-within' after 'display:none' on input");
     38 
     39  async_test((t) => {
     40    input.focus();
     41    window.requestAnimationFrame(() => {
     42      t.step(() => assert_true(input.matches(":focus-within"),
     43                               "Check input matches ':focus-within' after being focused"));
     44      t.step(() => assert_true(wrapper.matches(":focus-within"),
     45                               "Check wrapper matches ':focus-within' after child was focused"));
     46 
     47      wrapper.style.display = "none";
     48      window.requestAnimationFrame(() => {
     49        t.step(() => assert_false(input.matches(":focus-within"),
     50                                  "Check input doesn't match ':focus-within' after parent got 'display: none'"));
     51        t.step(() => assert_false(wrapper.matches(":focus-within"),
     52                                 "Check wrapper doesn't match ':focus-within' after getting 'display: none'"));
     53        wrapper.style.display = "block";
     54        t.done();
     55      });
     56    });
     57  }, "Test ':focus-within' after 'display:none' on input's parent");
     58 </script>