mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
|
@ -69,6 +69,25 @@
|
|||
var address = document.location.href;
|
||||
assert_equals(formAction, address);
|
||||
}, "Check if input.formAction is the document's address when formaction content attribute value is not assigned");
|
||||
|
||||
var newUrl = location.href.replace(/\/[^\/]*$/,'\/dummy.html');
|
||||
history.pushState('','','dummy.html');
|
||||
|
||||
test(function() {
|
||||
assert_equals(document.location.href, newUrl);
|
||||
|
||||
var formAction = document.querySelector('#missing button').formAction;
|
||||
var address = document.location.href;
|
||||
assert_equals(formAction, address);
|
||||
}, "Check if button.formAction is the document's new address when formaction content attribute is missing and pushState has been used");
|
||||
|
||||
test(function() {
|
||||
assert_equals(document.location.href, newUrl);
|
||||
|
||||
var formAction = document.querySelector('#missing input').formAction;
|
||||
var address = document.location.href;
|
||||
assert_equals(formAction, address);
|
||||
}, "Check if input.formAction is the document's new address when formaction content attribute is missing and pushState has been used");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
test(() => {
|
||||
const form = document.createElement("form"),
|
||||
input = document.createElement("input");
|
||||
|
||||
form.appendChild(input);
|
||||
assert_equals(input.form, form);
|
||||
}, "Ensure input and form get associated when not in a document");
|
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<table><form><tr><td><input></table>
|
||||
<div id=2></div>
|
||||
<script>
|
||||
test(() => {
|
||||
const input = document.querySelector("input"),
|
||||
form = document.querySelector("form");
|
||||
assert_equals(input.form, form);
|
||||
document.getElementById("2").appendChild(form.parentNode);
|
||||
assert_equals(input.form, form);
|
||||
document.getElementById("2").appendChild(input);
|
||||
assert_equals(input.form, null);
|
||||
}, "parser inserted flag is not reset by insertions with the owner form, but reset by by removal from the owner form");
|
||||
</script>
|
|
@ -0,0 +1,62 @@
|
|||
async_test(t => {
|
||||
const frame = document.createElement("frame"),
|
||||
form = document.createElement("form");
|
||||
t.add_cleanup(() => frame.remove());
|
||||
form.action = "/common/blank.html";
|
||||
form.target = "doesnotmattertwobits";
|
||||
frame.name = "doesnotmattertwobits";
|
||||
document.body.appendChild(frame);
|
||||
frame.onload = t.step_func(() => {
|
||||
if(frame.contentWindow.location.href === "about:blank")
|
||||
return;
|
||||
assert_unreached();
|
||||
});
|
||||
form.submit();
|
||||
t.step_timeout(() => {
|
||||
assert_equals(frame.contentWindow.location.href, "about:blank");
|
||||
t.done();
|
||||
}, 500);
|
||||
}, "<form> not connected to a document cannot navigate");
|
||||
|
||||
async_test(t => {
|
||||
const frame = document.createElement("frame"),
|
||||
form = document.createElement("form");
|
||||
t.add_cleanup(() => frame.remove());
|
||||
form.action = "/common/blank.html";
|
||||
form.target = "doesnotmattertwoqbits";
|
||||
form.onsubmit = t.step_func(() => form.remove());
|
||||
frame.name = "doesnotmattertwoqbits";
|
||||
document.body.appendChild(frame);
|
||||
document.body.appendChild(form);
|
||||
frame.onload = t.step_func(() => {
|
||||
if(frame.contentWindow.location.href === "about:blank")
|
||||
return;
|
||||
assert_unreached();
|
||||
});
|
||||
const submit = form.appendChild(document.createElement("input"));
|
||||
submit.type = "submit"
|
||||
submit.click();
|
||||
t.step_timeout(() => {
|
||||
assert_equals(frame.contentWindow.location.href, "about:blank");
|
||||
t.done();
|
||||
}, 500);
|
||||
}, "<form> not connected to a document after submit event cannot navigate");
|
||||
|
||||
async_test(t => {
|
||||
const frame = document.createElement("frame"),
|
||||
form = document.createElement("form");
|
||||
t.add_cleanup(() => frame.remove());
|
||||
form.action = "/";
|
||||
document.body.appendChild(frame);
|
||||
frame.contentDocument.body.appendChild(form);
|
||||
frame.onload = t.step_func(() => {
|
||||
if(frame.contentWindow.location.href === "about:blank")
|
||||
return;
|
||||
form.submit();
|
||||
t.step_timeout(() => {
|
||||
assert_equals(frame.contentWindow.location.pathname, "/common/blank.html");
|
||||
t.done();
|
||||
}, 500)
|
||||
});
|
||||
frame.src = "/common/blank.html";
|
||||
}, "<form> in a navigated document cannot navigate");
|
|
@ -92,4 +92,27 @@ for (var data of elemData) {
|
|||
}, `value dirty flag behavior after setRangeText on ${data.desc}`);
|
||||
}
|
||||
|
||||
for (var tag of ['input', 'textarea']) {
|
||||
test(function() {
|
||||
var el = document.createElement(tag);
|
||||
document.body.appendChild(el);
|
||||
this.add_cleanup(() => el.remove());
|
||||
el.value = "";
|
||||
assert_equals(el.selectionStart, el.value.length,
|
||||
"element.selectionStart should be value.length");
|
||||
assert_equals(el.selectionEnd, el.value.length,
|
||||
"element.selectionEnd should be value.length");
|
||||
el.value = "foo";
|
||||
assert_equals(el.selectionStart, el.value.length,
|
||||
"element.selectionStart should be value.length");
|
||||
assert_equals(el.selectionEnd, el.value.length,
|
||||
"element.selectionEnd should be value.length");
|
||||
el.value = "foobar";
|
||||
assert_equals(el.selectionStart, el.value.length,
|
||||
"element.selectionStart should be value.length");
|
||||
assert_equals(el.selectionEnd, el.value.length,
|
||||
"element.selectionEnd should be value.length");
|
||||
}, `selection is always collapsed to the end after setting values on ${tag}`);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>button_checkValidity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><button id='button_id'>button</button></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var button = document.getElementById("button_id");
|
||||
|
||||
try
|
||||
{
|
||||
var ret = button.checkValidity();
|
||||
|
||||
test(function() {
|
||||
assert_equals(ret, true, "calling of checkValidity method is failed.");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
test(function() {
|
||||
assert_unreached("autofocus attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,48 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>button_labels</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><label>Full name:<label>(name)<button id='button_id1'>button1</button><small>Format: First Last</small></label></label></p>
|
||||
<p><label>Age: <button id='button_id2'>button2</button></label></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var button1 = document.getElementById("button_id1");
|
||||
var button2 = document.getElementById("button_id2");
|
||||
|
||||
if (typeof(button1.labels) == "object") {
|
||||
if (button1.labels.length == 2 && button2.labels.length == 1) {
|
||||
test(function() {
|
||||
assert_true(true, "labels attribute is correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("labels attribute is not correct.");
|
||||
});
|
||||
}
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("labels attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>button_setCustomValidity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><button id='button_id'>button</button></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var button = document.getElementById("button_id");
|
||||
|
||||
try
|
||||
{
|
||||
button.setCustomValidity("custom error");
|
||||
test(function() {
|
||||
assert_true(true, "calling of setCustomValidity method is successed.");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
test(function() {
|
||||
assert_unreached("Error is raised.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>button_validationMessage</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><button id='button_id'>button</button></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var button = document.getElementById("button_id");
|
||||
|
||||
if (typeof(button.validationMessage) == "string") {
|
||||
test(function() {
|
||||
assert_equals(button.validationMessage, "", "validationMessage attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("validationMessage attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>button_validity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><button id='button_id'>button</button></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var button = document.getElementById("button_id");
|
||||
|
||||
if (typeof(button.validity) == "object") {
|
||||
test(function() {
|
||||
assert_equals(button.validity.valueMissing, false, "validity attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("validity attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>button_willValidate</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><button id='button_id'>button</button></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var button = document.getElementById("button_id");
|
||||
|
||||
if (typeof(button.willValidate) == "boolean") {
|
||||
test(function() {
|
||||
assert_equals(button.willValidate, true, "willValidate attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("willValidate attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>FieldSet_checkValidity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<fieldset id="input_field">
|
||||
</fieldset>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var field = document.getElementById("input_field");
|
||||
|
||||
try
|
||||
{
|
||||
var ret = field.checkValidity();
|
||||
|
||||
test(function() {
|
||||
assert_equals(ret, true, "calling of checkValidity method is failed.");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
test(function() {
|
||||
assert_unreached("Error is raised.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>FieldSet_setCustomValidity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<fieldset id="input_field">
|
||||
</fieldset>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var field = document.getElementById("input_field");
|
||||
|
||||
try
|
||||
{
|
||||
field.setCustomValidity("custom error");
|
||||
test(function() {
|
||||
assert_true(true, "calling of setCustomValidity method is successed.");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
test(function() {
|
||||
assert_unreached("Error is raised.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>FieldSet_validationMessage</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<fieldset id="input_field">
|
||||
</fieldset>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var field = document.getElementById("input_field");
|
||||
|
||||
if (typeof(field.validationMessage) == "string") {
|
||||
test(function() {
|
||||
assert_equals(field.validationMessage, "", "validationMessage attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("validationMessage attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>FieldSet_validity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<fieldset id="input_field">
|
||||
</fieldset>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var field = document.getElementById("input_field");
|
||||
|
||||
if (typeof(field.validity) == "object") {
|
||||
test(function() {
|
||||
assert_equals(field.validity.valueMissing, false, "validity attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("validity attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>FieldSet_willValidate</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<fieldset id="input_field">
|
||||
</fieldset>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var field = document.getElementById("input_field");
|
||||
|
||||
if (typeof(field.willValidate) == "boolean") {
|
||||
test(function() {
|
||||
assert_equals(field.willValidate, false, "willValidate attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("willValidate attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>Form_action</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action="http://www.google.com/"
|
||||
id="input_form">
|
||||
<p><input type=hidden name="custname"></p>
|
||||
<p><input type=hidden name="custtel"></p>
|
||||
<p><input type=hidden name="custemail"></p>
|
||||
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var form = document.getElementById("input_form");
|
||||
|
||||
if (typeof(form.action) == "string") {
|
||||
test(function() {
|
||||
assert_equals(form.action, "http://www.google.com/", "action attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("action attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,47 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>Form_checkValidity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><input type=hidden name="custname"></p>
|
||||
<p><input type=hidden name="custtel"></p>
|
||||
<p><input type=hidden name="custemail"></p>
|
||||
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var form = document.getElementById("input_form");
|
||||
|
||||
try
|
||||
{
|
||||
var ret = form.checkValidity();
|
||||
|
||||
test(function() {
|
||||
assert_equals(ret, true, "calling of checkValidity method is failed.");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
test(function() {
|
||||
assert_unreached("Error is raised.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -159,6 +159,11 @@
|
|||
<meter id="after-unassociated-meter1"></meter>
|
||||
<progress id="after-unassociated-progress1"></progress>
|
||||
|
||||
<form id="form2">
|
||||
<span id="shadow-1"></span>
|
||||
</form>
|
||||
<span id="shadow-2"></span>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
test(() => {
|
||||
|
@ -169,4 +174,19 @@ test(() => {
|
|||
|
||||
assert_array_equals(ids, allCorrectIDs);
|
||||
});
|
||||
|
||||
test(() => {
|
||||
const shadowRoot1 = document.querySelector("#shadow-1").attachShadow({mode: "open"});
|
||||
const input1 = document.createElement("input");
|
||||
shadowRoot1.appendChild(input1);
|
||||
|
||||
const shadowRoot2 = document.querySelector("#shadow-2").attachShadow({mode: "open"});
|
||||
const input2 = document.createElement("input");
|
||||
input2.setAttribute("form", "form2");
|
||||
shadowRoot2.appendChild(input2);
|
||||
|
||||
assert_equals(document.querySelector("#form2").elements.length, 0);
|
||||
assert_equals(input1.form, null);
|
||||
assert_equals(input2.form, null);
|
||||
}, "form.elements only includes elements from the same shadow tree");
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>Form_length</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><input type=hidden name="custname"></p>
|
||||
<p><input type=hidden name="custtel"></p>
|
||||
<p><input type=hidden name="custemail"></p>
|
||||
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var form = document.getElementById("input_form");
|
||||
var len = form.length;
|
||||
|
||||
test(function() {
|
||||
assert_equals(len, 3, "length attribute is not correct.");
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -31,9 +31,14 @@ var types = [
|
|||
|
||||
types.forEach(function(type) {
|
||||
test(function() {
|
||||
var input = document.createElement("input");
|
||||
const input = document.createElement("input"),
|
||||
input2 = document.createElement("input");
|
||||
input.type = type;
|
||||
input2.type = "file";
|
||||
assert_equals(input.files, null, "files should be null");
|
||||
|
||||
input.files = input2.files;
|
||||
assert_equals(input.files, null, "files should remain null as it cannot be set when it does not apply");
|
||||
}, "files for input type=" + type);
|
||||
});
|
||||
|
||||
|
@ -45,4 +50,22 @@ test(function() {
|
|||
var files = input.files;
|
||||
assert_equals(input.files, files, "files should return the same object");
|
||||
}, "files for input type=file");
|
||||
|
||||
test(() => {
|
||||
const i1 = document.createElement("input"),
|
||||
i2 = document.createElement("input");
|
||||
i1.type = "file";
|
||||
i2.type = "file";
|
||||
|
||||
const files = i2.files;
|
||||
i1.files = i2.files;
|
||||
assert_equals(i1.files, files, "FileList should not be copied");
|
||||
assert_equals(i2.files, files, "FileList can be shared across input elements");
|
||||
|
||||
i1.files = null;
|
||||
assert_equals(i1.files, files, "files cannot be set to null");
|
||||
|
||||
assert_throws(new TypeError(), () => i1.files = [], "files cannot be set to an array");
|
||||
assert_throws(new TypeError(), () => i1.files = [new File([], "x")], "files cannot be set to an array (even when it contains File objects)");
|
||||
}, "setting <input type=file>.files");
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_checkValidity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><input type='hidden' id='input_text'></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var input = document.getElementById("input_text");
|
||||
|
||||
try
|
||||
{
|
||||
var ret = input.checkValidity();
|
||||
|
||||
test(function() {
|
||||
assert_equals(ret, true, "calling of checkValidity method is failed.");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
test(function() {
|
||||
assert_unreached("Error is raised.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_height</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
name="input_form">
|
||||
<p><input type='image' id='input_text'></p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
var input_text = document.getElementById("input_text");
|
||||
input_text.height = 30;
|
||||
|
||||
if (typeof(input_text.height) == "number") {
|
||||
test(function() {
|
||||
assert_equals(input_text.height, 30, "formTarget attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("height attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_labels</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><label>Full name:<label>(name)<input name=fn id='input_text1'> <small>Format: First Last</small></label></label></p>
|
||||
<p><label>Age: <input name=age type=number min=0 id='input_text2'></label></p>
|
||||
<p><label>Post code: <input name=pc> <small>Format: AB12 3CD</small></label></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var input1 = document.getElementById("input_text1");
|
||||
var input2 = document.getElementById("input_text2");
|
||||
|
||||
if (typeof(input1.labels) == "object") {
|
||||
if (input1.labels.length == 2 && input2.labels.length == 1) {
|
||||
test(function() {
|
||||
assert_true(true, "labels attribute is correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("labels attribute is not correct.");
|
||||
});
|
||||
}
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("labels attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_setCustomValidity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><input type='hidden' id='input_text'></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var input = document.getElementById("input_text");
|
||||
|
||||
try
|
||||
{
|
||||
input.setCustomValidity("custom error");
|
||||
test(function() {
|
||||
assert_true(true, "calling of setCustomValidity method is successed.");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
test(function() {
|
||||
assert_unreached("Error is raised.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,44 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_stepDown</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
name="input_form">
|
||||
<p><input type='number' id='input_number'></p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var input_number = document.getElementById("input_number");
|
||||
input_number.max = "30";
|
||||
input_number.step = "3";
|
||||
input_number.value = "30";
|
||||
input_number.stepDown(5);
|
||||
|
||||
if (typeof(input_number.stepDown) == "function") {
|
||||
test(function() {
|
||||
assert_equals(input_number.value, "15", "call of stepDown method is failed.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("stepDown attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_stepUp</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
name="input_form">
|
||||
<p><input type='number' id='input_number'></p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
var input_number = document.getElementById("input_number");
|
||||
input_number.max = "30";
|
||||
input_number.step = "3";
|
||||
input_number.value = "0";
|
||||
input_number.stepUp(5);
|
||||
|
||||
if (typeof(input_number.stepUp) == "function") {
|
||||
test(function() {
|
||||
assert_equals(input_number.value, "15", "call of stepUp method is failed.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("stepUp attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_validationMessage</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><input type='hidden' id='input_text'></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var input = document.getElementById("input_text");
|
||||
|
||||
if (typeof(input.validationMessage) == "string") {
|
||||
test(function() {
|
||||
assert_equals(input.validationMessage, "", "validationMessage attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("validationMessage attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_validity</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><input type='hidden' id='input_text'></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var input = document.getElementById("input_text");
|
||||
|
||||
if (typeof(input.validity) == "object") {
|
||||
test(function() {
|
||||
assert_equals(input.validity.valueMissing, false, "validity attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("validity attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_value_INVALID_STATE_ERR</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
name="input_form">
|
||||
<p><input type='file' id='input_file'></p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
var input_file = document.getElementById("input_file");
|
||||
try {
|
||||
input_file.value = "val";
|
||||
test(function() {
|
||||
assert_unreached("INVALID_STATE_ERR error is not raised.");
|
||||
});
|
||||
} catch (e) {
|
||||
test(function() {
|
||||
assert_equals(e.code, e["INVALID_STATE_ERR"], "INVALID_STATE_ERR error is not raised.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_valueAsDate_INVALID_STATE_ERR</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
name="input_form">
|
||||
<p><input type='checkbox' id='input_checkbox'></p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var input_checkbox = document.getElementById("input_checkbox");
|
||||
try {
|
||||
input_checkbox.valueAsDate = new Date('2011-11-01');
|
||||
test(function() {
|
||||
assert_reached("INVALID_STATE_ERR error is not raised.");
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
test(function() {
|
||||
assert_equals(e.code, e["INVALID_STATE_ERR"], "INVALID_STATE_ERR error is not raised.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_valueAsNumber_INVALID_STATE_ERR</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
name="input_form">
|
||||
<p><input type='checkbox' id='input_checkbox'></p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
var input_checkbox = document.getElementById("input_checkbox");
|
||||
try {
|
||||
input_checkbox.valueAsNumber = 5;
|
||||
}
|
||||
catch (e) {
|
||||
test(function() {
|
||||
assert_equals(e.code, e["INVALID_STATE_ERR"], "INVALID_STATE_ERR error is not raised.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_width</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
name="input_form">
|
||||
<p><input type='image' id='input_text'></p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
var input_text = document.getElementById("input_text");
|
||||
input_text.width = 30;
|
||||
|
||||
if (typeof(input_text.width) == "number") {
|
||||
test(function() {
|
||||
assert_equals(input_text.width, 30, "width attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("width attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Forms</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<h3>input_willValidate</h3>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="log"></div>
|
||||
|
||||
<form method="post"
|
||||
enctype="application/x-www-form-urlencoded"
|
||||
action=""
|
||||
id="input_form">
|
||||
<p><input type='hidden' id='input_text'></p>
|
||||
</form>
|
||||
<script>
|
||||
|
||||
var input = document.getElementById("input_text");
|
||||
|
||||
if (typeof(input.willValidate) == "boolean") {
|
||||
test(function() {
|
||||
assert_equals(input.willValidate, false, "willValidate attribute is not correct.");
|
||||
});
|
||||
} else {
|
||||
test(function() {
|
||||
assert_unreached("willValidate attribute is not exist.");
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<body>
|
||||
<label>
|
||||
<div id="div1"></div>
|
||||
</label>
|
||||
<label for="test13"></label>
|
||||
</body>
|
||||
</html>
|
|
@ -32,10 +32,53 @@
|
|||
|
||||
<label id="lbl5" for="test7"></label>
|
||||
<input id="test7">
|
||||
|
||||
<label id="lbl7">
|
||||
<label id="lbl8">
|
||||
<div id="div1">
|
||||
<input id="test8">
|
||||
</div>
|
||||
</label>
|
||||
</label>
|
||||
<div id="div2"></div>
|
||||
|
||||
<label id="lbl9">
|
||||
<label id="lbl10" for="test10">
|
||||
<div id="div3">
|
||||
<input id="test9">
|
||||
</div>
|
||||
</label>
|
||||
</label>
|
||||
<div id="div4"><input id="test10"></div>
|
||||
|
||||
<label id="lbl11">
|
||||
<object id="obj">
|
||||
<input id="test11">
|
||||
<input id="test12">
|
||||
</object>
|
||||
</label>
|
||||
<label id="lbl12" for="test12"><div id="div5"></div></label>
|
||||
|
||||
<label id="lbl13">
|
||||
<p id="p1">
|
||||
<input id="test13">
|
||||
</p>
|
||||
</label>
|
||||
|
||||
<div id="div6">
|
||||
<div id="div7">
|
||||
<label id="lbl14">
|
||||
<label id="lbl15" for="test15">
|
||||
<input id="test14">
|
||||
</label>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<input id="test15">
|
||||
</form>
|
||||
|
||||
<label id="lbl6" for="test7"></label>
|
||||
|
||||
<div id="content" style="display: none">
|
||||
<script>
|
||||
|
||||
//control attribute
|
||||
|
@ -57,6 +100,7 @@
|
|||
}, "A label element not in a document can not label any element in the document.");
|
||||
|
||||
test(function () {
|
||||
var labels = document.getElementById("test3").labels;
|
||||
assert_equals(document.getElementById("lbl1").control, document.getElementById("test3"),
|
||||
"The first labelable descendant of a label element should be its labeled control.");
|
||||
|
||||
|
@ -64,6 +108,10 @@
|
|||
document.getElementById("lbl1").insertBefore(input, document.getElementById("test2"));
|
||||
assert_equals(document.getElementById("lbl1").control, input,
|
||||
"The first labelable descendant of a label element in tree order should be its labeled control.");
|
||||
assert_equals(input.labels.length, 1,
|
||||
"The form control has an ancestor with no explicit associated label, and is the first labelable descendant.");
|
||||
assert_equals(labels.length, 0,
|
||||
"The number of labels should be 0 if it's not the first labelable descendant of a label element.");
|
||||
input.remove();
|
||||
}, "The labeled control for a label element that has no 'for' attribute is the first labelable element which is a descendant of that label element.");
|
||||
|
||||
|
@ -100,6 +148,168 @@
|
|||
newLabel.remove();
|
||||
}, "A form control has multiple labels.");
|
||||
|
||||
test(function () {
|
||||
var labels = document.getElementById("test8").labels;
|
||||
assert_true(labels instanceof NodeList,
|
||||
"A form control's 'labels' property should be an instance of a NodeList.");
|
||||
assert_equals(labels.length, 2,
|
||||
"The form control has two ancestors with no explicit associated label, and is the first labelable descendant.");
|
||||
assert_array_equals(labels, [document.getElementById("lbl7"), document.getElementById("lbl8")],
|
||||
"The labels for a form control should be returned in tree order.");
|
||||
|
||||
document.getElementById('div2').insertBefore(document.getElementById('div1'), document.getElementById('div2').firstChild);
|
||||
assert_equals(labels.length, 0,
|
||||
"The number of labels should be 0 after the labelable element is moved to outside of nested associated labels.");
|
||||
}, "A labelable element is moved to outside of nested associated labels.");
|
||||
|
||||
test(function () {
|
||||
var labels1 = document.getElementById("test9").labels;
|
||||
var labels2 = document.getElementById("test10").labels;
|
||||
assert_true(labels1 instanceof NodeList,
|
||||
"A form control's 'labels' property should be an instance of a NodeList.");
|
||||
assert_true(labels2 instanceof NodeList,
|
||||
"A form control's 'labels' property should be an instance of a NodeList.");
|
||||
assert_equals(labels1.length, 1,
|
||||
"The form control has an ancestor with no explicit associated label, and is the first labelable descendant.");
|
||||
assert_equals(labels2.length, 1,
|
||||
"The number of labels associated with a form control should be the number of label elements for which it is a labeled control.");
|
||||
assert_array_equals(labels1, [document.getElementById("lbl9")],
|
||||
"The labels for a form control should be returned in tree order.");
|
||||
assert_array_equals(labels2, [document.getElementById("lbl10")],
|
||||
"The labels for a form control should be returned in tree order.");
|
||||
document.getElementById('div3').insertBefore(document.getElementById('div4'), document.getElementById('div3').firstChild);
|
||||
assert_equals(labels1.length, 0,
|
||||
"The number of labels should be 0 if it's not the first labelable descendant of a label element.");
|
||||
assert_equals(labels2.length, 2,
|
||||
"The form control has an ancestor with an explicit associated label, and is the first labelable descendant.");
|
||||
}, "A labelable element is moved to inside of nested associated labels.");
|
||||
|
||||
test(function () {
|
||||
var labels1 = document.getElementById("test11").labels;
|
||||
var labels2 = document.getElementById("test12").labels;
|
||||
assert_true(labels1 instanceof NodeList,
|
||||
"A form control's 'labels' property should be an instance of a NodeList.");
|
||||
assert_true(labels2 instanceof NodeList,
|
||||
"A form control's 'labels' property should be an instance of a NodeList.");
|
||||
assert_equals(labels1.length, 1,
|
||||
"The form control has an ancestor with no explicit associated label, and it is the first labelable descendant.");
|
||||
assert_equals(labels2.length, 1,
|
||||
"The number of labels should be 1 since there is a label with a 'for' attribute associated with this labelable element.");
|
||||
assert_array_equals(labels1, [document.getElementById("lbl11")],
|
||||
"The labels for a form control should be returned in tree order.");
|
||||
assert_array_equals(labels2, [document.getElementById("lbl12")],
|
||||
"The labels for a form control should be returned in tree order.");
|
||||
document.getElementById('div5').appendChild(document.getElementById('obj'));
|
||||
assert_equals(labels1.length, 0,
|
||||
"The number of labels should be 0 after the labelable element is moved to outside of associated label.");
|
||||
assert_equals(labels2.length, 1,
|
||||
"The number of labels should be 1 after the labelable element is moved to outside of associated label.");
|
||||
}, "A labelable element which is a descendant of non-labelable element is moved to outside of associated label.");
|
||||
|
||||
async_test(function () {
|
||||
var labels = document.getElementById("test13").labels;
|
||||
assert_true(labels instanceof NodeList,
|
||||
"A form control's 'labels' property should be an instance of a NodeList.");
|
||||
assert_equals(labels.length, 1,
|
||||
"The form control has an ancestor with no explicit associated label, and is the first labelable descendant.");
|
||||
assert_array_equals(labels, [document.getElementById("lbl13")],
|
||||
"The labels for a form control should be returned in tree order.");
|
||||
let iframe = document.createElement('iframe');
|
||||
|
||||
iframe.onload = this.step_func_done(() => {
|
||||
iframe.contentWindow.document.getElementById("div1").appendChild(document.getElementById("p1"));
|
||||
assert_equals(labels.length, 2,
|
||||
"The number of labels should be 2 after the labelable element is moved to iframe.");
|
||||
});
|
||||
|
||||
iframe.setAttribute('src', 'http://web-platform.test:8000/html/semantics/forms/the-label-element/iframe-label-attributes.html');
|
||||
document.body.appendChild(iframe);
|
||||
}, "A labelable element is moved to iframe.");
|
||||
|
||||
test(function () {
|
||||
var labels1 = document.getElementById("test14").labels;
|
||||
var labels2 = document.getElementById("test15").labels;
|
||||
assert_true(labels1 instanceof NodeList,
|
||||
"A form control's 'labels' property should be an instance of a NodeList.");
|
||||
assert_equals(labels1.length, 1,
|
||||
"The form control has an ancestor with no explicit associated label, and is the first labelable descendant.");
|
||||
assert_equals(labels2.length, 1,
|
||||
"The number of labels associated with a form control should be the number of label elements for which it is a labeled control.");
|
||||
assert_array_equals(labels1, [document.getElementById("lbl14")],
|
||||
"The labels for a form control should be returned in tree order.");
|
||||
|
||||
document.getElementById('div6').removeChild(document.getElementById('div7'));
|
||||
assert_equals(labels1.length, 0,
|
||||
"The number of labels should be 0 after the labelable element is removed.");
|
||||
assert_equals(labels2.length, 0,
|
||||
"The number of labels should be 0 since there is no label with a 'for' attribute associated with this labelable element.");
|
||||
}, "A div element which contains labelable element is removed.");
|
||||
|
||||
test(function () {
|
||||
// <label><input id="test16"><label for="test16"></label></label>
|
||||
var label1 = document.createElement('label');
|
||||
label1.innerHTML = "<input id='test16'>";
|
||||
var label2 = document.createElement('label');
|
||||
label2.htmlFor = "test16";
|
||||
label1.appendChild(label2);
|
||||
|
||||
var input = label1.firstChild;
|
||||
var labels = input.labels;
|
||||
|
||||
assert_equals(labels.length, 2,
|
||||
"The number of labels associated with a form control should be the number of label elements for which it is a labeled control.");
|
||||
assert_true(labels instanceof NodeList,
|
||||
"A form control's 'labels' property should be an instance of a NodeList.");
|
||||
assert_equals(label1.control, input, "The first labelable descendant of a label element should be its labeled control.");
|
||||
assert_equals(label2.control, input, "The labeled cotrol should be associated with the control whose ID is equal to the value of the 'for' attribute.");
|
||||
}, "A labelable element not in a document can label element in the same tree.");
|
||||
|
||||
test(function () {
|
||||
var isShadowDOMV0;
|
||||
if ("createShadowRoot" in document.getElementById('content')) {
|
||||
isShadowDOMV0 = true;
|
||||
}
|
||||
var root1;
|
||||
if (isShadowDOMV0) {
|
||||
root1 = document.getElementById('content').createShadowRoot();
|
||||
} else {
|
||||
root1 = document.getElementById('content').attachShadow({mode: 'open'});
|
||||
}
|
||||
assert_true(root1 instanceof DocumentFragment,
|
||||
"ShadowRoot should be an instance of DocumentFragment.");
|
||||
// <label><input id="shadow1"/></label><div id="div1"></div>
|
||||
var label1 = document.createElement('label');
|
||||
var input1 = document.createElement('input');
|
||||
input1.setAttribute("id", "shadow1");
|
||||
label1.appendChild(input1);
|
||||
root1.appendChild(label1);
|
||||
|
||||
var div1 = document.createElement('div');
|
||||
label1.appendChild(div1);
|
||||
// <label for="shadow2"></label><input id="shadow2"/>
|
||||
var root2;
|
||||
if (isShadowDOMV0) {
|
||||
root2 = div1.createShadowRoot();
|
||||
} else {
|
||||
root2 = div1.attachShadow({mode: 'open'});
|
||||
}
|
||||
|
||||
assert_true(root2 instanceof DocumentFragment,
|
||||
"ShadowRoot should be an instance of DocumentFragment.");
|
||||
var label2 = document.createElement('label');
|
||||
label2.setAttribute("for", "shadow2");
|
||||
|
||||
var input2 = document.createElement('input');
|
||||
input2.setAttribute("id", "shadow2");
|
||||
root2.appendChild(label2);
|
||||
root2.appendChild(input2);
|
||||
|
||||
assert_equals(root1.getElementById("shadow1").labels.length, 1,
|
||||
"The form control has an ancestor with no explicit associated label, and it is the first labelable descendant.");
|
||||
assert_equals(root2.getElementById("shadow2").labels.length, 1,
|
||||
"The number of labels should be 1 since there is a label with a 'for' attribute associated with this labelable element.");
|
||||
}, "A labelable element inside the shadow DOM.");
|
||||
|
||||
test(function () {
|
||||
var labels = document.getElementById("test3").labels;
|
||||
assert_true(labels instanceof NodeList, "A form control's 'labels' property should be an instance of a NodeList.");
|
||||
|
|
|
@ -104,6 +104,7 @@ test(function() {
|
|||
|
||||
hiddenInput.type = "hidden";
|
||||
assert_equals(labels.length, 0, "Retained .labels NodeList should be empty after input type changed to hidden");
|
||||
assert_equals(hiddenInput.labels, null, ".labels NodeList should be null after input type changed to hidden");
|
||||
|
||||
hiddenInput.type = "checkbox";
|
||||
assert_true(labels === hiddenInput.labels, ".labels property must return the [SameObject] after input type is toggled back from 'hidden'");
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
test(() => {
|
||||
const pr = document.createElement("progress");
|
||||
assert_equals(pr.value, 0);
|
||||
assert_equals(pr.position, -1);
|
||||
pr.value = 2;
|
||||
assert_equals(pr.value, 1);
|
||||
assert_equals(pr.position, 1);
|
||||
}, "If value > max, then current value = max");
|
||||
|
||||
test(() => {
|
||||
const pr = document.createElement("progress");
|
||||
pr.value = 2;
|
||||
assert_equals(pr.value, 1);
|
||||
assert_equals(pr.position, 1);
|
||||
pr.max = 4;
|
||||
assert_equals(pr.value, 2);
|
||||
assert_equals(pr.position, 0.5);
|
||||
}, "If value < max, then current value = value");
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>textarea element value/defaultValue/textContent functionality</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"/>
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-textarea-value"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
|
||||
textarea.appendChild(document.createCDATASection("foo bar baz"));
|
||||
assert_equals(textarea.defaultValue, "foo bar baz", "the defaultValue should reflect the textContent");
|
||||
assert_equals(textarea.value, "foo bar baz",
|
||||
"changing the child text content should change the raw value, and subsequently the api value");
|
||||
|
||||
}, "defaultValue and value include CDATASection Text nodes");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE HTML>
|
||||
<title>textarea element select() functionality</title>
|
||||
<title>textarea element value/defaultValue/textContent functionality</title>
|
||||
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-textarea-value">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
|
@ -28,6 +28,30 @@ test(() => {
|
|||
|
||||
}, "defaultValue and value are affected by setting textContent");
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
|
||||
textarea.textContent = "some text";
|
||||
textarea.firstChild.nodeValue = "foo bar";
|
||||
assert_equals(textarea.defaultValue, "foo bar", "the defaultValue should reflect the textContent");
|
||||
assert_equals(textarea.value, "foo bar",
|
||||
"changing the textContent should change the raw value, and subsequently the api value");
|
||||
|
||||
}, "defaultValue and value are affected by setting nodeValue on a child text node");
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
|
||||
textarea.textContent = "some text";
|
||||
textarea.firstChild.data = "foo bar";
|
||||
assert_equals(textarea.defaultValue, "foo bar", "the defaultValue should reflect the textContent");
|
||||
assert_equals(textarea.value, "foo bar",
|
||||
"changing the textContent should change the raw value, and subsequently the api value");
|
||||
|
||||
}, "defaultValue and value are affected by setting data on a child text node");
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
|
@ -40,6 +64,60 @@ test(() => {
|
|||
|
||||
}, "defaultValue and value are affected by textContent in combination with appending a text node");
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
textarea.textContent = "foo bar";
|
||||
|
||||
const frag = document.createDocumentFragment();
|
||||
frag.appendChild(document.createTextNode(" baz"));
|
||||
const el = document.createElement("span");
|
||||
el.appendChild(document.createTextNode("qux?"));
|
||||
frag.appendChild(el);
|
||||
frag.appendChild(document.createTextNode(" fizz"));
|
||||
textarea.appendChild(frag);
|
||||
|
||||
textarea.appendChild(document.createTextNode(" whee"));
|
||||
assert_equals(textarea.defaultValue, "foo bar baz fizz whee", "the defaultValue should reflect the textContent");
|
||||
assert_equals(textarea.value, "foo bar baz fizz whee",
|
||||
"changing the textContent should change the raw value, and subsequently the api value");
|
||||
|
||||
}, "defaultValue and value are affected by textContent in combination with appending a DocumentFragment");
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
textarea.appendChild(document.createTextNode("foo bar"));
|
||||
|
||||
const child = document.createElement("span");
|
||||
child.textContent = "baz";
|
||||
textarea.appendChild(child);
|
||||
|
||||
assert_equals(textarea.textContent, "foo barbaz", "the textContent should have *all* the text content");
|
||||
assert_equals(textarea.defaultValue, "foo bar", "the defaultValue should reflect the child text content");
|
||||
assert_equals(textarea.value, "foo bar",
|
||||
"changing the child text content should change the raw value, and subsequently the api value");
|
||||
|
||||
}, "defaultValue and value reflect child text content, not textContent");
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
textarea.appendChild(document.createTextNode("foo bar"));
|
||||
|
||||
const child = document.createElement("span");
|
||||
child.textContent = "baz";
|
||||
textarea.appendChild(child);
|
||||
|
||||
textarea.defaultValue = "foo";
|
||||
|
||||
assert_equals(textarea.childNodes.length, 1, "Only one child node should exist");
|
||||
assert_equals(textarea.defaultValue, "foo", "the defaultValue should be the new text");
|
||||
assert_equals(textarea.value, "foo", "the api value should be the new text");
|
||||
assert_equals(textarea.textContent, "foo", "the textContent should be the new text");
|
||||
|
||||
}, "Setting defaultValue wipes out any children, including elements (just like setting textContent)");
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
|
@ -50,6 +128,17 @@ test(() => {
|
|||
|
||||
}, "defaultValue and value treat CRLF differently");
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
|
||||
textarea.appendChild(document.createTextNode("foo\r"));
|
||||
textarea.appendChild(document.createTextNode("\nbar\rbaz\nqux"));
|
||||
assert_equals(textarea.defaultValue, "foo\r\nbar\rbaz\nqux", "the defaultValue should reflect the textContent");
|
||||
assert_equals(textarea.value, "foo\nbar\nbaz\nqux", "The value property should normalize CRLF and CR to LF");
|
||||
|
||||
}, "value normalizes CRLF even spread over multiple text nodes");
|
||||
|
||||
test(() => {
|
||||
|
||||
const textarea = document.createElement("textarea");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue