Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255

This commit is contained in:
James Graham 2015-03-27 09:15:38 +00:00
parent b2a5225831
commit 1a81b18b9f
12321 changed files with 544385 additions and 6 deletions

View file

@ -0,0 +1,14 @@
[
{
"id": "htmlallcollection",
"original_id": "htmlallcollection"
},
{
"id": "htmlformcontrolscollection",
"original_id": "htmlformcontrolscollection"
},
{
"id": "htmloptionscollection",
"original_id": "htmloptionscollection"
}
]

View file

@ -0,0 +1,33 @@
<!DOCTYPE HTML>
<html>
<head>
<title>HTMLAllCollection Tests</title>
<link rel="author" title="Dan Druta" href="mailto:dan.druta@att.com"/>
<link rel="help" href="2.7.2.1 - Common Infrastructure/Common DOM Interfaces/Collections/HTMLAllCollection"/>
<meta name="flags" content="TOKENS" />
<meta name="assert" content="TEST ASSERTION"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<img src="../../../../images/green.png" name="picture">
<script>
test(function(){ assert_equals(document.all.length,12)}, "Test for HTMLAllCollection size");
test(function(){ assert_equals(document.all.item(0).tagName,"HTML")}, "Test lookup by index using ()");
test(function(){ assert_equals(document.all[0].tagName,"HTML")}, "Test lookup by index using []");
test(function(){ assert_equals(document.all.tags("script").length,3)}, "Test for multiple occurence 3 <script> found");
test(function(){ assert_equals(document.all.item("picture").nodeName,"IMG")}, "Test lookup IMG by name");
test(function(){ assert_equals(document.all.namedItem("picture").nodeName,"IMG")}, "Test lookup IMG by namedItem ");
test(function(){ assert_equals(document.all("picture").nodeName,"IMG")}, "Test lookup IMG in collection using ()");
test(function(){ assert_equals(document.all["picture"].nodeName,"IMG")}, "Test lookup IMG in collection using []");
</script>
<div id="log"></div>
</body>
</html>

View file

@ -0,0 +1,112 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: the HTMLFormControlsCollection interface</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/common-dom-interfaces.html#htmlformcontrolscollection">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<form id="f1">
<input type="radio" id="r1">
<keygen id="kg" name="key"></keygen>
</form>
<form id="f2">
<table>
<tr>
<td>
<input type="checkbox" id="cb">
<input type="checkbox" name="cb">
</td>
</tr>
<button id="btn"></button>
<button name="btn"></button>
</table>
</form>
<script>
var coll1, coll2, rdo;
setup(function () {
rdo = document.getElementById("r1");
coll1 = document.forms[0].elements;
coll2 = document.forms[1].elements;
});
//length
test(function () {
assert_equals(coll1.length, 2, "The length attribute is incorrect.");
assert_equals(coll2.length, 4, "The length attribute is incorrect.");
}, "The length attribute must return the number of elements in the form");
//getter - index
test(function () {
assert_equals(coll1.item(0), rdo, "HTMLFormControlsCollection.item(index) should return the 'input' element in radio status.");
}, "HTMLFormControlsCollection.item(index) must return the indexed item");
test(function () {
assert_equals(coll1[0], rdo, "HTMLFormControlsCollection[index] should return the 'input' element in radio status.");
}, "HTMLFormControlsCollection[index] must return the indexed item");
//getter - name
test(function () {
assert_equals(coll1("r1"), rdo, "HTMLFormControlsCollection(name) should return the 'input' element in radio status.");
}, "HTMLFormControlsCollection(name) must return the named item");
test(function () {
assert_equals(coll1["r1"], rdo, "HTMLFormControlsCollection[name] should return the 'input' element in radio status.");
}, "HTMLFormControlsCollection[name] must return the named item");
//getter - namedItem
test(function () {
assert_equals(coll1.namedItem("r1"), rdo, "HTMLFormControlsCollection.namedItem(name) should return the 'input' element in radio status.");
}, "HTMLFormControlsCollection.namedItem(name) must return the named item");
test(function () {
assert_true(coll1.namedItem("r1") instanceof Element, "Can not return 'Element' object.");
}, "The namedItem(name) must return an Element");
test(function () {
assert_true(coll2.namedItem("cb") instanceof RadioNodeList, "Can not return 'RadioNodeList' object.");
}, "The namedItem(name) must return RadioNodeList");
test(function () {
assert_equals(coll1.namedItem(""), null, "The return value of namedItem() should be null.");
}, "The namedItem(name) must return null if the name is empty");
test(function () {
assert_equals(coll1.namedItem("test"), null, "The return value of namedItem() should be null.");
}, "The namedItem(name) must return null if there is no matched element");
test(function () {
assert_equals(coll1.namedItem("kg"), document.getElementById("kg"), "Controls can be named by 'id' attribute.");
assert_equals(coll1.namedItem("key"), document.getElementById("kg"), "Controls can be named by 'name' attribute.");
}, "Controls can be indexed by id or name attribute");
test(function () {
assert_equals(coll2.namedItem("btn").length, 2, "The length attribute should be 2.");
}, "The namedItem(name) must return the items with id or name attribute");
//various controls in fieldset and form
var containers = ["form", "fieldset"],
controls = ["button", "fieldset", "input", "keygen", "object", "output", "select", "textarea"];
for (var m = 0; m < containers.length; m++) {
test(function () {
var container = document.createElement(containers[m]);
var len = controls.length;
for (var n = 0; n < len; n++)
container.appendChild(document.createElement(controls[n]));
document.body.appendChild(container);
assert_equals(container.elements.length, len, "The length should be " + len + ".");
}, "The HTMLFormControlsCollection interface is used for collections of listed elements in " + containers[m] + " element");
}
//Check the controls' order
test(function () {
var opt = document.forms[1].insertBefore(document.createElement("output"), document.forms[1].firstChild);
assert_array_equals(document.forms[1].elements,
[opt, document.getElementsByTagName("input")[1], document.getElementsByTagName("input")[2],
document.getElementsByTagName("button")[0], document.getElementsByTagName("button")[1]]);
}, "The controls in the form element must be sorted in tree order");
</script>

