tor-browser

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

hidden-idl.html (1890B)


      1 <!DOCTYPE html>
      2 <link rel=author href="mailto:jarhar@chromium.org">
      3 <link rel=help href="https://github.com/whatwg/html/pull/7475">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <div>hello</div>
      8 <script>
      9 const div = document.querySelector('div');
     10 
     11 function runPropertyTest(assignedValue, expectedValue, expectedAttribute) {
     12  test(() => {
     13    div.hidden = assignedValue;
     14    assert_equals(div.hidden, expectedValue,
     15      `div.hidden = ${JSON.stringify(assignedValue)} should return ${JSON.stringify(expectedValue)}`);
     16    assert_equals(div.getAttribute('hidden'), expectedAttribute,
     17      `div.hidden = ${JSON.stringify(assignedValue)} should set the hidden attribute to ${JSON.stringify(expectedAttribute)}`);
     18  }, `div.hidden = ${Number.isNaN(assignedValue) ? 'NaN' : JSON.stringify(assignedValue)}`);
     19 }
     20 
     21 function runAttributeTest(assignedAttribute, expectedValue) {
     22  test(() => {
     23    div.setAttribute('hidden', assignedAttribute);
     24    assert_equals(div.hidden, expectedValue);
     25  }, `div.setAttribute('hidden', ${JSON.stringify(assignedAttribute)}) should make div.hidden return ${JSON.stringify(expectedValue)}`);
     26 }
     27 
     28 runPropertyTest(false, false, null);
     29 runPropertyTest(true, true, '');
     30 runPropertyTest('foo', true, '');
     31 runPropertyTest('false', true, '');
     32 runPropertyTest('', false, null);
     33 
     34 runAttributeTest('false', true);
     35 runAttributeTest('foo', true);
     36 
     37 runPropertyTest('until-found', 'until-found', 'until-found');
     38 runPropertyTest('UNTIL-FOUND', 'until-found', 'until-found');
     39 runPropertyTest('UnTiL-FoUnD', 'until-found', 'until-found');
     40 runPropertyTest('unt\u0131l-found', true, '');
     41 runPropertyTest('unt\u0130l-found', true, '');
     42 
     43 runPropertyTest(null, false, null);
     44 runPropertyTest(undefined, false, null);
     45 
     46 runPropertyTest(1, true, '');
     47 runPropertyTest(0, false, null);
     48 runPropertyTest(NaN, false, null);
     49 </script>