input-disabled-fieldset-dynamic.html (1391B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1861027"> 4 <script src=/resources/testharness.js></script> 5 <script src=/resources/testharnessreport.js></script> 6 <script src=/resources/testdriver.js></script> 7 <script src=/resources/testdriver-actions.js></script> 8 <script src=/resources/testdriver-vendor.js></script> 9 <fieldset id="fieldset" disabled> 10 <input id="target"> 11 </fieldset> 12 <script> 13 const target = document.getElementById("target"); 14 const fieldset = document.getElementById("fieldset"); 15 promise_test(async function() { 16 await new Promise(r => window.addEventListener("load", r, { once: true })); 17 assert_true(target.matches(":disabled"), "Fieldset disables the input"); 18 assert_true(target.matches(":read-only"), "Disabled implies read-only"); 19 20 // Try to focus, it shouldn't be focusable. 21 target.focus(); 22 23 assert_not_equals(document.activeElement, target, "Should not be focusable"); 24 25 fieldset.removeAttribute("disabled"); 26 27 assert_false(target.matches(":disabled"), "Should go back to writable"); 28 assert_false(target.matches(":read-only"), "No longer read-only"); 29 30 // Should be focusable now. 31 target.focus(); 32 33 assert_equals(document.activeElement, target, "Should not be focusable"); 34 35 await test_driver.send_keys(target, "A"); 36 assert_equals(target.value, "A", "Typing should work"); 37 }); 38 </script>