Update web-platform-tests and CSS tests.

- Update CSS tests to revision e05bfd5e30ed662c2f8a353577003f8eed230180.
- Update web-platform-tests to revision a052787dd5c069a340031011196b73affbd68cd9.
This commit is contained in:
Ms2ger 2017-02-06 11:06:12 +01:00
parent fb4f421c8b
commit 296fa2512b
21852 changed files with 2080936 additions and 892894 deletions

View file

@ -62,7 +62,8 @@
testData: [
{conditions: {max: "2000-01", value: "2001-01"}, expected: false, name: "[target] validity.valid must be false if validity.rangeOverflow is true"},
{conditions: {min: "2001-01", value: "2000-01"}, expected: false, name: "[target] validity.valid must be false if validity.rangeUnderflow is true"},
{conditions: {step: 2 * 1 * 1, value: "2001-03"}, expected: false, name: "[target] validity.valid must be false if validity.stepMismatch is true"},
// Step checks that "months since Jan 1970" is evenly divisible by `step`
{conditions: {step: 3, value: "2001-02"}, expected: false, name: "[target] validity.valid must be false if validity.stepMismatch is true"},
{conditions: {required: true, value: ""}, expected: false, name: "[target] validity.valid must be false if validity.valueMissing is true"}
]
},

View file

