Skip to content

Commit

Permalink
Split week and month input types from forms WPTs
Browse files Browse the repository at this point in the history
This was requested here:
web-platform-tests/interop#88

Change-Id: Id8792317129552efb39d872c0e12a597cf269ece
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Jun 23, 2022
1 parent 70113ca commit 0065a48
Show file tree
Hide file tree
Showing 23 changed files with 604 additions and 174 deletions.
42 changes: 42 additions & 0 deletions html/dom/elements-forms-weekmonth.js
@@ -0,0 +1,42 @@
var formElements = {
input: {
// Conforming
accept: "string",
alt: "string",
autocomplete: {type: "string", customGetter: true},
defaultChecked: {type: "boolean", domAttrName: "checked"},
dirName: "string",
disabled: "boolean",
// "formAction" has magic hard-coded in reflection.js
formAction: "url",
formEnctype: {type: "enum", keywords: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalidVal: "application/x-www-form-urlencoded"},
formMethod: {type: "enum", keywords: ["get", "post"], invalidVal: "get"},
formNoValidate: "boolean",
formTarget: "string",
height: {type: "unsigned long", customGetter: true},
max: "string",
maxLength: "limited long",
min: "string",
minLength: "limited long",
multiple: "boolean",
name: "string",
pattern: "string",
placeholder: "string",
readOnly: "boolean",
required: "boolean",
// https://html.spec.whatwg.org/#attr-input-size
size: {type: "limited unsigned long", defaultVal: 20},
src: "url",
step: "string",
type: {type: "enum", keywords: ["month", "week"],
defaultVal: "text"},
width: {type: "unsigned long", customGetter: true},
defaultValue: {type: "string", domAttrName: "value"},

// Obsolete
align: "string",
useMap: "string",
},
};

