tor-browser

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

slot-element-tabbable.tentative.html (2353B)


      1 <!DOCTYPE html>
      2 <title>CSS Test (Display): <slot> elements should be tabbable</title>
      3 <link rel="author" title="L. David Baron" href="https://dbaron.org/">
      4 <link rel="author" title="Google" href="http://www.google.com/">
      5 <link rel="help" href="https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3">
      6 <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/2632">
      7 <link rel="help" href="https://github.com/whatwg/html/issues/1837">
      8 <link rel="help" href="https://github.com/whatwg/html/pull/9425">
      9 <link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1366037">
     10 <!--
     11 
     12  This requirement is not particularly clear from current specs,
     13  so this test is tentative.  See issues above.
     14 
     15 -->
     16 <script src="/resources/testharness.js"></script>
     17 <script src="/resources/testharnessreport.js"></script>
     18 <script src="/resources/testdriver.js"></script>
     19 <script src="/resources/testdriver-vendor.js"></script>
     20 
     21 <body>
     22 
     23 <div id="before" tabindex="1" style="height: 10px"></div>
     24 
     25 <script>
     26 
     27  function do_test(slot_style, description) {
     28    promise_test(
     29      async () => {
     30        let before = document.getElementById("before");
     31        before.focus();
     32        let host = document.createElement("div");
     33        document.body.appendChild(host);
     34        var root = host.attachShadow({mode:"open"});
     35        root.innerHTML = `
     36          <style>
     37            slot       { --test-value: slot-not-focused; }
     38            slot:focus { --test-value: slot-is-focused; }
     39          </style>
     40          <slot tabindex="1" style="${slot_style}"></slot>
     41        `;
     42        let slot = root.querySelector("slot");
     43        let cs = getComputedStyle(slot);
     44        assert_equals(document.activeElement, before, "precondition");
     45        assert_not_equals(root.activeElement, slot, "precondition");
     46        assert_equals(cs.getPropertyValue("--test-value"), "slot-not-focused", "precondition (style)");
     47        await test_driver.send_keys(before, "\uE004");
     48        assert_equals(root.activeElement, slot, "slot is now focused");
     49        assert_equals(cs.getPropertyValue("--test-value"), "slot-is-focused", "slot is now focused (style)");
     50        document.body.removeChild(host);
     51      }, `slot element with ${description} should be focusable`);
     52  }
     53 
     54  do_test("display: block", "display: block");
     55  do_test("", "default style");
     56 
     57 </script>