View file

@ -0,0 +1,184 @@
<!doctype html>
<title>HTMLOptionsCollection</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#htmloptionscollection-0">
<select id=a>
<option>1</option>
<option>2</option>
<option>3</option>
<!--Note whitespace is important-->
<option>4</option>
<option>5</option>
</select>
<select id=b>
<option id=b1>1</option>
<option name=b2>2</option>
<option id=b3>3</option>
<option id=b3>4</option>
<option name=b4>5</option>
<option name=b4>6</option>
<option id=b5>7</option>
<option name=b5>8</option>
<option id=b6 name=b7>9</option>
<option id=b6 name=b6>10</option>
<option id=b8 name=b9>11</option>
</select>
<script>
var a;
var a_opts;
var a_original_innerHTML;
var b;
var b_opts;
setup(function() {
a = document.getElementById("a");
a_opts = a.options;
a_original_innerHTML = a.innerHTML;
a.innerHTML = a_original_innerHTML;
b = document.getElementById("b");
b_opts = b.options;
b_original_innerHTML = b.innerHTML;
b.innerHTML = b_original_innerHTML;
})
function assert_values_equals(coll, expected_values, message) {
actual = [];
for (var i=0; i<coll.length; i++) {
actual.push(coll[i].value);
}
assert_array_equals(actual, expected_values, message);
}
test(function() {
assert_equals(5, a_opts.length);
}, "Original length");
test(function() {
a.innerHTML = a_original_innerHTML;
a_opts.value = "3";
a_opts.length = 5;
assert_equals(a_opts.length, 5);
assert_equals(a_opts.value, "3");
}, "Setting length to original value has no effect");
test(function() {
a.innerHTML = a_original_innerHTML;
a.value = 3;
a_opts.length = 3;
assert_equals(3, a_opts.length, "Correct length");
assert_values_equals(a_opts, ["1","2","3"], "Correct elements remain")
assert_equals(a_opts.value, "3", "Correct value set");
assert_equals(a.childNodes.length, 11, "Correct number of child nodes")
}, "Setting length to shorter value");
test(function() {
a.innerHTML = a_original_innerHTML;
a.value = 3;
a_opts.length = 7;
assert_equals(a_opts.length, 7, "Correct length");
assert_values_equals(a_opts, ["1","2","3","4","5","",""], "Correct elements inserted")
assert_equals(a.value, "3", "Correct value set");
assert_equals(a.childNodes.length, 15, "Correct number of child nodes")
}, "Setting length to longer value");
test(function() {
a.innerHTML = a_original_innerHTML;
var newChild = document.createElement("p");
var newOption = document.createElement("option");
newOption.textContent = "6";
newChild.appendChild(newOption);
a.appendChild(newChild);
a.value = 3;
assert_equals(a_opts.length, 5, "Correct length");
assert_values_equals(a_opts, ["1","2","3","4","5"], "Correct elements inserted")
assert_equals(a.value, "3", "Correct value set");
}, "Insert <p><option>6</option></p> into <select>");
test(function() {
a.innerHTML = a_original_innerHTML;
var newChild = document.createElement("select");
var newOption = document.createElement("option");
newOption.textContent = "6";
newChild.appendChild(newOption);
a.appendChild(newChild);
a.value = 3;
assert_equals(a_opts.length, 5, "Correct length");
assert_values_equals(a_opts, ["1","2","3","4","5"], "Correct elements inserted")
assert_equals(a.value, "3", "Correct value set");
}, "Insert <select><option>6</option></select> into <select>");
test(function() {
//This tests the spec but it is probably wrong here; see bug 12665
a.innerHTML = a_original_innerHTML;
var newChild = document.createElement("optgroup");
var newOption = document.createElement("option");
newOption.textContent = "6";
newChild.appendChild(newOption);
a.appendChild(newChild);
a.value = 3;
assert_equals(a_opts.length, 6, "Correct length");
assert_values_equals(a_opts, ["1","2","3","4","5", "6"], "Correct elements inserted")
assert_equals(a.value, "3", "Correct value set");
}, "Insert <optgroup><option>6</option></optgroup> into <select>");
test(function() {
a.innerHTML = a_original_innerHTML;
var newChild = document.createElement("optgroup");
var newChild1 = document.createElement("optgroup");
var newOption = document.createElement("option");
newOption.textContent = "6";
newChild.appendChild(newChild1);
newChild1.appendChild(newOption);
a.appendChild(newChild);
a.value = 3;
assert_equals(a_opts.length, 5, "Correct length");
assert_values_equals(a_opts, ["1","2","3","4","5"], "Correct elements inserted")
assert_equals(a.value, "3", "Correct value set");
}, "Insert <optgroup><optgroup><option>6</option></optgroup></optgroup> into <select>");
test(function() {
assert_equals(b_opts.namedItem("b1").value, "1");
}, "namedItem id attribute");
test(function() {
assert_equals(b_opts.namedItem("b2").value, "2");
}, "namedItem name attribute");
test(function() {
assert_equals(b_opts.namedItem("c"), null);
}, "namedItem doesn't match anything");
test(function() {
assert_equals(b_opts.namedItem("b3").value, "3");
}, "namedItem multiple IDs");
test(function() {
assert_equals(b_opts.namedItem("b4").value, "5");
}, "namedItem multiple names");
test(function() {
assert_equals(b_opts.namedItem("b5").value, "7");
}, "namedItem multiple name and ID");
test(function() {
assert_equals(b_opts.namedItem("b6").value, "9");
}, "namedItem multiple name and ID with multiple attributes");
test(function() {
assert_equals(b_opts.namedItem("b8").value, "11");
}, "namedItem id attribute multiple attributes one element");
test(function() {
assert_equals(b_opts.namedItem("b9").value, "11");
}, "namedItem name attribute multiple attributes one element");
test(function() {
var add = document.createElement("p");
assert_throws(new TypeError(), function() {b_opts.add(add);});
}, "Add non-option to collection");
</script>
<div id=log></div>

