tor-browser

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

highlight-cascade-009.html (2173B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>CSS Pseudo-Elements Test: highlight cascade: inheritance of custom properties</title>
      4 <link rel="author" title="Stephen Chenney" href="mailto:schenney@chromium.org">
      5 <link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#highlight-cascade">
      6 <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/6641">
      7 <meta name="assert" content="This test verifies that custom properties used in highlight pseudos are taken from the highlight and originating element.">
      8 <script src="../support/selections.js"></script>
      9 <link rel="stylesheet" href="../support/highlights.css">
     10 <script src="/resources/testharness.js"></script>
     11 <script src="/resources/testharnessreport.js"></script>
     12 <style>
     13  body {
     14    --background-color: green;
     15    --decoration-color: green;
     16  }
     17  body::selection {
     18    --decoration-color: purple;
     19  }
     20  div::selection {
     21    --background-color: blue;
     22    background-color: var(--background-color, red);
     23  }
     24 </style>
     25 <body>
     26  <div>Some text</div>
     27 </body>
     28 <script>
     29    selectNodeContents(document.querySelector("body"));
     30 
     31    const div_style = getComputedStyle(document.querySelector("div"));
     32    const body_selection = getComputedStyle(document.querySelector("body"), "::selection");
     33    const div_selection = getComputedStyle(document.querySelector("div"), "::selection");
     34    test(() => void assert_equals(body_selection.getPropertyValue("--background-color"), "green"),
     35        "body ::selection uses the originating custom property");
     36    test(() => void assert_equals(body_selection.getPropertyValue("--decoration-color"), "purple"),
     37        "body ::selection uses its own custom property");
     38    test(() => void assert_equals(div_selection.getPropertyValue("--decoration-color"), "green"),
     39        "div::selection uses the originating element custom property");
     40    test(() => void assert_equals(div_selection.getPropertyValue("--background-color"), "blue"),
     41        "div::selection uses its own custom property");
     42    test(() => void assert_equals(div_style.getPropertyValue("--background-color"), "green"),
     43        "div::selection properties are not present on the originating element");
     44 </script>