mergeElements(formElements);
2 changes: 1 addition & 1 deletion html/dom/elements-forms.js
Expand Up @@ -52,7 +52,7 @@ var formElements = {
src: "url",
step: "string",
type: {type: "enum", keywords: ["hidden", "text", "search", "tel",
"url", "email", "password", "date", "month", "week",
"url", "email", "password", "date",
"time", "datetime-local", "number", "range", "color", "checkbox",
"radio", "file", "submit", "image", "reset", "button"], defaultVal:
"text"},
Expand Down
17 changes: 17 additions & 0 deletions html/dom/reflection-forms-weekmonth.html
@@ -0,0 +1,17 @@
<!doctype html>
<title>HTML5 reflection tests: week and month input types</title>
<meta name=timeout content=long>
<p>Implementers looking to fix bugs might want to use the <a
href=reflection-original.html>original version</a> of this suite's test
framework, which conveniently aggregates similar errors and only reports
failures. This file is (part of) the authoritative conformance test suite, and
is suitable for incorporation into automated test suites.

<div id=log></div>

<script src="/resources/testharness.js"></script>
<script src=/resources/testharnessreport.js></script>
<script src=original-harness.js></script>
<script src=new-harness.js></script>
<script src=elements-forms-weekmonth.js></script>
<script src=reflection.js></script>
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>The constraint validation API Test: element.validity.rangeOverflow</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-validitystate-rangeoverflow">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-constraint-validation-api">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/validator.js"></script>
<div id="log"></div>
<script>
var testElements = [
{
tag: "input",
types: ["month"],
testData: [
{conditions: {max: "", value: "2000-01"}, expected: false, name: "[target] The max attribute is not set"},
{conditions: {max: "2000-01", value: ""}, expected: false, name: "[target] Value is empty string"},
{conditions: {max: "2000/01", value: "2001-02"}, expected: false, name: "[target] The max attribute is an invalid month string"},
{conditions: {max: "2000-01", value: "2000-1"}, expected: false, name: "[target] The value attribute is an invalid month string"},
{conditions: {max: "987-01", value: "988-01"}, expected: false, name: "[target] The value is an invalid month string(year is three digits)"},
{conditions: {max: "2000-01", value: "2000-13"}, expected: false, name: "[target] The value is an invalid month string(month is greater than 12)"},
{conditions: {max: "2000-12", value: "2000-01"}, expected: false, name: "[target] The max attribute is greater than value attribute"},
{conditions: {max: "2000-01", value: "2000-12"}, expected: true, name: "[target] The value attribute is greater than max attribute"},
{conditions: {max: "9999-01", value: "10000-01"}, expected: true, name: "[target] The value attribute is greater than max attribute(Year is 10000 should be valid)"}
]
},
{
tag: "input",
types: ["week"],
testData: [
{conditions: {max: "", value: "2000-W01"}, expected: false, name: "[target] The max attribute is not set"},
{conditions: {max: "2000-W01", value: ""}, expected: false, name: "[target] Value is empty string"},
{conditions: {max: "2000/W01", value: "2001-W02"}, expected: false, name: "[target] The max attribute is an invalid week string"},
{conditions: {max: "2000-W01", value: "2000-W2"}, expected: false, name: "[target] The value attribute is an invalid week string"},
{conditions: {max: "2000-W01", value: "2000-w02"}, expected: false, name: "[target] The value attribute is an invalid week string(w is in lowercase)"},
{conditions: {max: "987-W01", value: "988-W01"}, expected: false, name: "[target] The value is an invalid week string(year is three digits)"},
{conditions: {max: "2000-W01", value: "2000-W57"}, expected: false, name: "[target] The value is an invalid week string(week is too greater)"},
{conditions: {max: "2000-W12", value: "2000-W01"}, expected: false, name: "[target] The max attribute is greater than value attribute"},
{conditions: {max: "2000-W01", value: "2000-W12"}, expected: true, name: "[target] The value attribute is greater than max attribute"},
{conditions: {max: "9999-W01", value: "10000-W01"}, expected: true, name: "[target] The value attribute is greater than max attribute(Year is 10000 should be valid)"}
]
}
];

validator.run_test(testElements, "rangeOverflow");
</script>
Expand Up @@ -43,37 +43,6 @@
{conditions: {max: "9999-01-01", value: "10000-01-01"}, expected: true, name: "[target] The value attribute is greater than max attribute(Year is 10000 should be valid)"}
]
},
{
tag: "input",
types: ["month"],
testData: [
{conditions: {max: "", value: "2000-01"}, expected: false, name: "[target] The max attribute is not set"},
{conditions: {max: "2000-01", value: ""}, expected: false, name: "[target] Value is empty string"},
{conditions: {max: "2000/01", value: "2001-02"}, expected: false, name: "[target] The max attribute is an invalid month string"},
{conditions: {max: "2000-01", value: "2000-1"}, expected: false, name: "[target] The value attribute is an invalid month string"},
{conditions: {max: "987-01", value: "988-01"}, expected: false, name: "[target] The value is an invalid month string(year is three digits)"},
{conditions: {max: "2000-01", value: "2000-13"}, expected: false, name: "[target] The value is an invalid month string(month is greater than 12)"},
{conditions: {max: "2000-12", value: "2000-01"}, expected: false, name: "[target] The max attribute is greater than value attribute"},
{conditions: {max: "2000-01", value: "2000-12"}, expected: true, name: "[target] The value attribute is greater than max attribute"},
{conditions: {max: "9999-01", value: "10000-01"}, expected: true, name: "[target] The value attribute is greater than max attribute(Year is 10000 should be valid)"}
]
},
{
tag: "input",
types: ["week"],
testData: [
{conditions: {max: "", value: "2000-W01"}, expected: false, name: "[target] The max attribute is not set"},
{conditions: {max: "2000-W01", value: ""}, expected: false, name: "[target] Value is empty string"},
{conditions: {max: "2000/W01", value: "2001-W02"}, expected: false, name: "[target] The max attribute is an invalid week string"},
{conditions: {max: "2000-W01", value: "2000-W2"}, expected: false, name: "[target] The value attribute is an invalid week string"},
{conditions: {max: "2000-W01", value: "2000-w02"}, expected: false, name: "[target] The value attribute is an invalid week string(w is in lowercase)"},
{conditions: {max: "987-W01", value: "988-W01"}, expected: false, name: "[target] The value is an invalid week string(year is three digits)"},
{conditions: {max: "2000-W01", value: "2000-W57"}, expected: false, name: "[target] The value is an invalid week string(week is too greater)"},
{conditions: {max: "2000-W12", value: "2000-W01"}, expected: false, name: "[target] The max attribute is greater than value attribute"},
{conditions: {max: "2000-W01", value: "2000-W12"}, expected: true, name: "[target] The value attribute is greater than max attribute"},
{conditions: {max: "9999-W01", value: "10000-W01"}, expected: true, name: "[target] The value attribute is greater than max attribute(Year is 10000 should be valid)"}
]
},
{
tag: "input",
types: ["time"],
Expand Down
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>The constraint validation API Test: element.validity.rangeUnderflow</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-validitystate-rangeunderflow">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-constraint-validation-api">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/validator.js"></script>
<div id="log"></div>
<script>
var testElements = [
{
tag: "input",
types: ["month"],
testData: [
{conditions: {min: "", value: "2000-01"}, expected: false, name: "[target] The min attribute is not set"},
{conditions: {min: "2000-01", value: ""}, expected: false, name: "[target] Value is empty string"},
{conditions: {min: "2001/01", value: "2000-02"}, expected: false, name: "[target] The min attribute is an invalid month string"},
{conditions: {min: "2000-02", value: "2000-1"}, expected: false, name: "[target] The value attribute is an invalid month string"},
{conditions: {min: "988-01", value: "987-01"}, expected: false, name: "[target] The value is an invalid month string(year is three digits)"},
{conditions: {min: "2001-01", value: "2000-13"}, expected: false, name: "[target] The value is an invalid month string(month is less than 12)"},
{conditions: {min: "2000-01", value: "2000-12"}, expected: false, name: "[target] The min attribute is less than value attribute"},
{conditions: {min: "2001-01", value: "2000-12"}, expected: true, name: "[target] The value attribute is less than min attribute"},
{conditions: {min: "10000-01", value: "2000-01"}, expected: true, name: "[target] The value attribute is less than min attribute(Year is 10000 should be valid)"}
]
},
{
tag: "input",
types: ["week"],
testData: [
{conditions: {min: "", value: "2000-W01"}, expected: false, name: "[target] The min attribute is not set"},
{conditions: {min: "2000-W01", value: ""}, expected: false, name: "[target] Value is empty string"},
{conditions: {min: "2001/W02", value: "2000-W01"}, expected: false, name: "[target] The min attribute is an invalid week string"},
{conditions: {min: "2001-W02", value: "2000-W1"}, expected: false, name: "[target] The value attribute is an invalid week string"},
{conditions: {min: "2001-W02", value: "2000-w01"}, expected: false, name: "[target] The value attribute is an invalid week string(w is in lowercase)"},
{conditions: {min: "988-W01", value: "987-W01"}, expected: false, name: "[target] The value is an invalid week string(year is three digits)"},
{conditions: {min: "2001-W01", value: "2000-W57"}, expected: false, name: "[target] The value is an invalid week string(week is too greater)"},
{conditions: {min: "2000-W01", value: "2000-W12"}, expected: false, name: "[target] The min attribute is less than value attribute"},
{conditions: {min: "2000-W12", value: "2000-W01"}, expected: true, name: "[target] The value attribute is less than min attribute"},
{conditions: {min: "10000-W01", value: "2000-W01"}, expected: true, name: "[target] The value attribute is less than min attribute(Year is 10000 should be valid)"}
]
}
];

validator.run_test(testElements, "rangeUnderflow");
</script>
Expand Up @@ -44,37 +44,6 @@
{conditions: {min: "10000-01-01", value: "9999-01-01"}, expected: true, name: "[target] The value attribute is less than min attribute(Year is 10000 should be valid)"}
]
},
{
tag: "input",
types: ["month"],
testData: [
{conditions: {min: "", value: "2000-01"}, expected: false, name: "[target] The min attribute is not set"},
{conditions: {min: "2000-01", value: ""}, expected: false, name: "[target] Value is empty string"},
{conditions: {min: "2001/01", value: "2000-02"}, expected: false, name: "[target] The min attribute is an invalid month string"},
{conditions: {min: "2000-02", value: "2000-1"}, expected: false, name: "[target] The value attribute is an invalid month string"},
{conditions: {min: "988-01", value: "987-01"}, expected: false, name: "[target] The value is an invalid month string(year is three digits)"},
{conditions: {min: "2001-01", value: "2000-13"}, expected: false, name: "[target] The value is an invalid month string(month is less than 12)"},
{conditions: {min: "2000-01", value: "2000-12"}, expected: false, name: "[target] The min attribute is less than value attribute"},
{conditions: {min: "2001-01", value: "2000-12"}, expected: true, name: "[target] The value attribute is less than min attribute"},
{conditions: {min: "10000-01", value: "2000-01"}, expected: true, name: "[target] The value attribute is less than min attribute(Year is 10000 should be valid)"}
]
},
{
tag: "input",
types: ["week"],
testData: [
{conditions: {min: "", value: "2000-W01"}, expected: false, name: "[target] The min attribute is not set"},
{conditions: {min: "2000-W01", value: ""}, expected: false, name: "[target] Value is empty string"},
{conditions: {min: "2001/W02", value: "2000-W01"}, expected: false, name: "[target] The min attribute is an invalid week string"},
{conditions: {min: "2001-W02", value: "2000-W1"}, expected: false, name: "[target] The value attribute is an invalid week string"},
{conditions: {min: "2001-W02", value: "2000-w01"}, expected: false, name: "[target] The value attribute is an invalid week string(w is in lowercase)"},
{conditions: {min: "988-W01", value: "987-W01"}, expected: false, name: "[target] The value is an invalid week string(year is three digits)"},
{conditions: {min: "2001-W01", value: "2000-W57"}, expected: false, name: "[target] The value is an invalid week string(week is too greater)"},
{conditions: {min: "2000-W01", value: "2000-W12"}, expected: false, name: "[target] The min attribute is less than value attribute"},
{conditions: {min: "2000-W12", value: "2000-W01"}, expected: true, name: "[target] The value attribute is less than min attribute"},
{conditions: {min: "10000-W01", value: "2000-W01"}, expected: true, name: "[target] The value attribute is less than min attribute(Year is 10000 should be valid)"}
]
},
{
tag: "input",
types: ["time"],
Expand Down
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>The constraint validation API Test: element.validity.valid</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-validitystate-valid">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-constraint-validation-api">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/validator.js"></script>
<div id="log"></div>
<script>
var testElements = [
{
tag: "input",
types: ["month"],
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"},
// 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, expectedImmutable: true, name: "[target] validity.valid must be false if validity.valueMissing is true"}
]
},
{
tag: "input",
types: ["week"],
testData: [
{conditions: {max: "2000-W01", value: "2001-W01"}, expected: false, name: "[target] validity.valid must be false if validity.rangeOverflow is true"},
{conditions: {min: "2001-W01", value: "2000-W01"}, expected: false, name: "[target] validity.valid must be false if validity.rangeUnderflow is true"},
{conditions: {step: 2 * 1 * 604800000, value: "2001-W03"}, expected: false, name: "[target] validity.valid must be false if validity.stepMismatch is true"},
{conditions: {required: true, value: ""}, expected: false, expectedImmutable: true, name: "[target] validity.valid must be false if validity.valueMissing is true"}
]
}
];

validator.run_test(testElements, "isValid");
</script>
Expand Up @@ -56,27 +56,6 @@
{conditions: {required: true, value: ""}, expected: false, expectedImmutable: true, name: "[target] validity.valid must be false if validity.valueMissing is true"}
]
},
{
tag: "input",
types: ["month"],
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"},
// 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, expectedImmutable: true, name: "[target] validity.valid must be false if validity.valueMissing is true"}
]
},
{
tag: "input",
types: ["week"],
testData: [
{conditions: {max: "2000-W01", value: "2001-W01"}, expected: false, name: "[target] validity.valid must be false if validity.rangeOverflow is true"},
{conditions: {min: "2001-W01", value: "2000-W01"}, expected: false, name: "[target] validity.valid must be false if validity.rangeUnderflow is true"},
{conditions: {step: 2 * 1 * 604800000, value: "2001-W03"}, expected: false, name: "[target] validity.valid must be false if validity.stepMismatch is true"},
{conditions: {required: true, value: ""}, expected: false, expectedImmutable: true, name: "[target] validity.valid must be false if validity.valueMissing is true"}
]
},
{
tag: "input",
types: ["time"],
Expand Down

0 comments on commit 0065a48

Please sign in to comment.