View file

@ -0,0 +1,78 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: the RadioNodeList interface</title>
<link rel="author" title="Intel" href="http://www.intel.com/">
<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/common-dom-interfaces.html#radionodelist">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<form >
<input type="checkbox" name="rdo" value="0" id="r0" checked>
<input type="radio" name="rdo" id="r1">
<input type="radio" name="rdo" id="r2" value="2">
</form>
<script>
var rdoList;
setup(function () {
rdoList = document.forms[0].elements.namedItem("rdo");
});
//on getting
test(function () {
assert_equals(rdoList.value, "", "The value attribute should be empty.");
}, "The value attribute should be empty if no element is checked");
test(function () {
document.getElementById("r2").checked = true;
assert_equals(rdoList.value, "2", "The value attribute should be 2.");
}, "The RadioNodeList.value must be the first checked radio button's value");
test(function () {
document.getElementById("r1").checked = true;
assert_equals(rdoList.value, "on", "The value attribute should be on.");
document.getElementById("r1").value = 1;
assert_equals(rdoList.value, "1", "The value attribute should be 1.");
}, "Check the RadioNodeList.value on getting");
//on setting
test(function () {
assert_equals(rdoList.value, document.getElementById("r1").value,
"The value attribute should be equal to the first checked radio input element's value.");
assert_false(document.getElementById("r2").checked,
"The second radio input element should not be checked.");
rdoList.value = "2";
assert_equals(rdoList.value, document.getElementById("r2").value,
"The value attribute should be equal to the second radio input element's value.");
assert_true(document.getElementById("r2").checked,
"The second radio input element should be checked.");
//Do nothing if no element's value is equal to new value.
rdoList.value = "3";
assert_equals(rdoList.value, document.getElementById("r2").value,
"The value attribute should be the second radio input element's value.");
assert_true(document.getElementById("r2").checked,
"The second radio input element should be checked.");
}, "Check the RadioNodeList.value on setting");
//setting to on, specific case
test(function () {
rdoList.value = "on";
assert_equals(rdoList.value, document.getElementById("r2").value,
"The value attribute should be the second radio input element's value.");
assert_true(document.getElementById("r2").checked,
"The second radio input element should be checked.");
document.getElementById("r1").removeAttribute("value");
rdoList.value = "on";
assert_equals(rdoList.value, document.getElementById("r1").value,
"The value attribute should be the first radio input element's value.");
assert_true(document.getElementById("r1").checked,
"The first radio input element should be checked.");
}, "Check the RadioNodeList.value on setting to 'on'");
</script>