@ -22,16 +22,16 @@
types: ["button", "reset"],
testData: [{conditions: {}, expected: false, name: "[target] Must be barred from the constraint validation"}]
},
//FIELDSET, OUTPUT elements should not be barred from the constraint validation
// FIELDSET and OUTPUT elements are not "submittable elements" and therefore never validate.
{
tag: "fieldset",
types: [],
testData: [{conditions: {}, expected: true, name: "[target] Must not be barred from the constraint validation"}]
testData: [{conditions: {}, expected: false, name: "[target] The willValidate attribute must be false since FIELDSET is not a submittable element"}]
},
{
tag: "output",
types: [],
testData: [{conditions: {}, expected: true, name: "[target] Must not be barred from the constraint validation"}]
testData: [{conditions: {}, expected: false, name: "[target] The willValidate attribute must be false since OUTPUT is not a submittable element"}]
},
//OBJECT, KEYGEN, elements must be barred from the constraint validation
{
@ -39,11 +39,6 @@
types: [],
testData: [{conditions: {}, expected: false, name: "[target] Must be barred from the constraint validation"}]
},
{
tag: "keygen",
types: [],
testData: [{conditions: {}, expected: false, name: "[target] Must be barred from the constraint validation"}]
},
//If an element is disabled, it is barred from constraint validation.
//The willValidate attribute must be true if an element is mutable
//If the readonly attribute is specified on an INPUT element, the element is barred from constraint validation.

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>input[type="email"], ValidityState.tooShort and user editing</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#setting-minimum-input-length-requirements:-the-minlength-attribute">
<meta name="flags" content="interact">
<meta name="assert" content="Per the 'Constraint validation' definition in the referenced section, an input whose value was edited by the user but still falls below the input's minlength should suffer from being too short.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<p>Type one additional character into the following text input:</p>
<input type="email" value="jane.doe@example.com" minlength="25" autocomplete="off" id="testinput">
<div id="log"></div>
<script>
var input = document.getElementById('testinput');
setup({explicit_timeout: true, explicit_done: true});
on_event(input, "input", function () {
test(function() {
assert_class_string(input.validity, 'ValidityState', 'HTMLInputElement.validity must be a ValidityState instance');
assert_true(input.validity.tooShort, "tooShort must be true since the user just changed the input's value and the value falls below the minlength");
});
done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>input[type="password"], ValidityState.tooShort and user editing</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#setting-minimum-input-length-requirements:-the-minlength-attribute">
<meta name="flags" content="interact">
<meta name="assert" content="Per the 'Constraint validation' definition in the referenced section, an input whose value was edited by the user but still falls below the input's minlength should suffer from being too short.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<p>Type one additional character into the following text input:</p>
<input type="password" value="swordfish" minlength="15" autocomplete="off" id="testinput">
<div id="log"></div>
<script>
var input = document.getElementById('testinput');
setup({explicit_timeout: true, explicit_done: true});
on_event(input, "input", function () {
test(function() {
assert_class_string(input.validity, 'ValidityState', 'HTMLInputElement.validity must be a ValidityState instance');
assert_true(input.validity.tooShort, "tooShort must be true since the user just changed the input's value and the value falls below the minlength");
});
done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>input[type="search"], ValidityState.tooShort and user editing</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#setting-minimum-input-length-requirements:-the-minlength-attribute">
<meta name="flags" content="interact">
<meta name="assert" content="Per the 'Constraint validation' definition in the referenced section, an input whose value was edited by the user but still falls below the input's minlength should suffer from being too short.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<p>Type one additional character into the following text input:</p>
<input type="search" value="abcdefghi" minlength="15" autocomplete="off" id="testinput">
<div id="log"></div>
<script>
var input = document.getElementById('testinput');
setup({explicit_timeout: true, explicit_done: true});
on_event(input, "input", function () {
test(function() {
assert_class_string(input.validity, 'ValidityState', 'HTMLInputElement.validity must be a ValidityState instance');
assert_true(input.validity.tooShort, "tooShort must be true since the user just changed the input's value and the value falls below the minlength");
});
done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>input[type="tel"], ValidityState.tooShort and user editing</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#setting-minimum-input-length-requirements:-the-minlength-attribute">
<meta name="flags" content="interact">
<meta name="assert" content="Per the 'Constraint validation' definition in the referenced section, an input whose value was edited by the user but still falls below the input's minlength should suffer from being too short.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<p>Type one additional character into the following text input:</p>
<input type="tel" value="123-456-7890" minlength="20" autocomplete="off" id="testinput">
<div id="log"></div>
<script>
var input = document.getElementById('testinput');
setup({explicit_timeout: true, explicit_done: true});
on_event(input, "input", function () {
test(function() {
assert_class_string(input.validity, 'ValidityState', 'HTMLInputElement.validity must be a ValidityState instance');
assert_true(input.validity.tooShort, "tooShort must be true since the user just changed the input's value and the value falls below the minlength");
});
done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>input[type="text"], ValidityState.tooShort and user editing</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#setting-minimum-input-length-requirements:-the-minlength-attribute">
<meta name="flags" content="interact">
<meta name="assert" content="Per the 'Constraint validation' definition in the referenced section, an input whose value was edited by the user but still falls below the input's minlength should suffer from being too short.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<p>Type one additional character into the following text input:</p>
<input type="text" value="1234" minlength="10" autocomplete="off" id="testinput">
<div id="log"></div>
<script>
var input = document.getElementById('testinput');
setup({explicit_timeout: true, explicit_done: true});
on_event(input, "input", function () {
test(function() {
assert_class_string(input.validity, 'ValidityState', 'HTMLInputElement.validity must be a ValidityState instance');
assert_true(input.validity.tooShort, "tooShort must be true since the user just changed the input's value and the value falls below the minlength");
});
done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>input[type="url"], ValidityState.tooShort and user editing</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#setting-minimum-input-length-requirements:-the-minlength-attribute">
<meta name="flags" content="interact">
<meta name="assert" content="Per the 'Constraint validation' definition in the referenced section, an input whose value was edited by the user but still falls below the input's minlength should suffer from being too short.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<p>Type one additional character into the following text input:</p>
<input type="url" value="http://example.com" minlength="25" autocomplete="off" id="testinput">
<div id="log"></div>
<script>
var input = document.getElementById('testinput');
setup({explicit_timeout: true, explicit_done: true});
on_event(input, "input", function () {
test(function() {
assert_class_string(input.validity, 'ValidityState', 'HTMLInputElement.validity must be a ValidityState instance');
assert_true(input.validity.tooShort, "tooShort must be true since the user just changed the input's value and the value falls below the minlength");
});
done();
});
</script>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>textarea, ValidityState.tooShort and user editing</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#setting-minimum-input-length-requirements:-the-minlength-attribute">
<meta name="flags" content="interact">
<meta name="assert" content="Per the 'Constraint validation' definition in the referenced section, a textarea whose value was edited by the user but still falls below the textarea's minlength should suffer from being too short.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<p>Type one additional character into the following text area:</p>
<textarea minlength="15" autocomplete="off" id="testinput">123456789</textarea>
<div id="log"></div>
<script>
var input = document.getElementById('testinput');
setup({explicit_timeout: true, explicit_done: true});
on_event(input, "input", function () {
test(function() {
assert_class_string(input.validity, 'ValidityState', 'HTMLTextAreaElement.validity must be a ValidityState instance');
assert_true(input.validity.tooShort, "tooShort must be true since the user just changed the input's value and the value falls below the minlength");
});
done();
});
</script>
</body>
</html>

View file

@ -9,7 +9,6 @@
<p><button id="button">button</button>
<p><fieldset id="fieldset">fieldset</fieldset>
<p><input id="input">
<p><keygen id="keygen">
<p><object id="object">object</object>
<p><output id="output">output</output>
<p><select id="select"><option>select</option></select>
@ -21,8 +20,6 @@
<p><label id="label-form-form2" form="form2">label-form-form2</label>
<p><label id="label-with-control">label-with-control <input></label>
<p><label id="label-for" for="control-for-label">label-for</label> <input id="control-for-label">
<p><label id="label-with-progress">label-with-progress <progress></progress></label>
<p><label id="label-with-meter">label-with-meter <meter></meter></label>
<p>
<input id="input-with-form-attr-in-form" form="form2">
<label id="label-for-control-form-in-form" for="input-with-form-attr-in-form">label-for-control-form-in-form</label>
@ -59,7 +56,6 @@ var listedElements = [
"button",
"fieldset",
"input",
"keygen",
"object",
"output",
"select",
@ -87,8 +83,6 @@ testLabel("label-form", null);
testLabel("label-form-form2", null);
testLabel("label-with-control", form);
testLabel("label-for", form);
testLabel("label-with-progress", null);
testLabel("label-with-meter", null);
testLabel("label-for-control-form-in-form", form2);
testLabel("label-for-control-form", form2);
testLabel("label-in-table", null);

View file

@ -15,6 +15,11 @@ var simple_tests = [
input: "<textarea name=foo>bar</textarea>",
output: "foo=bar"
},
{
name: "nokeygen.simple",
input: "<input name=foo value=barb><keygen>",
output: "foo=barb"
}
];
simple_tests.forEach(function(test_obj) {
test_obj.test = async_test(test_obj.name);

View file

@ -0,0 +1,3 @@
<!DOCTYPE html>
<form></form>

View file

@ -0,0 +1,38 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>reset() event firing realm</title>
<link rel="help" href="https://html.spec.whatwg.org/#resetting-a-form">
<link rel="help" href="https://dom.spec.whatwg.org/#concept-event-fire">
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe src="reset-form-event-realm-support.html"></iframe>
<iframe></iframe>
<script>
"use strict";
async_test(t => {
window.onload = t.step_func_done(() => {
const frame0Form = frames[0].document.forms[0];
const frame1Body = frames[1].document.body;
frame1Body.appendChild(frame0Form);
let resetCalled = false;
frame0Form.onreset = t.step_func(ev => {
resetCalled = true;
const functionConstructorInEvRealm = ev.constructor.constructor;
const functionConstructorInFormRealm = frame0Form.constructor.constructor;
assert_equals(functionConstructorInEvRealm, functionConstructorInFormRealm,
"the event must be created in the realm of the target");
});
frame0Form.reset();
assert_true(resetCalled, "The reset event handler must have been called");
});
}, "reset()'s event must be fired in the Realm of the target")
</script>

View file

@ -15,7 +15,6 @@
<input type="checkbox" id="cb1" checked="checked" />
<input type="checkbox" id="cb2" />
<textarea id="ta">abc</textarea>
<!--<keygen id="kg"></keygen>-->
<output id="opt">5</output>
<select id="slt1">
<option value="1">ITEM1</option>
@ -114,7 +113,6 @@ function runTest(reset, description) {
assert_true(document.getElementById("slt3").options[1].selected, "The second option in the select element with multiple attribute should be selected.");
assert_true(document.getElementById("slt3").options[2].selected, "The third option in the select element with multiple attribute should be selected.");
}, "Resetting <select> " + description);
//TODO: The keygen reset algorithm
}
</script>

View file

@ -9,12 +9,21 @@
<script>
test(function() {
var el = document.createElement("textarea");
assert_equals(el.selectionStart, 0);
assert_equals(el.selectionEnd, 0);
assert_equals(el.selectionStart, 0, "initial selectionStart");
assert_equals(el.selectionEnd, 0, "initial selectionEnd");
assert_equals(el.selectionDirection, "none", "initial selectionDirection");
el.selectionStart = 1;
el.selectionEnd = 1;
el.selectionDirection = "forward";
assert_equals(el.selectionStart, 1, "updated selectionStart");
assert_equals(el.selectionEnd, 1, "updated selectionEnd");
assert_equals(el.selectionDirection, "forward", "updated selectionDirection");
el.setRangeText("foobar");
el.setSelectionRange(0, 1);
assert_equals(el.selectionStart, 0, "final selectionStart");
assert_equals(el.selectionEnd, 1, "final selectionEnd");
assert_equals(el.selectionDirection, "forward", "final selectionDirection");
}, "text field selection for the input textarea");
</script>

View file

@ -110,7 +110,7 @@
element.onselect = this.step_func_done(function(e) {
assert_true(q, "event should be queued");
assert_true(e.isTrusted, "event is trusted");
assert_false(e.bubbles, "event bubbles");
assert_true(e.bubbles, "event bubbles");
assert_false(e.cancelable, "event is not cancelable");
});
element.setRangeText("foobar2", 0, 6);

View file

@ -41,7 +41,7 @@ test(function() {
input.setSelectionRange(input.value.length+1,1)
assert_equals(input.selectionStart, 1, "If end is less than or equal to start then the start of the selection and the end of the selection must both be placed immediately before the character with offset end");
assert_equals(input.selectionEnd, 1, "element.selectionEnd should be 1");
},'input setSelectionRange(input.value.length+1,input.value.length+1)');
},'input setSelectionRange(input.value.length+1,1)');
test(function() {
input.setSelectionRange(2,2)

View file

@ -52,20 +52,20 @@
assert_true(document.getElementById('fs2').disabled, "The fieldset is disabled");
assert_false(document.getElementById('clubname2').willValidate, "fieldset is disabled so is input 'clubname2'");
assert_false(document.getElementById('clubnum2').willValidate, "fieldset is disabled so is input 'clubnum2'");
assert_false(document.getElementById('club2').willValidate, "the first legend is not a child of the disbled fieldset: input 'club2' is disabled");
assert_false(document.getElementById('club2').willValidate, "the first legend is not a child of the disabled fieldset: input 'club2' is disabled");
}, "The first 'legend' element is not a child of the disabled fieldset: Its descendants should be disabled.");
test(function () {
assert_true(document.getElementById('fs3').disabled, "The fieldset is disabled");
assert_false(document.getElementById('clubname3').willValidate, "fieldset is disabled so is input 'clubname3'");
assert_false(document.getElementById('clubnum3').willValidate, "fieldset is disabled so is input 'clubnum3'");
assert_false(document.getElementById('club3').willValidate, "the first legend is not a child of the disbled fieldset: input 'club3' is disabled");
assert_false(document.getElementById('club3').willValidate, "the first legend is not a child of the disabled fieldset: input 'club3' is disabled");
}, "The <legend> element is not a child of the disabled fieldset: Its descendants should be disabled.");
test(function () {
assert_true(document.getElementById('fs4').disabled, "The fieldset is disabled");
assert_false(document.getElementById('clubname4').willValidate, "fieldset is disabled so is input 'clubname4'");
assert_false(document.getElementById('clubnum4').willValidate, "fieldset is disabled so is input 'clubnum4'");
assert_true(document.getElementById('club4').willValidate, "the first legend a child of the disbled fieldset: input 'club4' is disabled");
assert_true(document.getElementById('club4').willValidate, "the first legend a child of the disabled fieldset: input 'club4' is disabled");
}, "The <legend> element is child of the disabled fieldset: Its descendants should be disabled.");
</script>

View file

@ -5,7 +5,6 @@
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<!-- XXX Nothing tests id attributes yet. -->
<!-- XXX Keygen. -->
<!-- XXX We also need tests for moving inputs and forms in the DOM. -->
<form>
<input type=button name=button>
@ -327,4 +326,93 @@ test(function() {
assert_equals(form["new-name2"], 5);
}, 'Trying to set a non-configurable expando that shadows a named property that gets added later');
test(function() {
var form = document.getElementsByTagName("form")[1];
var i1 = document.createElement("input");
i1.name = "past-name1";
i1.id = "past-id1"
assert_equals(form["past-name1"], undefined);
assert_equals(form["past-id1"], undefined);
form.appendChild(i1);
assert_equals(form["past-name1"], i1);
assert_equals(form["past-id1"], i1);
i1.name = "twiddled-name1";
i1.id = "twiddled-id1";
assert_equals(form["past-name1"], i1);
assert_equals(form["twiddled-name1"], i1);
assert_equals(form["past-id1"], i1);
assert_equals(form["twiddled-id1"], i1);
i1.name = "twiddled-name2";
i1.id = "twiddled-id2";
assert_equals(form["past-name1"], i1);
assert_equals(form["twiddled-name1"], i1);
assert_equals(form["twiddled-name2"], i1);
assert_equals(form["past-id1"], i1);
assert_equals(form["twiddled-id1"], i1);
assert_equals(form["twiddled-id2"], i1);
i1.removeAttribute("id");
i1.removeAttribute("name");
assert_equals(form["past-name1"], i1);
assert_equals(form["twiddled-name1"], i1);
assert_equals(form["twiddled-name2"], i1);
assert_equals(form["past-id1"], i1);
assert_equals(form["twiddled-id1"], i1);
assert_equals(form["twiddled-id2"], i1);
i1.remove();
assert_equals(form["past-name1"], undefined);
assert_equals(form["twiddled-name1"], undefined);
assert_equals(form["twiddled-name2"], undefined);
assert_equals(form["past-id1"], undefined);
assert_equals(form["twiddled-id1"], undefined);
assert_equals(form["twiddled-id2"], undefined);
var i2 = document.createElement("input");
i2.name = "past-name2";
i2.id = "past-id2";
assert_equals(form["past-name2"], undefined);
assert_equals(form["past-id2"], undefined);
form.appendChild(i2);
assert_equals(form["past-name2"], i2);
assert_equals(form["past-id2"], i2);
i2.name = "twiddled-name3";
i2.id = "twiddled-id3";
assert_equals(form["past-name2"], i2);
assert_equals(form["twiddled-name3"], i2);
assert_equals(form["past-id2"], i2);
assert_equals(form["twiddled-id3"], i2);
i2.name = "twiddled-name4";
i2.id = "twiddled-id4";
assert_equals(form["past-name2"], i2);
assert_equals(form["twiddled-name3"], i2);
assert_equals(form["twiddled-name4"], i2);
assert_equals(form["past-id2"], i2);
assert_equals(form["twiddled-id3"], i2);
assert_equals(form["twiddled-id4"], i2);
i2.removeAttribute("id");
i2.removeAttribute("name");
assert_equals(form["past-name2"], i2);
assert_equals(form["twiddled-name3"], i2);
assert_equals(form["twiddled-name4"], i2);
assert_equals(form["past-id2"], i2);
assert_equals(form["twiddled-id3"], i2);
assert_equals(form["twiddled-id4"], i2);
i2.setAttribute("form", "c");
assert_equals(form["past-name2"], undefined);
assert_equals(form["twiddled-name3"], undefined);
assert_equals(form["twiddled-name4"], undefined);
assert_equals(form["past-id2"], undefined);
assert_equals(form["twiddled-id3"], undefined);
assert_equals(form["twiddled-id4"], undefined);
}, "Past names map should work correctly");
</script>

View file

@ -0,0 +1,150 @@
<!doctype html>
<meta charset=utf-8>
<title>Test input value retention upon clone</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<style>form {display: none;} </style>
<form>
<p><input type=checkbox> This checkbox is initially unchecked.</p>
<p><input type=checkbox checked="checked"> This checkbox is initially checked.</p>
<p><input type=radio name=radio> This radiobutton is initially unchecked.</p>
<p><input type=radio checked="checked" name=radio> This radiobutton is initially checked.</p>
<p><input type=hidden value="DEFAULT
DEFAULT"> This hidden field has the initial value "DEFAULT\nDEFAULT".</p>
<p><input type=text value=DEFAULT> This text field has the initial value "DEFAULT".</p>
<p><input type=search value=DEFAULT> This search field has the initial value "DEFAULT".</p>
<p><input type=tel value=DEFAULT> This phone number field has the initial value "DEFAULT".</p>
<p><input type=url value=https://default.invalid/> This URL field has the initial value "https://default.invalid/".</p>
<p><input type=email value=default@default.invalid> This email field has the initial value "default@default.invalid".</p>
<p><input type=password value=DEFAULT> This password field has the initial value "DEFAULT".</p>
<p><input type=date value=2015-01-01> This date field has the initial value "2015-01-01".</p>
<p><input type=month value=2015-01> This month field has the initial value "2015-01".</p>
<p><input type=week value=2015-W01> This week field has the initial value "2015-W01".</p>
<p><input type=time value=12:00> This time field has the initial value "12:00".</p>
<p><input type=datetime-local value=2015-01-01T12:00> This datetime (local) field has the initial value "2015-01-01T12:00".</p>
<p><input type=number value=1> This number field has the initial value "1".</p>
<p><input type=range value=1> This range control has the initial value "1".</p>
<p><input type=color value=#ff0000> This color picker has the initial value "#FF0000".</p>
<p><input type="button" value="Clone" onclick="clone();"></p>
</form>
<script>
setup(function() {
let form = document.getElementsByTagName("form")[0];
let inputs = form.getElementsByTagName("input");
inputs[0].checked = true;
inputs[1].checked = false;
inputs[2].checked = true;
inputs[4].value = "CHANGED\nCHANGED";
inputs[5].value = "CHANGED";
inputs[6].value = "CHANGED";
inputs[7].value = "CHANGED";
inputs[8].value = "https://changed.invalid/";
inputs[9].value = "changed@changed.invalid";
inputs[10].value = "CHANGED";
inputs[11].value = "2016-01-01";
inputs[12].value = "2016-01";
inputs[13].value = "2016-W01";
inputs[14].value = "12:30";
inputs[15].value = "2016-01-01T12:30";
inputs[16].value = "2";
inputs[17].value = "2";
inputs[18].value = "#00ff00";
let clone = form.cloneNode(true);
document.body.appendChild(clone);
});
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_true(inputs[0].checked, "Should have retained checked state");
}, "Checkbox must retain checked state.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_false(inputs[1].checked, "Should have retained unchecked state");
}, "Checkbox must retain unchecked state.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_true(inputs[2].checked, "Should have retained checked state");
}, "Radiobutton must retain checked state.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_false(inputs[3].checked, "Should have retained unchecked state");
}, "Radiobutton must retain unchecked state.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[4].value, "CHANGED\nCHANGED", "Should have retained the changed value.");
}, "Hidden field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[5].value, "CHANGED", "Should have retained the changed value.");
}, "Text field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[6].value, "CHANGED", "Should have retained the changed value.");
}, "Search field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[7].value, "CHANGED", "Should have retained the changed value.");
}, "Phone number field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[8].value, "https://changed.invalid/", "Should have retained the changed value.");
}, "URL field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[9].value, "changed@changed.invalid", "Should have retained the changed value.");
}, "Email field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[10].value, "CHANGED", "Should have retained the changed value.");
}, "Password field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[11].value, "2016-01-01", "Should have retained the changed value.");
}, "Date field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[12].value, "2016-01", "Should have retained the changed value.");
}, "Month field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[13].value, "2016-W01", "Should have retained the changed value.");
}, "Week field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[14].value, "12:30", "Should have retained the changed value.");
}, "Time field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[15].value, "2016-01-01T12:30", "Should have retained the changed value.");
}, "Datetime (local) field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[16].value, "2", "Should have retained the changed value.");
}, "Number field must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[17].value, "2", "Should have retained the changed value.");
}, "Range control must retain changed value.");
test(function() {
let clone = document.getElementsByTagName("form")[1];
let inputs = clone.getElementsByTagName("input");
assert_equals(inputs[18].value, "#00ff00", "Should have retained the changed value.");
}, "Color picker must retain changed value.");
</script>

