tor-browser

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

hidden-ua-stylesheet.html (2345B)


      1 <!DOCTYPE html>
      2 <link rel=author href="mailto:jarhar@chromium.org">
      3 <link rel=help href="https://html.spec.whatwg.org/multipage/rendering.html#hiddenCSS">
      4 <link rel=help href="https://github.com/whatwg/html/pull/7475#issuecomment-1069313217">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 
      8 <div id=div>hello world</div>
      9 <table id=table>
     10  <colgroup id=colgroup>
     11    <col id=col></col>
     12  </colgroup>
     13 </table>
     14 
     15 <script>
     16 function testDisplayNone(description) {
     17  test(() => {
     18    assert_equals(getComputedStyle(div).display, 'none',
     19        `${description} should make the div display:none.`);
     20    assert_equals(getComputedStyle(div).contentVisibility, 'visible',
     21        `${description} should not affect the div's content-visibility property.`);
     22  }, description);
     23 }
     24 
     25 function testCVHidden(description) {
     26  test(() => {
     27    assert_equals(getComputedStyle(div).display, 'block',
     28        `${description} should not affect the div's display property.`);
     29    assert_equals(getComputedStyle(div).contentVisibility, 'hidden',
     30        `${description} should make the div content-visibility:hidden.`);
     31    assert_equals(div.hidden, "until-found",
     32      `${description} should make the div hidden=until-found.`);
     33  }, description);
     34 
     35 }
     36 
     37 function testNormal(description) {
     38  test(() => {
     39    assert_equals(getComputedStyle(div).display, 'block',
     40        `${description} should not affect the div's display property.`);
     41    assert_equals(getComputedStyle(div).contentVisibility, 'visible',
     42        `${description} should not affect the div's content-visibility property.`);
     43  }, description);
     44 }
     45 
     46 test(() => {
     47  div.removeAttribute('hidden');
     48  testNormal(`div.removeAttribute('hidden')`);
     49 
     50  div.setAttribute('hidden', '');
     51  testDisplayNone(`div.setAttribute('hidden', '')`);
     52 
     53  div.setAttribute('hidden', 'asdf');
     54  testDisplayNone(`div.setAttribute('hidden', 'asdf')`);
     55 
     56  div.setAttribute('hidden', 'until-found');
     57  testCVHidden(`div.setAttribute('hidden', 'until-found')`);
     58 
     59  div.setAttribute('hidden', 'UNTIL-FOUND');
     60  testCVHidden(`div.setAttribute('hidden', 'UNTIL-FOUND')`);
     61 
     62  div.setAttribute('hidden', 'UnTiL-FoUnD');
     63  testCVHidden(`div.setAttribute('hidden', 'UnTiL-FoUnD')`);
     64 
     65  div.setAttribute('hidden', '0');
     66  testDisplayNone(`div.setAttribute('hidden', '0')`);
     67 });
     68 </script>