mirror of
https://github.com/servo/servo.git
synced 2025-10-17 00:39:15 +01:00
Update web-platform-tests to revision 422b440e0b587317e4539378b18c362a4ea7afee
This commit is contained in:
parent
dbee7f7d27
commit
0c29efe000
160 changed files with 6195 additions and 2605 deletions
|
@ -91,7 +91,11 @@
|
|||
{conditions: {max: "12:00:00.1", value: "12:00:00.2"}, expected: true, name: "[target] The value is greater than max(with millisecond in 1 digit)"},
|
||||
{conditions: {max: "12:00:00.01", value: "12:00:00.02"}, expected: true, name: "[target] The value is greater than max(with millisecond in 2 digit)"},
|
||||
{conditions: {max: "12:00:00.001", value: "12:00:00.002"}, expected: true, name: "[target] The value is greater than max(with millisecond in 3 digit)"},
|
||||
{conditions: {max: "12:00:00", value: "12:01"}, expected: true, name: "[target] The time missing second part is valid"}
|
||||
{conditions: {max: "12:00:00", value: "12:01"}, expected: true, name: "[target] The time missing second part is valid"},
|
||||
{conditions: {max: "12:00:00", min: "14:00:00", value: "12:00:00"}, expected: false, name: "[target] The time is max for reversed range"},
|
||||
{conditions: {max: "12:00:00", min: "14:00:00", value: "13:00:00"}, expected: true, name: "[target] The time is outside the accepted range for reversed range"},
|
||||
{conditions: {max: "12:00:00", min: "14:00:00", value: "14:00:00"}, expected: false, name: "[target] The time is min for reversed range"},
|
||||
{conditions: {max: "12:00:00", min: "14:00:00", value: "15:00:00"}, expected: false, name: "[target] The time is inside the accepted range for reversed range"},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -89,7 +89,11 @@
|
|||
{conditions: {min: "12:00:00.2", value: "12:00:00.1"}, expected: true, name: "[target] The value is less than min(with millisecond in 1 digit)"},
|
||||
{conditions: {min: "12:00:00.02", value: "12:00:00.01"}, expected: true, name: "[target] The value is less than min(with millisecond in 2 digit)"},
|
||||
{conditions: {min: "12:00:00.002", value: "12:00:00.001"}, expected: true, name: "[target] The value is less than min(with millisecond in 3 digit)"},
|
||||
{conditions: {min: "12:00:00", value: "11:59"}, expected: true, name: "[target] The time missing second part is valid"}
|
||||
{conditions: {min: "12:00:00", value: "11:59"}, expected: true, name: "[target] The time missing second part is valid"},
|
||||
{conditions: {min: "14:00:00", max: "12:00:00", value: "12:00:00"}, expected: false, name: "[target] The time is max for reversed range"},
|
||||
{conditions: {min: "14:00:00", max: "12:00:00", value: "13:00:00"}, expected: true, name: "[target] The time is outside the accepted range for reversed range"},
|
||||
{conditions: {min: "14:00:00", max: "12:00:00", value: "14:00:00"}, expected: false, name: "[target] The time is min for reversed range"},
|
||||
{conditions: {min: "14:00:00", max: "12:00:00", value: "15:00:00"}, expected: false, name: "[target] The time is inside the accepted range for reversed range"},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -132,7 +132,8 @@
|
|||
testData: [
|
||||
{conditions: {required: false, checked: false, name: "test4"}, expected: false, name: "[target] The required attribute is not set"},
|
||||
{conditions: {required: true, checked: true, name: "test5"}, expected: false, name: "[target] The checked attribute is true"},
|
||||
{conditions: {required: true, checked: false, name: "test6"}, expected: true, name: "[target] The checked attribute is false"}
|
||||
{conditions: {required: true, checked: false, name: "test6"}, expected: true, name: "[target] The checked attribute is false"},
|
||||
{conditions: {required: true, checked: false, name: ""}, expected: false, name: "[target] The checked attribute is false and the name attribute is empty"}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset="utf-8">
|
||||
<html>
|
||||
<head>
|
||||
<title>HTMLInputElement valueAsDate</title>
|
||||
<link rel="author" title="pmdartus" href="mailto:dartus.pierremarie@gmail.com">
|
||||
<link rel=help href="https://html.spec.whatwg.org/#dom-input-valueasdate">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h3>input_valueAsDate</h3>
|
||||
<hr>
|
||||
<div id="log"></div>
|
||||
|
||||
<input id="input_date" type="date" />
|
||||
<input id="input_month" type="month" />
|
||||
<input id="input_week" type="week" />
|
||||
<input id="input_time" type="time" />
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
function testValueAsDateGetter(type, element, cases) {
|
||||
for (const [actualValue, expectedValueAsDate] of cases) {
|
||||
test(
|
||||
() => {
|
||||
element.value = actualValue;
|
||||
|
||||
const actualValueAsDate = element.valueAsDate;
|
||||
if (actualValueAsDate instanceof Date) {
|
||||
assert_equals(
|
||||
actualValueAsDate.getTime(),
|
||||
expectedValueAsDate.getTime(),
|
||||
`valueAsDate returns an invalid date (actual: ${actualValueAsDate.toISOString()}, ` +
|
||||
`expected: ${expectedValueAsDate.toISOString()})`
|
||||
);
|
||||
} else {
|
||||
assert_equals(actualValueAsDate, expectedValueAsDate);
|
||||
}
|
||||
},
|
||||
`valueAsDate getter on type ${type} (actual value: ${actualValue}, ` +
|
||||
`expected valueAsDate: ${expectedValueAsDate})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function testValueAsDateSetter(type, element, cases) {
|
||||
for (const [valueAsDate, expectedValue] of cases) {
|
||||
test(() => {
|
||||
element.valueAsDate = valueAsDate;
|
||||
assert_equals(element.value, expectedValue);
|
||||
}, `valueAsDate setter on type ${type} (actual valueAsDate: ${valueAsDate}, expected value: ${expectedValue})`);
|
||||
}
|
||||
}
|
||||
|
||||
const dateInput = document.getElementById("input_date");
|
||||
testValueAsDateGetter("date", dateInput, [
|
||||
["", null],
|
||||
["0000-12-10", null],
|
||||
["2019-00-12", null],
|
||||
["2019-12-00", null],
|
||||
["2019-13-10", null],
|
||||
["2019-02-29", null],
|
||||
["2019-12-10", new Date("2019-12-10T00:00:00.000Z")],
|
||||
["2016-02-29", new Date("2016-02-29T00:00:00.000Z")] // Leap year
|
||||
]);
|
||||
testValueAsDateSetter("date", dateInput, [
|
||||
[new Date("2019-12-10T00:00:00.000Z"), "2019-12-10"],
|
||||
[new Date("2016-02-29T00:00:00.000Z"), "2016-02-29"] // Leap year
|
||||
]);
|
||||
|
||||
const monthInput = document.getElementById("input_month");
|
||||
testValueAsDateGetter("month", monthInput, [
|
||||
["", null],
|
||||
["0000-12", null],
|
||||
["2019-00", null],
|
||||
["2019-12", new Date("2019-12-01T00:00:00.000Z")]
|
||||
]);
|
||||
testValueAsDateSetter("month", monthInput, [[new Date("2019-12-01T00:00:00.000Z"), "2019-12"]]);
|
||||
|
||||
const weekInput = document.getElementById("input_week");
|
||||
testValueAsDateGetter("week", weekInput, [
|
||||
["", null],
|
||||
["0000-W50", null],
|
||||
["2019-W00", null],
|
||||
["2019-W60", null],
|
||||
["2019-W50", new Date("2019-12-09T00:00:00.000Z")]
|
||||
]);
|
||||
testValueAsDateSetter("week", weekInput, [[new Date("2019-12-09T00:00:00.000Z"), "2019-W50"]]);
|
||||
|
||||
const timeInput = document.getElementById("input_time");
|
||||
testValueAsDateGetter("time", timeInput, [
|
||||
["", null],
|
||||
["24:00", null],
|
||||
["00:60", null],
|
||||
["00:00", new Date("1970-01-01T00:00:00.000Z")],
|
||||
["12:00", new Date("1970-01-01T12:00:00.000Z")],
|
||||
["23:59", new Date("1970-01-01T23:59:00.000Z")]
|
||||
]);
|
||||
testValueAsDateSetter("time", timeInput, [
|
||||
[new Date("1970-01-01T00:00:00.000Z"), "00:00"],
|
||||
[new Date("1970-01-01T12:00:00.000Z"), "12:00"],
|
||||
[new Date("1970-01-01T23:59:00.000Z"), "23:59"]
|
||||
]);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,146 @@
|
|||
<!DOCTYPE HTML>
|
||||
<meta charset="utf-8">
|
||||
<html>
|
||||
<head>
|
||||
<title>HTMLInputElement valueAsNumber</title>
|
||||
<link rel="author" title="pmdartus" href="mailto:dartus.pierremarie@gmail.com">
|
||||
<link rel=help href="https://html.spec.whatwg.org/#dom-input-valueasnumber">
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h3>input_valueAsNumber</h3>
|
||||
<hr>
|
||||
<div id="log"></div>
|
||||
|
||||
<input id="input_date" type="date" />
|
||||
<input id="input_month" type="month" />
|
||||
<input id="input_week" type="week" />
|
||||
<input id="input_time" type="time" />
|
||||
<input id="input_datetime-local" type="datetime-local" />
|
||||
<input id="input_number" type="number" />
|
||||
<input id="input_range" type="range" min="0" max="100" />
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
function testValueAsNumberGetter(type, element, cases) {
|
||||
for (const [value, expectedValueAsNumber] of cases) {
|
||||
test(
|
||||
() => {
|
||||
element.value = value;
|
||||
assert_equals(element.valueAsNumber, expectedValueAsNumber);
|
||||
},
|
||||
`valueAsNumber getter on type ${type} (actual value: ${value}, ` +
|
||||
`expected valueAsNumber: ${expectedValueAsNumber})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function testValueAsNumberSetter(type, element, cases) {
|
||||
for (const [valueAsNumber, expectedValue] of cases) {
|
||||
test(
|
||||
() => {
|
||||
element.valueAsNumber = valueAsNumber;
|
||||
assert_equals(element.value, expectedValue);
|
||||
},
|
||||
`valueAsNumber setter on type ${type} (actual valueAsNumber: ${valueAsNumber}, ` +
|
||||
`expected value: ${expectedValue})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const dateInput = document.getElementById("input_date");
|
||||
testValueAsNumberGetter("date", dateInput, [
|
||||
["", NaN],
|
||||
["0000-12-10", NaN],
|
||||
["2019-00-12", NaN],
|
||||
["2019-12-00", NaN],
|
||||
["2019-13-10", NaN],
|
||||
["2019-02-29", NaN],
|
||||
["2019-12-10", 1575936000000],
|
||||
["2016-02-29", 1456704000000] // Leap year
|
||||
]);
|
||||
testValueAsNumberSetter("date", dateInput, [
|
||||
[0, "1970-01-01"],
|
||||
[1575936000000, "2019-12-10"],
|
||||
[1456704000000, "2016-02-29"] // Leap year
|
||||
]);
|
||||
|
||||
const monthInput = document.getElementById("input_month");
|
||||
testValueAsNumberGetter("month", monthInput, [
|
||||
["", NaN],
|
||||
["0000-12", NaN],
|
||||
["2019-00", NaN],
|
||||
["2019-12", 599]
|
||||
]);
|
||||
testValueAsNumberSetter("month", monthInput, [[599, "2019-12"]]);
|
||||
|
||||
const weekInput = document.getElementById("input_week");
|
||||
testValueAsNumberGetter("week", weekInput, [
|
||||
["", NaN],
|
||||
["0000-W50", NaN],
|
||||
["2019-W00", NaN],
|
||||
["2019-W60", NaN],
|
||||
["2019-W50", 1575849600000]
|
||||
]);
|
||||
testValueAsNumberSetter("week", weekInput, [
|
||||
[0, "1970-W01"],
|
||||
[1575849600000, "2019-W50"]
|
||||
]);
|
||||
|
||||
const timeInput = document.getElementById("input_time");
|
||||
testValueAsNumberGetter("time", timeInput, [
|
||||
["", NaN],
|
||||
["24:00", NaN],
|
||||
["00:60", NaN],
|
||||
["00:00", 0],
|
||||
["12:00", 12 * 3600 * 1000],
|
||||
["23:59", ((23 * 3600) + (59 * 60)) * 1000]
|
||||
]);
|
||||
testValueAsNumberSetter("time", timeInput, [
|
||||
[0, "00:00"],
|
||||
[12 * 3600 * 1000, "12:00"],
|
||||
[((23 * 3600) + (59 * 60)) * 1000, "23:59"]
|
||||
]);
|
||||
|
||||
const dateTimeLocalInput = document.getElementById("input_datetime-local");
|
||||
testValueAsNumberGetter("datetime-local", dateTimeLocalInput, [
|
||||
["", NaN],
|
||||
["2019-12-10T00:00", 1575936000000],
|
||||
["2019-12-10T12:00", 1575979200000]
|
||||
]);
|
||||
testValueAsNumberSetter("datetime-local", dateTimeLocalInput, [
|
||||
[1575936000000, "2019-12-10T00:00"],
|
||||
[1575979200000, "2019-12-10T12:00"]
|
||||
]);
|
||||
|
||||
const numberInput = document.getElementById("input_number");
|
||||
testValueAsNumberGetter("number", numberInput, [
|
||||
["", NaN],
|
||||
["123", 123],
|
||||
["123.456", 123.456]
|
||||
]);
|
||||
testValueAsNumberSetter("number", numberInput, [
|
||||
[123, "123"],
|
||||
[123.456, "123.456"]
|
||||
]);
|
||||
|
||||
const rangeInput = document.getElementById("input_range");
|
||||
testValueAsNumberGetter("range", rangeInput, [
|
||||
["", 50],
|
||||
["0", 0],
|
||||
["50", 50],
|
||||
["100", 100],
|
||||
["-10", 0], // Realign to the min
|
||||
["110", 100] // Realign to the max
|
||||
]);
|
||||
testValueAsNumberSetter("range", rangeInput, [
|
||||
[0, "0"],
|
||||
[50, "50"],
|
||||
[100, "100"]
|
||||
]);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -174,4 +174,34 @@
|
|||
assert_true(radio71.checked, "canceled click event on radio should leave the previously-checked radio checked");
|
||||
assert_false(radio72.checked, "canceled click event on previously-unchecked radio should leave that radio unchecked");
|
||||
});
|
||||
|
||||
test(() => {
|
||||
const container = document.createElement('div');
|
||||
container.innerHTML =
|
||||
'<input type=radio name=n1><span><input type=radio name=n1 checked></span>' +
|
||||
'<form><input type=radio name=n1 checked></form>';
|
||||
const radios = container.querySelectorAll('input');
|
||||
assert_false(radios[0].checked, 'Sanity check: The first radio should be unchecked');
|
||||
assert_true(radios[1].checked, 'Sanity check: The second radio should be checked');
|
||||
assert_true(radios[2].checked, 'Sanity check: The third radio should be checked');
|
||||
|
||||
radios[0].checked = true;
|
||||
assert_true(radios[0].checked, 'The first radio should be checked after setting checked');
|
||||
assert_false(radios[1].checked, 'The second radio should be unchecked after setting checked');
|
||||
assert_true(radios[2].checked, 'The third radio should be checked after setting checked');
|
||||
|
||||
radios[1].required = true;
|
||||
assert_false(radios[0].validity.valueMissing, 'The first radio should be valid');
|
||||
assert_false(radios[1].validity.valueMissing, 'The second radio should be valid');
|
||||
assert_false(radios[2].validity.valueMissing, 'The third radio should be valid');
|
||||
|
||||
radios[0].remove();
|
||||
assert_false(radios[0].validity.valueMissing, 'The first radio should be valid because of no required');
|
||||
assert_true(radios[1].validity.valueMissing, 'The second radio should be invalid***');
|
||||
assert_false(radios[2].validity.valueMissing, 'The third radio should be valid');
|
||||
|
||||
radios[0].required = true;
|
||||
radios[0].checked = false;
|
||||
assert_true(radios[0].validity.valueMissing, 'The first radio should be invalid because of required');
|
||||
}, 'Radio buttons in an orphan tree should make a group');
|
||||
</script>
|
||||
|
|
|
@ -302,4 +302,31 @@ test(function() {
|
|||
input.value = "foo\r\r\n\n\0";
|
||||
assert_equals(input.value, "#000000");
|
||||
}, "value IDL attribute of input type color with value attribute");
|
||||
|
||||
// MODE FILENAME
|
||||
test(function () {
|
||||
var input = document.createElement("input");
|
||||
input.type = "file";
|
||||
|
||||
for (const emptyValue of ["", null]) {
|
||||
input.value = emptyValue;
|
||||
assert_equals(input.value, "", `input.value is empty after assigning ${emptyValue}`);
|
||||
}
|
||||
|
||||
for (const invalidValue of ["foo", 10, undefined]) {
|
||||
assert_throws("InvalidStateError", () => {
|
||||
input.value = invalidValue;
|
||||
});
|
||||
assert_equals(input.value, "", `input.value is empty after assigning ${invalidValue}`);
|
||||
}
|
||||
}, "value IDL attribute of input type file without value attribute");
|
||||
test(function() {
|
||||
var input = document.createElement("input");
|
||||
input.type = "file";
|
||||
input.setAttribute("value", "bar");
|
||||
assert_equals(input.value, "", "input.value is empty even with a value attribute");
|
||||
|
||||
input.value = "";
|
||||
assert_equals(input.getAttribute("value"), "bar", "Setting input.value does not change the value attribute");
|
||||
}, "value IDL attribute of input type file with value attribute");
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue