OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/js-test.js"></script> | 2 <script src="../../../resources/js-test.js"></script> |
3 <style> | 3 <style> |
4 input { background-color: transparent } | 4 input { background-color: transparent } |
5 #inputValid:valid, | 5 #inputValid:valid, |
6 #inputInvalid:invalid, | 6 #inputInvalid:invalid, |
7 #formValid:valid, | 7 #formValid:valid, |
8 #formInvalid:invalid { | 8 #formInvalid:invalid, |
| 9 #maxlengthInvalid:invalid, |
| 10 #minlengthInvalid:invalid { |
9 background-color: green | 11 background-color: green |
10 } | 12 } |
11 | 13 |
12 form + div, | 14 form + div, |
13 input + div { | 15 input + div { |
14 color: pink | 16 color: pink |
15 } | 17 } |
16 </style> | 18 </style> |
17 <input id="inputValid" required></input> | 19 <input id="inputValid" required></input> |
18 <div> | 20 <div> |
(...skipping 16 matching lines...) Expand all Loading... |
35 </div> | 37 </div> |
36 <form id="formInvalid"> | 38 <form id="formInvalid"> |
37 <input id="inputInFormInvalid" type="text"></input> | 39 <input id="inputInFormInvalid" type="text"></input> |
38 <input type="text"></input> | 40 <input type="text"></input> |
39 <input type="text"></input> | 41 <input type="text"></input> |
40 </form> | 42 </form> |
41 <div> | 43 <div> |
42 <div></div> | 44 <div></div> |
43 <div></div> | 45 <div></div> |
44 </div> | 46 </div> |
| 47 <input id="maxlengthInvalid" type="text"></input> |
| 48 <div> |
| 49 <div></div> |
| 50 <div></div> |
| 51 </div> |
| 52 <input id="minlengthInvalid" type="text"></input> |
| 53 <div> |
| 54 <div></div> |
| 55 <div></div> |
| 56 </div> |
45 | 57 |
46 <script> | 58 <script> |
47 description("Use descendant invalidation sets for :valid and :invalid pseudo cla
sses.") | 59 description("Use descendant invalidation sets for :valid and :invalid pseudo cla
sses.") |
48 | 60 |
49 var transparent = "rgba(0, 0, 0, 0)"; | 61 var transparent = "rgba(0, 0, 0, 0)"; |
50 var green = "rgb(0, 128, 0)"; | 62 var green = "rgb(0, 128, 0)"; |
51 | 63 |
52 shouldBe("getComputedStyle(inputValid, '').backgroundColor", "transparent"); | 64 shouldBe("getComputedStyle(inputValid, '').backgroundColor", "transparent"); |
53 document.body.offsetTop; // Force recalc. | 65 document.body.offsetTop; // Force recalc. |
54 inputValid.removeAttribute("required"); | 66 inputValid.removeAttribute("required"); |
(...skipping 15 matching lines...) Expand all Loading... |
70 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); | 82 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); |
71 shouldBe("getComputedStyle(formValid, '').backgroundColor", "green"); | 83 shouldBe("getComputedStyle(formValid, '').backgroundColor", "green"); |
72 | 84 |
73 shouldBe("getComputedStyle(formInvalid, '').backgroundColor", "transparent"); | 85 shouldBe("getComputedStyle(formInvalid, '').backgroundColor", "transparent"); |
74 document.body.offsetTop; // Force recalc. | 86 document.body.offsetTop; // Force recalc. |
75 inputInFormInvalid.setAttribute("required", ""); | 87 inputInFormInvalid.setAttribute("required", ""); |
76 if (window.internals) | 88 if (window.internals) |
77 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); | 89 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2"); |
78 shouldBe("getComputedStyle(formInvalid, '').backgroundColor", "green"); | 90 shouldBe("getComputedStyle(formInvalid, '').backgroundColor", "green"); |
79 | 91 |
| 92 // Make sure the value is user input, otherwise setting maxlength/minlength |
| 93 // won't cause a validation. |
| 94 if (window.eventSender) { |
| 95 maxlengthInvalid.focus(); |
| 96 eventSender.keyDown("x"); |
| 97 eventSender.keyDown("x"); |
| 98 minlengthInvalid.focus(); |
| 99 eventSender.keyDown("x"); |
| 100 } |
| 101 |
| 102 shouldBe("getComputedStyle(maxlengthInvalid, '').backgroundColor", "transparent"
); |
| 103 document.body.offsetTop; // Force recalc. |
| 104 maxlengthInvalid.setAttribute("maxlength", "1"); |
| 105 if (window.internals) |
| 106 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1"); |
| 107 shouldBe("getComputedStyle(maxlengthInvalid, '').backgroundColor", "green"); |
| 108 |
| 109 shouldBe("getComputedStyle(minlengthInvalid, '').backgroundColor", "transparent"
); |
| 110 document.body.offsetTop; // Force recalc. |
| 111 minlengthInvalid.setAttribute("minlength", "2"); |
| 112 if (window.internals) |
| 113 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "1"); |
| 114 shouldBe("getComputedStyle(minlengthInvalid, '').backgroundColor", "green"); |
80 </script> | 115 </script> |
OLD | NEW |