mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Update web-platform-tests to revision 66c4613f823c4384c78ada77346eda17bb128947
This commit is contained in:
parent
183772583f
commit
a91433f0c8
234 changed files with 4368 additions and 967 deletions
|
@ -24,21 +24,21 @@ var testElements = [
|
|||
},
|
||||
{
|
||||
tag: "input",
|
||||
types: ["datetime"],
|
||||
types: ["datetime-local"],
|
||||
testData: [
|
||||
{conditions: {value: ""}, expected: false, name: "[target] The value attribute is empty"},
|
||||
{conditions: {value: "2000-01-01T12:00:00Z"}, expected: false, name: "[target] The value attribute is a valid date and time string"},
|
||||
{conditions: {value: "abc"}, expected: true, name: "[target] The value attribute cannot convert to a valid normalized forced-UTC global date and time string"}
|
||||
{conditions: {value: "2000-01-01T12:00:00"}, expected: false, name: "[target] The value attribute is a valid date and time string"},
|
||||
{conditions: {value: "abc"}, expected: false, name: "[target] The value attribute cannot convert to a valid normalized forced-UTC global date and time string"}
|
||||
]
|
||||
},
|
||||
{
|
||||
tag: "input",
|
||||
types: ["color"],
|
||||
testData: [
|
||||
{conditions: {value: ""}, expected: true, name: "[target] The value attribute is empty"},
|
||||
{conditions: {value: ""}, expected: false, name: "[target] The value attribute is empty"},
|
||||
{conditions: {value: "#000000"}, expected: false, name: "[target] The value attribute is a valid sample color"},
|
||||
{conditions: {value: "#FFFFFF"}, expected: false, name: "[target] The value attribute is not a valid lowercase sample color"},
|
||||
{conditions: {value: "abc"}, expected: true, name: "[target] The value attribute cannot convert to a valid sample color"}
|
||||
{conditions: {value: "abc"}, expected: false, name: "[target] The value attribute cannot convert to a valid sample color"}
|
||||
]
|
||||
},
|
||||
];
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<title>The selection interface members</title>
|
||||
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#textFieldSelection">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var valid = ["text", "search", "url", "tel", "password"];
|
||||
var invalid = ["hidden", "datetime", "date", "month", "week", "datetime-local",
|
||||
"number", "range", "color", "checkbox", "radio", "button",
|
||||
"file", "email", "submit", "image", "reset"];
|
||||
valid.forEach(function(aType) {
|
||||
test(function() {
|
||||
var input = document.createElement("input");
|
||||
input.type = aType;
|
||||
assert_equals(input.type, aType, "Input type unsupported")
|
||||
input.select();
|
||||
var a = input.selectionStart;
|
||||
input.selectionStart = 0;
|
||||
a = input.selectionEnd;
|
||||
input.selectionEnd = 0;
|
||||
input.setSelectionRange(0, 0);
|
||||
}, "Selection attributes should apply to type " + aType)
|
||||
})
|
||||
|
||||
invalid.forEach(function(aType) {
|
||||
test(function() {
|
||||
var input = document.createElement("input");
|
||||
input.type = aType;
|
||||
assert_equals(input.type, aType, "Input type unsupported")
|
||||
assert_throws("INVALID_STATE_ERR", function() { input.select(); }, "Should throw with type " + aType);
|
||||
assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionStart; });
|
||||
assert_throws("INVALID_STATE_ERR", function() { input.selectionStart = 0; });
|
||||
assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionEnd; });
|
||||
assert_throws("INVALID_STATE_ERR", function() { input.selectionEnd = 0; });
|
||||
assert_throws("INVALID_STATE_ERR", function() { input.setSelectionRange(0, 0); });
|
||||
}, "Selection attributes should not apply to type " + aType)
|
||||
})
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,131 @@
|
|||
<!DOCTYPE HTML>
|
||||
<title>Input element programmatic selection support</title>
|
||||
<link rel="author" title="yaycmyk" href="mailto:evan@yaycmyk.com">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/forms.html#dom-textarea/input-select">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
|
||||
/* all textual, non-hidden inputs support .select() */
|
||||
test(function() {
|
||||
var valid = [
|
||||
"text",
|
||||
"search",
|
||||
"url",
|
||||
"tel",
|
||||
"email",
|
||||
"password",
|
||||
"date",
|
||||
"month",
|
||||
"week",
|
||||
"time",
|
||||
"datetime-local",
|
||||
"number",
|
||||
"color",
|
||||
"file",
|
||||
];
|
||||
|
||||
var invalid = [
|
||||
"hidden",
|
||||
"range",
|
||||
"checkbox",
|
||||
"radio",
|
||||
"submit",
|
||||
"image",
|
||||
"reset",
|
||||
"button"
|
||||
];
|
||||
|
||||
valid.forEach(function(type) {
|
||||
test(function() {
|
||||
var input = document.createElement("input");
|
||||
var a;
|
||||
|
||||
input.type = type;
|
||||
assert_equals(input.type, type, "the given input type is not supported");
|
||||
|
||||
input.select();
|
||||
|
||||
}, "input type " + type + " should support the select() method");
|
||||
});
|
||||
|
||||
invalid.forEach(function(type) {
|
||||
test(function() {
|
||||
var input = document.createElement("input");
|
||||
|
||||
input.type = type;
|
||||
assert_equals(input.type, type, "the given input type is not supported");
|
||||
|
||||
assert_throws("INVALID_STATE_ERR", function() { input.select(); });
|
||||
|
||||
}, "input type " + type + " should not support the select() method");
|
||||
});
|
||||
});
|
||||
|
||||
/* only certain input types are allowed to have a variable-length selection */
|
||||
test(function() {
|
||||
var valid = [
|
||||
"text",
|
||||
"search",
|
||||
"url",
|
||||
"tel",
|
||||
"password"
|
||||
];
|
||||
|
||||
var invalid = [
|
||||
"hidden",
|
||||
"email",
|
||||
"date",
|
||||
"month",
|
||||
"week",
|
||||
"time",
|
||||
"datetime-local",
|
||||
"number",
|
||||
"range",
|
||||
"color",
|
||||
"checkbox",
|
||||
"radio",
|
||||
"file",
|
||||
"submit",
|
||||
"image",
|
||||
"reset",
|
||||
"button"
|
||||
];
|
||||
|
||||
valid.forEach(function(type) {
|
||||
test(function() {
|
||||
var input = document.createElement("input");
|
||||
var a;
|
||||
|
||||
input.type = type;
|
||||
assert_equals(input.type, type, "the given input type is not supported");
|
||||
|
||||
a = input.selectionStart;
|
||||
input.selectionStart = 0;
|
||||
a = input.selectionEnd;
|
||||
input.selectionEnd = 0;
|
||||
input.setSelectionRange(0, 0);
|
||||
input.setRangeText('', 0, 0);
|
||||
|
||||
}, "input type " + type + " should support all selection attributes and methods");
|
||||
});
|
||||
|
||||
invalid.forEach(function(type) {
|
||||
test(function() {
|
||||
var input = document.createElement("input");
|
||||
|
||||
input.type = type;
|
||||
assert_equals(input.type, type, "the given input type is not supported");
|
||||
|
||||
assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionStart; });
|
||||
assert_throws("INVALID_STATE_ERR", function() { input.selectionStart = 0; });
|
||||
assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionEnd; });
|
||||
assert_throws("INVALID_STATE_ERR", function() { input.selectionEnd = 0; });
|
||||
assert_throws("INVALID_STATE_ERR", function() { input.setSelectionRange(0, 0); });
|
||||
assert_throws("INVALID_STATE_ERR", function() { input.setRangeText('', 0, 0); });
|
||||
|
||||
}, "input type " + type + " should not support variable-length selections");
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -32,8 +32,11 @@ test(function() {
|
|||
|
||||
assert_equals(template.ownerDocument, doc.body.ownerDocument,
|
||||
'Wrong template node owner document');
|
||||
assert_equals(template.content.ownerDocument, doc,
|
||||
'Wrong template content owner document');
|
||||
var ownerDoc = template.content.ownerDocument;
|
||||
assert_not_equals(ownerDoc, doc, 'Wrong template content owner document');
|
||||
assert_not_equals(ownerDoc, document, 'Wrong template content owner document');
|
||||
assert_equals(ownerDoc.defaultView, null,
|
||||
'Template content owner document should not have a browsing context');
|
||||
|
||||
}, 'Parsing XHTML: Node\'s node document must be set to that of the element '
|
||||
+ 'to which it will be appended. Test empty template');
|
||||
|
|
|
@ -22,6 +22,13 @@ function templateIsAChild(element) {
|
|||
'Template element should be a descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
function templateIsDisallowedAsAChild(element) {
|
||||
element.innerHTML = '<template>some text</template>';
|
||||
|
||||
assert_equals(element.querySelector('template'), null,
|
||||
'Template element should not be allowed as a descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
function templateIsAnIndirectChild(element) {
|
||||
element.innerHTML = '<div><template>some text</template></div>';
|
||||
|
||||
|
@ -29,6 +36,13 @@ function templateIsAnIndirectChild(element) {
|
|||
'Template element should be a descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
function templateIsDisallowedAsAnIndirectChild(element) {
|
||||
element.innerHTML = '<div><template>some text</template></div>';
|
||||
|
||||
assert_equals(element.querySelector('template'), null,
|
||||
'Template element should not be allowed as indirect descendant of the ' + element.tagName + ' element');
|
||||
}
|
||||
|
||||
function templateIsAnAppendedChild(doc, element) {
|
||||
var template = doc.createElement('template');
|
||||
|
||||
|
@ -58,13 +72,16 @@ var parameters = [['Template element as a descendant of the BODY element. ' +
|
|||
['Template element as a descendant of the HEAD element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
doc.head],
|
||||
['Template element as a descendant of the FRAMESET element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
frameset]
|
||||
];
|
||||
generate_tests(templateIsAChild, parameters,
|
||||
'Template element as a descendant of the HEAD, BODY and FRAMESET elements');
|
||||
'Template element as a descendant of the HEAD and BODY elements');
|
||||
|
||||
parameters = [['Template element as a descendant of the FRAMESET element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
frameset],
|
||||
];
|
||||
generate_tests(templateIsDisallowedAsAChild, parameters,
|
||||
'Template element should be disallowed as a descendant of the FRAMESET elements');
|
||||
|
||||
|
||||
parameters = [['Template element as an indirect descendant of the BODY element. ' +
|
||||
|
@ -73,13 +90,17 @@ parameters = [['Template element as an indirect descendant of the BODY element.
|
|||
['Template element as an indirect descendant of the HEAD element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
doc.head],
|
||||
['Template element as an indirect descendant of the FRAMESET element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
frameset]
|
||||
];
|
||||
generate_tests(templateIsAnIndirectChild, parameters,
|
||||
'Template element as an indirect descendant of the HEAD, BODY and FRAMESET elements');
|
||||
|
||||
parameters = [['Template element as a descendant of the FRAMESET element. ' +
|
||||
'Template element is created by innerHTML',
|
||||
frameset],
|
||||
];
|
||||
generate_tests(templateIsDisallowedAsAnIndirectChild, parameters,
|
||||
'Template element should be disallowed as an indirect descendant of the FRAMESET elements');
|
||||
|
||||
|
||||
|
||||
parameters = [['Template element as a descendant of the BODY element. ' +
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Selector: pseudo-classes (:focus for autofocus)</title>
|
||||
<link rel="author" title="Kent Tamura" href="mailto:tkent@chromium.org">
|
||||
<link rel=help href="https://html.spec.whatwg.org/multipage/#pseudo-classes">
|
||||
<link rel=help href="https://html.spec.whatwg.org/multipage/forms.html#autofocusing-a-form-control:-the-autofocus-attribute">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<script>
|
||||
// This test can't be merged to focus.html because element.focus() may affect
|
||||
// autofocus behavior.
|
||||
var autofocusTest = async_test(":focus selector should work with an autofocused element.");
|
||||
var input = document.createElement("input");
|
||||
input.autofocus = true;
|
||||
input.addEventListener("focus", function() {
|
||||
autofocusTest.step(function() {
|
||||
assert_array_equals(document.querySelectorAll(":focus"), [input])
|
||||
autofocusTest.done();
|
||||
});
|
||||
}, false);
|
||||
document.body.appendChild(input);
|
||||
</script>
|
||||
</body>
|
|
@ -11,7 +11,6 @@
|
|||
<button id=button1 type=submit>button1</button>
|
||||
<input id=input1>
|
||||
<input id=input2 disabled>
|
||||
<input id=input3 autofocus>
|
||||
<textarea id=textarea1>textarea1</textarea>
|
||||
<input type=checkbox id=checkbox1 checked>
|
||||
<input type=radio id=radio1 checked>
|
||||
|
@ -20,8 +19,6 @@
|
|||
<iframe src="focus-iframe.html" id=iframe onload="load()"></iframe>
|
||||
|
||||
<script>
|
||||
testSelector(":focus", ["input3"], "input3 has the attribute autofocus");
|
||||
|
||||
document.getElementById("input1").focus(); // set the focus on input1
|
||||
testSelector(":focus", ["input1"], "input1 has the focus");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue