Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/fast/forms/ValidityState-valueMissing.html |
| diff --git a/third_party/WebKit/LayoutTests/fast/forms/ValidityState-valueMissing.html b/third_party/WebKit/LayoutTests/fast/forms/ValidityState-valueMissing.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b5df8eca0f383ac02332e6e09496497e7327950e |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/fast/forms/ValidityState-valueMissing.html |
| @@ -0,0 +1,358 @@ |
| +<!DOCTYPE html> |
| +<body> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| + |
| +<input id="input-empty" name="victim" required/> |
| +<input id="input-nonempty" name="victim" value="something" required/> |
| +<textarea id="textarea-empty" name="victim" required></textarea> |
| +<textarea id="textarea-nonempty" name="victim" required>something</textarea> |
| +<select id="select-no-option" name="victim" required> |
| +</select> |
| +<select id="select-placeholder-selected" name="victim" required> |
| + <option value="" selected /> |
| + <option value="X">X</option> |
| +</select> |
| +<select id="select-without-placeholder" name="victim" required> |
| + <option value="X">X</option> |
| + <option value="" selected /> |
| +</select> |
| +<select id="select-placeholder-selected-size2" name="victim" size="2" required> |
| + <option value="" selected /> |
| + <option value="X">X</option> |
| +</select> |
| +<select id="select-without-placeholder-size2" name="victim" size="2" required> |
| + <option value="X">X</option> |
| + <option value="" selected /> |
| +</select> |
| +<select id="select-none-selected-multiple" name="victim" multiple required> |
| + <option value="" /> |
| + <option value="X">X</option> |
| +</select> |
| +<select id="select-fake-placeholder-selected-multiple" name="victim" multiple required> |
| + <option value="" selected /> |
| + <option value="X">X</option> |
| +</select> |
| +<select id="select-without-fake-placeholder-multiple" name="victim" multiple required> |
| + <option value="X">X</option> |
| + <option value="" selected /> |
| +</select> |
| +<select id="select-none-selected-size2-multiple" name="victim" multiple size="2" required> |
| + <option value="" /> |
| + <option value="X">X</option> |
| +</select> |
| +<select id="select-fake-placeholder-selected-size2-multiple" name="victim" multiple size="2" required> |
| + <option value="" selected /> |
| + <option value="X">X</option> |
| +</select> |
| +<select id="select-without-fake-placeholder-size2-multiple" name="victim" multiple size="2" required> |
| + <option value="X">X</option> |
| + <option value="" selected /> |
| +</select> |
| +<select id="select-optgroup" name="victim" required> |
| + <optgroup label="1"> |
| + <option value="" selected /> |
| + </optgroup> |
| + <option value="X">X</option> |
| +</select> |
| +<select id="select-disabled-option" name="victim" required> |
| + <option value="" disabled selected /> |
| + <option value="X">X</option> |
| +</select> |
| +<select id="select-disabled-option-2" name="victim" required> |
| + <option value="" disabled /> |
| + <option value="X">X</option> |
| +</select> |
| + |
| +<select id="select-with-placeholder" name="victim" required> |
| + <option value="" /> |
| + <option value="X" selected>X</option> |
| +</select> |
| +<select id="select-with-fake-placeholder-size2" name="victim" size="2" required> |
| + <option value="" /> |
| + <option value="X" selected>X</option> |
| +</select> |
| +<select id="select-without-fake-placeholder-size2" name="victim" size="2" required> |
| + <option value="X" selected>X</option> |
| + <option value="" /> |
| +</select> |
| +<select id="select-with-fake-placeholder-multiple" name="victim" multiple required> |
| + <option value="" /> |
| + <option value="X" selected>X</option> |
| +</select> |
| +<select id="select-without-fake-placeholder-multiple" name="victim" multiple required> |
| + <option value="X" selected>X</option> |
| + <option value="" /> |
| +</select> |
| +<select id="select-with-fake-placeholder-size2-multiple" name="victim" multiple size="2" required> |
| + <option value="" /> |
| + <option value="X" selected>X</option> |
| +</select> |
| +<select id="select-without-fake-placeholder-size2-multiple" name="victim" multiple size="2" required> |
| + <option value="X" selected>X</option> |
| + <option value="" /> |
| +</select> |
| +<select id="select-selecting-by-key" required> |
| + <option value="" selected/> |
| + <option>a</option> |
| +</select> |
| +<select id="select-selecting-by-key-2" required> |
| + <option value="" selected/> |
| + <option accesskey="1">a</option> |
| +</select> |
| + |
| +<input name="victim" disabled required /> |
| +<textarea name="victim" disabled required></textarea> |
| +<select name="victim" disabled required> |
| +</select> |
| +<select name="victim" disabled required> |
| + <option value="" selected /> |
| + <option value="X">X</option> |
| +</select> |
| +<select name="victim" disabled required> |
| + <option value="X">X</option> |
| + <option value="" selected /> |
| +</select> |
| +<select name="victim" size="2" disabled required> |
| + <option value="" selected /> |
| + <option value="X">X</option> |
| +</select> |
| +<select name="victim" size="2" disabled required> |
| + <option value="X">X</option> |
| + <option value="" selected /> |
| +</select> |
| +<select name="victim" multiple disabled required> |
| + <option value="" /> |
| + <option value="X">X</option> |
| +</select> |
| +<select name="victim" multiple disabled required> |
| + <option value="" selected /> |
| + <option value="X">X</option> |
| +</select> |
| +<select name="victim" multiple disabled required> |
| + <option value="X">X</option> |
| + <option value="" selected /> |
| +</select> |
| +<select name="victim" multiple size="2" disabled required> |
| + <option value="" /> |
| + <option value="X">X</option> |
| +</select> |
| +<select name="victim" multiple size="2" disabled required> |
| + <option value="" selected /> |
| + <option value="X">X</option> |
| +</select> |
| +<select name="victim" multiple size="2" disabled required> |
| + <option value="X">X</option> |
| + <option value="" selected /> |
| +</select> |
| + |
| +<input name="victim" readonly required /> |
| +<textarea name="victim" readonly required></textarea> |
| + |
| +<fieldset id="non-supported-container"> |
| +<input name="victim" type="hidden" required /> |
| +<input name="victim" type="range" required /> |
| +<input name="victim" type="image" required /> |
| +<input name="victim" type="reset" required /> |
| +<input name="victim" type="button" required /> |
| +<input name="victim" type="submit" required /> |
| +</fieldset> |
| + |
| +<input name="victim" type="checkbox" required checked /> |
| +<input name="victim" type="checkbox" required /> |
| + |
| +<input id="input-file" type="file" required /> |
| +<input id="input-text" type="text" required /> |
| +<input id="input-search" type="search" required /> |
| +<input id="input-url" type="url" required /> |
| +<input id="input-tel" type="tel" required /> |
| +<input id="input-email" type="email" required /> |
| +<input id="input-password" type="password" required /> |
| +<input id="input-number" type="number" required /> |
| + |
| +<script> |
| +function valueMissingFor(id) { |
| + return document.getElementById(id).validity.valueMissing; |
| +} |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('input-empty')); |
|
yosin_UTC9
2016/08/04 08:19:19
Since sample and verification is too far away, it
tkent
2016/08/04 23:08:26
That's a good idea. Done in Patch Set 2.
|
| +}, 'Empty-value INPUT[required] should be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('input-nonempty')); |
| +}, 'INPUT[required] with a non-empty value should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('textarea-empty')); |
| +}, 'Empty value TEXTAREA[required] should be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('textarea-nonempty')); |
| +}, 'TEXTAREA[required] with a non-empty value should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('select-no-option')); |
| +}, 'SELECT[required] with no OPTIONS should be valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('select-placeholder-selected')); |
| +}, 'SELECT[required] with a selected placeholder OPTION should be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-without-placeholder')); |
| +}, 'SELECT[required] with a selected non-placeholder OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-placeholder-selected-size2')); |
| +}, 'SELECT[required][size=2] with a selected placeholder OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-without-placeholder-size2')); |
| +}, 'SELECT[rquired][size=2] with a selected non-placeholder OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('select-none-selected-multiple')); |
| +}, 'SELECT[required][multiple] without selected OPTIONs should be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-fake-placeholder-selected-multiple')); |
| +}, 'SELECT[required][multiple] with a selected placeholder-like OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-without-fake-placeholder-multiple')); |
| +}, 'SELECT[required][multiple] with a selected OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('select-none-selected-size2-multiple')); |
| +}, 'SELECT[required][multiple][size=2] without selected OPTIONs should be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-fake-placeholder-selected-size2-multiple')); |
| +}, 'SELECT[required][multiple][size=2] with a selected placeholder-liek OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-without-fake-placeholder-size2-multiple')); |
| +}, 'SELECT[required][multiple][size=2] with a selected OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-optgroup')); |
| +}, 'SELECT[required] with a selected placeholder-like OPTION inside an OPTGROUP should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('select-disabled-option')); |
| +}, 'SELECT[required] with a selected disabled placeholder OPTION should be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-disabled-option-2')); |
| + assert_equals(document.getElementById('select-disabled-option-2').selectedIndex, 1); |
| +}, 'SELECT[required] with a non-selected disabled placeholder OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-with-placeholder')); |
| +}, 'SELECT[required] with a unselected placeholder OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-with-fake-placeholder-size2')); |
| +}, 'SELECT[required][size=2] with a unselected placeholder OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-without-fake-placeholder-size2')); |
| +}, 'SELECT[required][size=2] with a unselected placeholder-like OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-with-fake-placeholder-multiple')); |
| +}, 'SELECT[required][multiple] with a unselected placeholder OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_false(valueMissingFor('select-without-fake-placeholder-multiple')); |
| +}, 'SELECT[required][multiple] with a unselected placeholder-like OPTION should not be valueMissing.'); |
| +test(() => { |
| + assert_false(valueMissingFor('select-with-fake-placeholder-size2-multiple')); |
| +}, 'SELECT[required][size=2][multiple] with a unselected placeholder OPTION should not be valueMissing.'); |
| +test(() => { |
| + assert_false(valueMissingFor('select-without-fake-placeholder-size2-multiple')); |
| +}, 'SELECT[required][size=2][multiple] with a unselected placeholder-like OPTION should not be valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(!!window.eventSender, 'Needs eventSender.'); |
| + // Select by type-ahead. |
| + var select = document.getElementById('select-selecting-by-key'); |
| + assert_true(valueMissingFor('select-selecting-by-key')); |
| + select.focus(); |
| + eventSender.keyDown('a'); |
| + assert_equals(select.value, 'a'); |
| + assert_false(valueMissingFor('select-selecting-by-key')); |
| + |
| + // Select by accesskey. |
| + select = document.getElementById('select-selecting-by-key-2'); |
| + assert_true(valueMissingFor('select-selecting-by-key-2')); |
| + select.focus(); |
| + eventSender.keyDown('1', 'accessKey'); |
| + assert_equals(select.value, 'a'); |
| + assert_false(valueMissingFor('select-selecting-by-key-2')); |
| +}, 'Updating valueMissing state by user input.'); |
| + |
| +test(() => { |
| + var controls = document.querySelectorAll(':disabled'); |
| + for (c in controls) { |
| + if (c.validity) |
| + assert_false(c.validity.valueMissing); |
| + } |
| +}, 'Disabled controls never be valueMissing.'); |
| + |
| +test(() => { |
| + var controls = document.querySelectorAll('[readonly]'); |
| + for (c in controls) { |
| + if (c.validity) |
| + assert_false(c.validity.valueMissing); |
| + } |
| +}, 'Read-only controls never be valueMissing.'); |
| + |
| +test(() => { |
| + var fieldset = document.querySelector('#non-supported-container'); |
| + for (c in fieldset.elements) { |
| + if (c.validity) |
| + assert_false(c.validity.valueMissing); |
| + } |
| +}, 'INPUT elements of some types never be valueMissing.'); |
| + |
| +test(() => { |
| + var controls = document.querySelectorAll('input[type=checkbox]'); |
| + assert_false(controls[0].validity.valueMissing); |
| + assert_true(controls[1].validity.valueMissing); |
| +}, 'INPUT[type=checkbox] supports valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('input-file')); |
| +}, 'INPUT[type=file] supports valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('input-text')); |
| +}, 'INPUT[type=text] supports valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('input-search')); |
| +}, 'INPUT[type=search] supports valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('input-url')); |
| +}, 'INPUT[type=url] supports valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('input-tel')); |
| +}, 'INPUT[type=tel] supports valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('input-email')); |
| +}, 'INPUT[type=email] supports valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('input-password')); |
| +}, 'INPUT[type=password] supports valueMissing.'); |
| + |
| +test(() => { |
| + assert_true(valueMissingFor('input-number')); |
| +}, 'INPUT[type=number] supports valueMissing.'); |
| +</script> |
| +</body> |