View file

@ -16,7 +16,7 @@
<input id="too_large_value" type="date" value="2099-01-31" min="2011-01-01" max="2011-12-31"/>
<input id="invalid_min" type="date" value="2011-01-01" min="1999-1" max="2011-12-31"/>
<input id="invalid_max" type="date" value="2011-01-01" min="2011-01-01" max="2011-13-162-777"/>
<input id="min_larger_than_max" type="date" value="2011-01-01" min="2099-01" max="2011-12-31"/>
<input id="min_larger_than_max" type="date" value="2011-01-01" min="2099-01-01" max="2011-12-31"/>
<input id="invalid_value" type="date" value="invalid-date" min="2011-01-01" max="2011-12-31"/>
</div>
@ -29,20 +29,20 @@
test(function() {
assert_equals(document.getElementById("valid").value, "2011-11-01");
assert_equals(document.getElementById("too_small_value").value, "2011-01-01");
assert_equals(document.getElementById("too_large_value").value, "2011-12-31");
assert_equals(document.getElementById("too_small_value").value, "1999-01-31");
assert_equals(document.getElementById("too_large_value").value, "2099-01-31");
}, "The value attribute, if specified and not empty, must have a value that is a valid date string.");
test(function() {
assert_equals(document.getElementById("valid").min, "2011-01-01"),
assert_equals(document.getElementById("invalid_min").min, "")
}, "The min attribute, if specified, must have a value that is a valid date string.");
assert_equals(document.getElementById("valid").min, "2011-01-01");
assert_equals(document.getElementById("invalid_min").min, "1999-1");
}, "The min attribute must be reflected verbatim by the min property.");
test(function() {
assert_equals(document.getElementById("valid").max, "2011-12-31"),
assert_equals(document.getElementById("min_larger_than_max").max, "2099-01"),
assert_equals(document.getElementById("invalid_max").max, "")
},"The max attribute, if specified, must have a value that is a valid date string.");
assert_equals(document.getElementById("valid").max, "2011-12-31");
assert_equals(document.getElementById("min_larger_than_max").max, "2011-12-31");
assert_equals(document.getElementById("invalid_max").max, "2011-13-162-777");
}, "The max attribute must be reflected verbatim by the max property.");
test(function() {
assert_equals(document.getElementById("invalid_value").value, "");

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Date & Time Inputs</title>
<title>Date and Time Inputs</title>
<meta name=viewport content="width=device-width, maximum-scale=1.0, user-scalable=no" />
<link rel="author" title="Fabrice Clari" href="mailto:f.clari@inno-group.com">
<link rel="author" title="Dimitri Bocquet" href="mailto:Dimitri.Bocquet@mosquito-fp7.eu">
@ -11,11 +11,11 @@
</head>
<body>
<h1>Date & Time Inputs</h1>
<h1>Date and Time Inputs</h1>
<div style="display: none">
<input type="date" value="2011-12-01" min="2011-12-01" max="2011-12-31" step="5" />
<input type="time" value= "12:00" min="11:30" max="14:00" step="600" />
<input type="datetime" value="2011-12-01T12:00Z" min="2011-12-01T12:00Z" max="2011-12-31T22:00Z" step="7200" />
<input type="datetime-local" value="2011-12-01T12:00" min="2011-12-01T12:00" max="2011-12-31T22:00" step="7200" />
<input type="month" value="2011-01" min="2011-01" max="2011-12" step="2" />
<input type="week" value="2011-W40" min="2011-W20" max="2011-W50" step="2" />
</div>
@ -54,19 +54,19 @@
test(function() {assert_true(typeof(document.getElementsByTagName("input")[1].stepDown) == "function")}, "[time] stepDown method support on input 'time' element", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-stepdown" });
test(function() {assert_equals(document.getElementsByTagName("input")[2].type, "datetime")}, "datetime type support on input element", {
test(function() {assert_equals(document.getElementsByTagName("input")[2].type, "datetime-local")}, "datetime-local type support on input element", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-type" });
test(function() {assert_equals(document.getElementsByTagName("input")[2].value, "2011-12-01T12:00Z")}, "[datetime] The must be a valid global date and time string", {
test(function() {assert_equals(document.getElementsByTagName("input")[2].value, "2011-12-01T12:00")}, "[datetime-local] The must be a valid local date and time string", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-value" });
test(function() {assert_equals(document.getElementsByTagName("input")[2].min, "2011-12-01T12:00Z")}, "[datetime] The min attribute must have a value that is a valid global date and time string", {
test(function() {assert_equals(document.getElementsByTagName("input")[2].min, "2011-12-01T12:00")}, "[datetime-local] The min attribute must have a value that is a valid local date and time string", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-min" });
test(function() {assert_equals(document.getElementsByTagName("input")[2].max, "2011-12-31T22:00Z")}, "[datetime] The max attribute must have a value that is a valid global date and time string", {
test(function() {assert_equals(document.getElementsByTagName("input")[2].max, "2011-12-31T22:00")}, "[datetime-local] The max attribute must have a value that is a valid local date and time string", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-max" });
test(function() {assert_equals(document.getElementsByTagName("input")[2].step, "7200")}, "[datetime] The step attribute must be expressed in seconds", {
test(function() {assert_equals(document.getElementsByTagName("input")[2].step, "7200")}, "[datetime-local] The step attribute must be expressed in seconds", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-step" });
test(function() {assert_true(typeof(document.getElementsByTagName("input")[2].stepUp) == "function")}, "[datetime] stepUp method support on input 'datetime' element", {
test(function() {assert_true(typeof(document.getElementsByTagName("input")[2].stepUp) == "function")}, "[datetime-local] stepUp method support on input 'datetime-local' element", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-stepup" });
test(function() {assert_true(typeof(document.getElementsByTagName("input")[2].stepDown) == "function")}, "[datetime] stepDown method support on input 'datetime' element", {
test(function() {assert_true(typeof(document.getElementsByTagName("input")[2].stepDown) == "function")}, "[datetime-local] stepDown method support on input 'datetime-local' element", {
"help" : "https://html.spec.whatwg.org/multipage/#dom-input-stepdown" });
test(function() {assert_equals(document.getElementsByTagName("input")[3].type, "month")}, "month type support on input element", {

View file

@ -2,7 +2,7 @@
<meta charset=utf-8>
<title>Form input type=number</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/#password-state-(type=number)">
<link rel=help href="https://html.spec.whatwg.org/multipage/#number-state-(type=number)">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
@ -29,14 +29,14 @@
{value: "Infinity", expected: "", testname: " value = Infinity"},
{value: "-Infinity", expected: "", testname: "value = -Infinity"},
{value: "NaN", expected: "", testname: "value = NaN"},
{value: "9007199254740993", expected: "9007199254740992", testname: "value = 2^53+1"},
{value: "9007199254740993", expected: "9007199254740993", testname: "value = 2^53+1"},
{value: "2e308", expected: "", testname: "value >= Number.MAX_VALUE"},
{value: "1e", expected: "", testname: "value = 1e"},
{value: "+1", expected: "1", testname: "value = +1"},
{value: "+1", expected: "", testname: "value = +1"},
{value: "+", expected: "", testname: "value = '+'"},
{value: "-", expected: "", testname: "value = '-'"},
{value: " 1", expected: "1", testname: "value with a leading whitespace"},
{value: "1trailing junk", expected: "1", testname: "value = 1trailing junk"}
{value: " 1", expected: "", testname: "value with a leading whitespace"},
{value: "1trailing junk", expected: "", testname: "value = 1trailing junk"}
];
for (var i = 0; i < numbers.length; i++) {
var w = numbers[i];

View file

@ -71,24 +71,30 @@
}
);
// HTML5 spec says the default vaules of min and max attributes are 0 and 100 respectively,
// however, Chrome, Opera and Firefox would not give any default value at all...
test(
function() {
assert_equals(document.getElementById('illegal_min_and_max').min, "0")
assert_equals(document.getElementById('illegal_min_and_max').min, "ab")
},
"Illegal value of min attribute",
{
"help" : "https://html.spec.whatwg.org/multipage/#range-state-(type=range)"
"help" : [
"https://html.spec.whatwg.org/multipage/#dom-input-min",
"https://html.spec.whatwg.org/multipage/#range-state-(type=range)"
]
}
);
test(
function() {
assert_equals(document.getElementById('illegal_min_and_max').max, "100")
assert_equals(document.getElementById('illegal_min_and_max').max, "f")
},
"Illegal value of max attribute",
{ "help" : "https://html.spec.whatwg.org/multipage/#range-state-(type=range)" }
{
"help" : [
"https://html.spec.whatwg.org/multipage/#dom-input-max",
"https://html.spec.whatwg.org/multipage/#range-state-(type=range)"
]
}
);
test(
@ -103,10 +109,15 @@
test(
function() {
assert_equals(document.getElementById('illegal_value_and_step').step, "1")
assert_equals(document.getElementById('illegal_value_and_step').step, "xyz")
},
"Converting an illegal string to the default step",
{ "help" : "https://html.spec.whatwg.org/multipage/#range-state-(type=range)" }
"Illegal value of step attribute",
{
"help" : [
"https://html.spec.whatwg.org/multipage/#dom-input-step",
"https://html.spec.whatwg.org/multipage/#range-state-(type=range)"
]
}
);
test(
@ -131,7 +142,7 @@
test(
function() {
assert_equals(document.getElementById('empty_attributes').min, "0")
assert_equals(document.getElementById('empty_attributes').min, "")
},
"default value of min attribute in input type=range",
{ "help" : "https://html.spec.whatwg.org/multipage/#dom-input-min" }
@ -139,7 +150,7 @@
test(
function() {
assert_equals(document.getElementById('empty_attributes').max, "100")
assert_equals(document.getElementById('empty_attributes').max, "")
},
"default value of max attribute in input type=range",
{

View file

@ -2,8 +2,8 @@
<meta charset=utf-8>
<title>Form input type=time</title>
<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org">
<link rel=help href="https://html.spec.whatwg.org/multipage/multipage/common-microsyntaxes.html#times">
<link rel=help href="https://html.spec.whatwg.org/multipage/multipage/states-of-the-type-attribute.html#time-state-(type=time)">
<link rel=help href="https://html.spec.whatwg.org/multipage/#times">
<link rel=help href="https://html.spec.whatwg.org/multipage/#time-state-(type=time)">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
@ -23,9 +23,9 @@
{value: "00:60:00.000", expected: "", testname: "Invalid value: minute > 59. Value should be empty"},
{value: "00:00:60.000", expected: "", testname: "Invalid value: second > 59. Value should be empty"},
{value: "12:00:00.001", attributes: { min: "12:00:00.000" }, expected: "12:00:00.001", testname: "Value >= min attribute"},
{value: "12:00:00.000", attributes: { min: "12:00:00.001" }, expected: "12:00:00.001", testname: "Value < min attribute"},
{value: "12:00:00.000", attributes: { min: "12:00:00.001" }, expected: "12:00:00.000", testname: "Value < min attribute"},
{value: "12:00:00.000", attributes: { max: "12:00:00.001" }, expected: "12:00:00.000", testname: "Value <= max attribute"},
{value: "12:00:00.001", attributes: { max: "12:00:00.000" }, expected: "12:00:00.000", testname: "Value > max attribute"}
{value: "12:00:00.001", attributes: { max: "12:00:00.000" }, expected: "12:00:00.001", testname: "Value > max attribute"}
];
for (var i = 0; i < times.length; i++) {
var w = times[i];

View file

@ -51,79 +51,172 @@ test(function(){
_StepTest.value = "12:00";
_StepTest.step = "";
_StepTest.stepUp();
assert_equals(_StepTest.value,"12:01");
assert_in_array(
_StepTest.value,
[
"12:01",
"12:01:00",
"12:01:00.0",
"12:01:00.00",
"12:01:00.000"],
"a valid time string representing 1 minute after noon");
} , "stepUp step value empty on default step value ");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "";
_StepTest.stepDown();
assert_equals(_StepTest.value,"11:59");
assert_in_array(
_StepTest.value,
[
"11:59",
"11:59:00",
"11:59:00.0",
"11:59:00.00",
"11:59:00.000"],
"a valid time string representing 1 minute before noon");
}, "stepDown step value empty default step value");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "-600";
_StepTest.stepUp();
assert_equals(_StepTest.value, "12:01");
assert_in_array(
_StepTest.value,
[
"12:01",
"12:01:00",
"12:01:00.0",
"12:01:00.00",
"12:01:00.000"],
"a valid time string representing 1 minute after noon");
},"stepUp on step value minus");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "-600";
_StepTest.stepDown();
assert_equals(_StepTest.value, "11:59");
assert_in_array(
_StepTest.value,
[
"11:59",
"11:59:00",
"11:59:00.0",
"11:59:00.00",
"11:59:00.000"],
"a valid time string representing 1 minute before noon");
},"stepDown on step value minus");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "0";
_StepTest.stepUp();
assert_equals(_StepTest.value, "12:01");
assert_in_array(
_StepTest.value,
[
"12:01",
"12:01:00",
"12:01:00.0",
"12:01:00.00",
"12:01:00.000"],
"a valid time string representing 1 minute after noon");
} , "stepUp on step value zero ");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "0";
_StepTest.stepDown();
assert_equals(_StepTest.value, "11:59");
assert_in_array(
_StepTest.value,
[
"11:59",
"11:59:00",
"11:59:00.0",
"11:59:00.00",
"11:59:00.000"],
"a valid time string representing 1 minute before noon");
} , "stepDown on step value zero ");
test(function(){
_StepTest.value = "00:00";
_StepTest.step = "86399";
_StepTest.stepUp();
assert_equals(_StepTest.value, "23:59:59");
assert_in_array(
_StepTest.value,
[
"23:59:59",
"23:59:59.0",
"23:59:59.00",
"23:59:59.000"],
"a valid time string representing 1 second before midnight");
} , "stepUp on step value 24 hour");
test(function(){
_StepTest.value = "23:59:59";
_StepTest.step = "86399";
_StepTest.stepDown();
assert_equals(_StepTest.value, "00:00:00");
assert_in_array(
_StepTest.value,
[
"00:00",
"00:00:00",
"00:00:00.0",
"00:00:00.00",
"00:00:00.000"],
"a valid time string representing midnight");
} , "stepDown on step value 24 hour ");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "3600";
_StepTest.stepUp();
assert_equals(_StepTest.value, "13:00");
assert_in_array(
_StepTest.value,
[
"13:00",
"13:00:00",
"13:00:00.0",
"13:00:00.00",
"13:00:00.000"],
"a valid time string representing 1pm");
} , "stepUp on step value hour ");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "3600";
_StepTest.stepDown();
assert_equals(_StepTest.value, "11:00");
assert_in_array(
_StepTest.value,
[
"11:00",
"11:00:00",
"11:00:00.0",
"11:00:00.00",
"11:00:00.000"],
"a valid time string representing 11am");
} , "stepDown on step value hour ");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "1";
_StepTest.stepUp();
assert_equals(_StepTest.value, "12:00:01");
assert_in_array(
_StepTest.value,
[
"12:00:01",
"12:00:01.0",
"12:00:01.00",
"12:00:01.000"],
"a valid time string representing 1 second after noon");
} , "stepUp on step value second ");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "1";
_StepTest.stepDown();
assert_equals(_StepTest.value, "11:59:59");
assert_in_array(
_StepTest.value,
[
"11:59:59",
"11:59:59.0",
"11:59:59.00",
"11:59:59.000"],
"a valid time string representing 1 second before noon");
} , "stepDown on step value second ");
test(function(){
@ -131,64 +224,118 @@ test(function(){
_StepTest.step = "0.001";
_StepTest.stepUp();
assert_equals(_StepTest.value, "12:00:00.001");
} , "stepUp on step value miri second ");
} , "stepUp on step value with fractional seconds");
test(function(){
_StepTest.value = "12:00";
_StepTest.step = "0.001";
_StepTest.stepDown();
assert_equals(_StepTest.value, "11:59:59.999");
} , "stepDown on step value miri second ");
} , "stepDown on step value with fractional seconds");
test(function(){
_StepTest.value = "13:00:00";
_StepTest.step = "1";
_StepTest.stepUp(2);
assert_equals(_StepTest.value, "13:00:02");
}, "stepUp argment 2 times");
assert_in_array(
_StepTest.value,
[
"13:00:02",
"13:00:02.0",
"13:00:02.00",
"13:00:02.000"],
"a valid time string representing 2 seconds after 1pm");
}, "stepUp argument 2 times");
test(function(){
_StepTest.value = "13:00:00";
_StepTest.step = "1";
_StepTest.stepDown(2);
assert_equals(_StepTest.value, "12:59:58");
}, "stepDown argment 2 times");
assert_in_array(
_StepTest.value,
[
"12:59:58",
"12:59:58.0",
"12:59:58.00",
"12:59:58.000"],
"a valid time string representing 2 seconds before 1pm");
}, "stepDown argument 2 times");
test(function(){
_StepTest.max = "15:00";
this.add_cleanup(function() { _StepTest.max = ""; });
_StepTest.value = "15:00";
_StepTest.stepUp();
assert_equals(_StepTest.value, "15:00");
_StepTest.max = "";
assert_in_array(
_StepTest.value,
[
"15:00",
"15:00:00",
"15:00:00.0",
"15:00:00.00",
"15:00:00.000"],
"a valid time string representing 3pm");
} , "stepUp stop because it exceeds the maximum value");
test(function(){
_StepTest.min = "13:00";
this.add_cleanup(function() { _StepTest.min = ""; });
_StepTest.value = "13:00";
_StepTest.stepDown();
assert_equals(_StepTest.value, "13:00");
_StepTest.min="";
} , "stepDown Stop so lower than the minimum value");
assert_in_array(
_StepTest.value,
[
"13:00",
"13:00:00",
"13:00:00.0",
"13:00:00.00",
"13:00:00.000"],
"a valid time string representing 1pm");
} , "stepDown stop so lower than the minimum value");
test(function(){
_StepTest.max = "15:01";
this.add_cleanup(function() { _StepTest.max = ""; });
_StepTest.value = "15:00";
_StepTest.step = "120";
_StepTest.stepUp();
assert_equals(_StepTest.value, "15:01");
_StepTest.max = "";
assert_in_array(
_StepTest.value,
[
"15:01",
"15:01:00",
"15:01:00.0",
"15:01:00.00",
"15:01:00.000"],
"a valid time string representing 1 minute after 3pm");
} , "stop at border on stepUp");
test(function(){
_StepTest.min = "12:59";
this.add_cleanup(function() { _StepTest.min = ""; });
_StepTest.value = "13:00";
_StepTest.step = "120";
_StepTest.stepDown();
assert_equals(_StepTest.value, "12:59");
_StepTest.min="";
assert_in_array(
_StepTest.value,
[
"12:59",
"12:59:00",
"12:59:00.0",
"12:59:00.00",
"12:59:00.000"],
"a valid time string representing 1 minute before 2pm");
} , "stop at border on stepDown");
test(function(){
_StepTest.value = "";
_StepTest.step = "60";
_StepTest.stepUp();
assert_equals(_StepTest.value, "00:01");
assert_in_array(
_StepTest.value,
[
"00:01",
"00:01:00",
"00:01:00.0",
"00:01:00.00",
"00:01:00.000"],
"a valid time string representing 1 minute after midnight");
} , " empty value of stepUp");

View file

@ -19,9 +19,9 @@
{value: "-W52", expected: "", testname: "Invalid value: yearless week"},
{value: "W52", expected: "", testname: "Invalid value: yearless week and no '-' (U+002D)"},
{value: "2014-W03", attributes: { min: "2014-W02" }, expected: "2014-W03", testname: "Value >= min attribute"},
{value: "2014-W01", attributes: { min: "2014-W02" }, expected: "2014-W02", testname: "Value < min attribute"},
{value: "2014-W01", attributes: { min: "2014-W02" }, expected: "2014-W01", testname: "Value < min attribute"},
{value: "2014-W10", attributes: { max: "2014-W11" }, expected: "2014-W10", testname: "Value <= max attribute"},
{value: "2014-W12", attributes: { max: "2014-W11" }, expected: "2014-W11", testname: "Value > max attribute"}
{value: "2014-W12", attributes: { max: "2014-W11" }, expected: "2014-W12", testname: "Value > max attribute"}
];
for (var i = 0; i < weeks.length; i++) {
var w = weeks[i];

View file

@ -103,11 +103,12 @@ test(function() {
}, "Check if the input element in radio state can access 'labels'");
test(function() {
assert_equals(document.getElementById("lbl7").control.id, "testkeygen", "A keygen element should be labelable.");
}, "Check if the keygen element is a labelable element");
assert_not_equals(document.getElementById("lbl7").control, document.getElementById("testkeygen"));
assert_equals(document.getElementById("lbl7").control, null, "A keygen element should not be labelable.");
}, "Check if the keygen element is not a labelable element");
test(function() {
testLabelsAttr("testkeygen", "lbl7");
assert_equals(document.getElementById("testkeygen").labels, undefined);
}, "Check if the keygen element can access 'labels'");
test(function() {

View file

@ -0,0 +1,95 @@
<!doctype html>
<meta charset=utf-8>
<title>HTMLSelectElement.checkValidity</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/forms.html#the-select-element:attr-select-required-4">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function() {
var select = document.createElement('select');
assert_true(select.willValidate, "A select element is a submittable element that is a candidate for constraint validation.");
var placeholder = document.createElement('option');
select.appendChild(placeholder);
assert_true(select.checkValidity(), "Always valid when the select isn't a required value.");
select.required = true;
assert_true(placeholder.selected, "If display size is 1, multiple is absent and no options have selectedness true, the first option is selected.");
assert_equals(select.value, "", "The placeholder's value should be the select's value right now");
assert_false(select.checkValidity(), "A selected placeholder option should invalidate the select.");
var emptyOption = document.createElement('option');
select.appendChild(emptyOption);
emptyOption.selected = true;
assert_equals(select.value, "", "The empty value should be set.");
assert_true(select.checkValidity(), "An empty non-placeholder option should be a valid choice.");
var filledOption = document.createElement('option');
filledOption.value = "test";
select.appendChild(filledOption);
filledOption.selected = true;
assert_equals(select.value, "test", "The non-empty value should be set.");
assert_true(select.checkValidity(), "A non-empty non-placeholder option should be a valid choice.");
select.removeChild(placeholder);
select.appendChild(emptyOption); // move emptyOption to second place
emptyOption.selected = true;
assert_equals(select.value, "", "The empty value should be set.");
assert_true(select.checkValidity(), "Only the first option can be seen as a placeholder.");
placeholder.disabled = true;
select.insertBefore(placeholder, filledOption);
placeholder.selected = true;
assert_equals(select.value, "", "A disabled first placeholder option should result in an empty value.");
assert_false(select.checkValidity(), "A disabled first placeholder option should invalidate the select.");
}, "Placeholder label options within a select");
test(function() {
var select = document.createElement('select');
select.required = true;
var optgroup = document.createElement('optgroup');
var emptyOption = document.createElement('option');
optgroup.appendChild(emptyOption);
select.appendChild(optgroup);
emptyOption.selected = true;
assert_equals(select.value, "", "The empty value should be set.");
assert_true(select.checkValidity(), "The first option is not considered a placeholder if it is located within an optgroup.");
var otherEmptyOption = document.createElement('option');
otherEmptyOption.value = "";
select.appendChild(otherEmptyOption);
otherEmptyOption.selected = true;
assert_equals(select.value, "", "The empty value should be set.");
assert_true(select.checkValidity(), "The empty option should be accepted as it is not the first option in the tree ordered list.");
}, "Placeholder label-like options within optgroup");
test(function() {
var select = document.createElement('select');
select.required = true;
select.size = 2;
var emptyOption = document.createElement('option');
select.appendChild(emptyOption);
assert_false(emptyOption.selected, "Display size is not 1, so the first option should not be selected.");
assert_false(select.checkValidity(), "If no options are selected the select must be seen as invalid.");
emptyOption.selected = true;
assert_true(select.checkValidity(), "If one option is selected, the select should be considered valid.");
var otherEmptyOption = document.createElement('option');
otherEmptyOption.value = "";
select.appendChild(otherEmptyOption);
otherEmptyOption.selected = true;
assert_false(emptyOption.selected, "Whenever an option has its selectiveness set to true, the other options must be set to false.");
otherEmptyOption.selected = false;
assert_false(otherEmptyOption.selected, "It should be possible to set the selectiveness to false with a display size more than one.");
assert_false(select.checkValidity(), "If no options are selected the select must be seen as invalid.");
}, "Validation on selects with display size set as more than one");
test(function() {
var select = document.createElement('select');
select.required = true;
select.multiple = true;
var emptyOption = document.createElement('option');
select.appendChild(emptyOption);
assert_false(select.checkValidity(), "If no options are selected the select must be seen as invalid.");
emptyOption.selected = true;
assert_true(select.checkValidity(), "If one option is selected, the select should be considered valid.");
var optgroup = document.createElement('optgroup');
optgroup.appendChild(emptyOption); // Move option to optgroup
select.appendChild(optgroup);
assert_true(select.checkValidity(), "If one option within an optgroup or not is selected, the select should be considered valid.");
}, "Validation on selects with multiple set");
</script>