tor-browser

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

highlight-pseudo-computed.html (1726B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>CSS ::highlight Pseudo-Element Test: ::highlight selector getComputedStyle</title>
      4 <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <style>
      8  #target::highlight(foo) {
      9    background-color: green;
     10    color: lime;
     11  }
     12 
     13  #target::highlight(bar) {
     14    background-color: cyan;
     15    color: fuchsia;
     16  }
     17 </style>
     18 <div id="target"></div>
     19 <script>
     20  let highlightPseudo = "::highlight(foo)";
     21  test(() => {
     22    let style = getComputedStyle(target, highlightPseudo);
     23    assert_equals(style.backgroundColor, "rgb(0, 128, 0)", "Background color is green.");
     24    assert_equals(style.color, "rgb(0, 255, 0)", "Color is lime.");
     25  }, `getComputedStyle() for ${highlightPseudo}`);
     26 
     27  highlightPseudo = "::highlight(bar)";
     28  test(() => {
     29    let style = getComputedStyle(target, highlightPseudo);
     30    assert_equals(style.backgroundColor, "rgb(0, 255, 255)", "Background color is cyan.");
     31    assert_equals(style.color, "rgb(255, 0, 255)", "Color is fuchsia.");
     32  }, `Different getComputedStyle() for ${highlightPseudo} and same element`);
     33 
     34  for (const illHighlightPseudo of ["::highlight(foo):", "::highlight(foo))", "::highlight(foo)(", "::highlight", "::highlight(foo)(foo)", "::highlight(foo)()", ":::highlight(foo)", "::highlight(foo).", "::highlight(foo,bar)", "::highlight(foo bar)"]) {
     35    test(() => {
     36      let style = getComputedStyle(target, illHighlightPseudo);
     37      assert_equals(style.length, 0, "Invalid pseudo identifiers should not return a style.");
     38    }, `getComputedStyle() for ${illHighlightPseudo} should not return a style.`);
     39  }
     40 </script>