OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Selector: pseudo-classes (:read-write, :read-only)</title> |
| 4 <link rel=help href="https://html.spec.whatwg.org/multipage/#pseudo-classes" id=
link2> |
| 5 <script src="../../../../../../resources/testharness.js"></script> |
| 6 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 7 <script src="utils.js"></script> |
| 8 <div id="log"></div> |
| 9 |
| 10 <div id=set1> |
| 11 <input id=input1> |
| 12 <input id=input2 readonly> |
| 13 <input id=input3 disabled> |
| 14 <input id=input4 type=checkbox> |
| 15 <input id=input5 type=checkbox readonly> |
| 16 </div> |
| 17 |
| 18 <div id=set2> |
| 19 <textarea id=textarea1>textarea1</textarea> |
| 20 <textarea readonly id=textarea2>textarea2</textarea> |
| 21 </div> |
| 22 |
| 23 <div id=set3> |
| 24 <textarea id=textarea3>textarea3</textarea> |
| 25 <textarea disabled id=textarea4>textarea4</textarea> |
| 26 </div> |
| 27 |
| 28 <div id=set4> |
| 29 <p id=p1>paragraph1.</p> |
| 30 <p id=p2 contenteditable>paragraph2.</p> |
| 31 </div> |
| 32 |
| 33 <script> |
| 34 testSelector("#set1 :read-write", ["input1"], "The :read-write pseudo-class mu
st match input elements to which the readonly attribute applies, and that are mu
table"); |
| 35 |
| 36 testSelector("#set1 :read-only", ["input2"], "The :read-only pseudo-class must
not match input elements to which the readonly attribute applies, and that are
mutable"); |
| 37 |
| 38 document.getElementById("input1").setAttribute("readonly", "readonly"); |
| 39 testSelector("#set1 :read-write", [], "The :read-write pseudo-class must not m
atch input elements after the readonly attribute has been added"); |
| 40 |
| 41 testSelector("#set1 :read-only", ["input1", "input2"], "The :read-only pseudo-
class must match input elements after the readonly attribute has been added"); |
| 42 |
| 43 document.getElementById("input1").removeAttribute("readonly"); |
| 44 testSelector("#set1 :read-write", ["input1"], "The :read-write pseudo-class mu
st not match input elements after the readonly attribute has been removed"); |
| 45 |
| 46 testSelector("#set1 :read-only", ["input2"], "The :read-only pseudo-class must
match input elements after the readonly attribute has been removed"); |
| 47 |
| 48 testSelector("#set2 :read-write", ["textarea1"], "The :read-write pseudo-class
must match textarea elements that do not have a readonly attribute, and that ar
e not disabled"); |
| 49 |
| 50 testSelector("#set2 :read-only", ["textarea2"], "The :read-only pseudo-class m
ust match textarea elements that have a readonly attribute, or that are disabled
"); |
| 51 |
| 52 document.getElementById("textarea1").setAttribute("readonly", "readonly"); |
| 53 testSelector("#set2 :read-write", [], "The :read-write pseudo-class must match
textarea elements after the readonly attribute has been added"); |
| 54 |
| 55 testSelector("#set2 :read-only", ["textarea1", "textarea2"], "The :read-only p
seudo-class must match textarea elements after the readonly attribute has been a
dded"); |
| 56 |
| 57 testSelector("#set3 :read-write", ["textarea3"], "The :read-write pseudo-class
must not match textarea elements that are disabled"); |
| 58 |
| 59 testSelector("#set3 :read-only", ["textarea4"], "The :read-only pseudo-class m
ust match textarea elements that are disabled"); |
| 60 |
| 61 testSelector("#set4 :read-write", ["p2"], "The :read-write pseudo-class must m
atch elements that are editable"); |
| 62 |
| 63 testSelector("#set4 :read-only", ["p1"], "The :read-only pseudo-class must not
match elements that are editable"); |
| 64 |
| 65 document.designMode = "on"; |
| 66 |
| 67 testSelector("#set4 :read-write", ["p1", "p2"], "The :read-write pseudo-class
must match elements that are editing hosts"); |
| 68 |
| 69 testSelector("#set4 :read-only", [], "The :read-only pseudo-class must not mat
ch elements that are editing hosts"); |
| 70 |
| 71 </script> |
OLD | NEW |