HTMLLinkElement-disabled-002.html (1528B)
1 <!doctype html> 2 <title><link disabled>, HTMLLinkElement.disabled and CSSStyleSheet.disabled interactions (alternate)</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 assert_true(link.disabled); 18 19 link.onload = t.step_func_done(function() { 20 assert_equals(document.styleSheets.length, 1); 21 let sheet = document.styleSheets[0]; 22 assert_equals(sheet.ownerNode, link); 23 assert_applies(true); 24 25 link.disabled = true; 26 assert_equals(sheet.ownerNode, null); 27 assert_false(sheet.disabled); 28 assert_applies(false); 29 assert_true(link.hasAttribute("disabled")); 30 assert_equals(document.styleSheets.length, 0); 31 }); 32 33 link.disabled = false; 34 assert_true(!link.hasAttribute("disabled")); 35 assert_false(link.disabled); 36 }, "HTMLLinkElement.disabled reflects the <link disabled> attribute, and behaves consistently, when the sheet is an alternate"); 37 </script>