| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> |
| 5 <style> |
| 6 :focus { background: rgb(0, 255, 0); } |
| 7 :not(:focus) { background: rgb(255, 0, 0); } |
| 8 </style> |
| 9 </head> |
| 10 <body> |
| 11 <p id="description"></p> |
| 12 <form method="get"> |
| 13 <input id="input-empty" name="victim" type="text" required/> |
| 14 <input id="input-pattern-mismatch" name="victim" type="text" pattern="Lorem ipsu
m" value="Loremipsum"/> |
| 15 <textarea id="textarea" name="victim" required></textarea> |
| 16 <select id="select-no-explicit-value" required> |
| 17 <option>empty</option> |
| 18 <option>another</option> |
| 19 </select> |
| 20 <select id="select-placeholder" name="victim" required> |
| 21 <option value="" selected /> |
| 22 <option value="X">X</option> |
| 23 </select> |
| 24 <select id="select-non-placeholder" name="victim" required> |
| 25 <option value="X">X</option> |
| 26 <option value="" selected /> |
| 27 </select> |
| 28 </form> |
| 29 <div id="console"></div> |
| 30 <script> |
| 31 function reportValidityFor(id) { |
| 32 return document.getElementById(id).reportValidity(); |
| 33 } |
| 34 function backgroundOf(id) { |
| 35 return document.defaultView.getComputedStyle(document.getElementById(id)
, null).getPropertyValue('background-color'); |
| 36 } |
| 37 var unfocusedColor = 'rgb(255, 0, 0)'; |
| 38 var focusedColor = 'rgb(0, 255, 0)'; |
| 39 |
| 40 description("This test checks if reportValidity() returns correctly a false
(meaning error) result on invalid elements, and returns a true result on a blank
but valid elements. Blank but non-placeholder label options are valid."); |
| 41 |
| 42 shouldBeFalse('reportValidityFor("input-empty")'); |
| 43 shouldBe('backgroundOf("input-empty")', 'focusedColor'); |
| 44 shouldBeFalse('reportValidityFor("input-pattern-mismatch")'); |
| 45 shouldBe('backgroundOf("input-pattern-mismatch")', 'focusedColor'); |
| 46 shouldBeFalse('reportValidityFor("textarea")'); |
| 47 shouldBe('backgroundOf("textarea")', 'focusedColor'); |
| 48 shouldBeTrue('reportValidityFor("select-no-explicit-value")'); |
| 49 shouldBe('backgroundOf("select-no-explicit-value")', 'unfocusedColor'); |
| 50 shouldBeFalse('reportValidityFor("select-placeholder")'); |
| 51 shouldBe('backgroundOf("select-placeholder")', 'focusedColor'); |
| 52 shouldBeTrue('reportValidityFor("select-non-placeholder")'); |
| 53 shouldBe('backgroundOf("select-non-placeholder")', 'unfocusedColor'); |
| 54 </script> |
| 55 </body> |
| 56 </html> |
| OLD | NEW |