tor-browser

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

HTMLLinkElement-disabled-004.html (1572B)


      1 <!doctype html>
      2 <title>&lt;link disabled&gt;'s "explicitly enabled" state doesn't persist for clones</title>
      3 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
      4 <link rel="author" title="Mozilla" href="https://mozilla.org">
      5 <link rel="help" href="https://html.spec.whatwg.org/#attr-link-disabled">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <link title="alt" rel="alternate stylesheet" disabled href="data:text/css,html { background: green }">
      9 <script>
     10 function assert_applies(applies) {
     11  (applies ? assert_equals : assert_not_equals)(getComputedStyle(document.documentElement).backgroundColor, "rgb(0, 128, 0)");
     12 }
     13 
     14 const link = document.querySelector("link[disabled]");
     15 
     16 async_test(function(t) {
     17  link.remove();
     18  link.disabled = false; // `link` is explicitly enabled.
     19 
     20  let clonesLoaded = 0;
     21 
     22  for (let shallow of [true, false]) {
     23    const clone = link.cloneNode(shallow);
     24    clone.onload = t.step_func(function() {
     25      assert_false(link.disabled);
     26      // Even though it's not disabled, it still doesn't apply, since it's an alternate.
     27      assert_applies(false);
     28      if (++clonesLoaded == 2) {
     29        link.onload = t.step_func_done(function() {
     30          assert_false(link.disabled);
     31          assert_applies(true); // `link` is still explicitly enabled.
     32        });
     33        document.head.appendChild(link);
     34      }
     35    });
     36    document.head.appendChild(clone);
     37  }
     38 }, "HTMLLinkElement.disabled's explicitly enabled state doesn't persist on clones");
     39 </script>