tor-browser

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

getComputedStyle-display-none-001.html (1783B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>CSSOM: getComputedStyle gets invalidated for display: none elements (inheritance)</title>
      4 <link rel="help" href="https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle">
      5 <link rel="help" href="https://bugs.webkit.org/show_bug.cgi?id=186882">
      6 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
      7 <script src=/resources/testharness.js></script>
      8 <script src=/resources/testharnessreport.js></script>
      9 <style>
     10 #undisplayed, #host {
     11  display: none;
     12  color: red;
     13 }
     14 </style>
     15 <div id="undisplayed"><div id="child"></div></div>
     16 <div id="host"></div>
     17 <script>
     18  test(function() {
     19    let undisplayed_style = getComputedStyle(undisplayed);
     20    let undisplayed_child_style = getComputedStyle(child);
     21    assert_equals(undisplayed_style.color, "rgb(255, 0, 0)");
     22    assert_equals(undisplayed_child_style.color, "rgb(255, 0, 0)");
     23    undisplayed.style.color = "green";
     24    assert_equals(undisplayed_style.color, "rgb(0, 128, 0)");
     25    assert_equals(undisplayed_child_style.color, "rgb(0, 128, 0)");
     26  }, "getComputedStyle gets invalidated in display: none subtrees due to inherited changes to an ancestor");
     27  test(function() {
     28    host.attachShadow({ mode: 'open' }).innerHTML = `
     29      <div></div>
     30    `;
     31    let host_style = getComputedStyle(host);
     32    let shadow_style = getComputedStyle(host.shadowRoot.firstElementChild);
     33    assert_equals(host_style.color, "rgb(255, 0, 0)");
     34    assert_equals(shadow_style.color, "rgb(255, 0, 0)");
     35    host.style.color = "green";
     36    assert_equals(host_style.color, "rgb(0, 128, 0)");
     37    assert_equals(shadow_style.color, "rgb(0, 128, 0)");
     38  }, "getComputedStyle gets invalidated in display: none subtrees due to inherited changes to an ancestor shadow host");
     39 </script>