fix existing test expectations and add new tests for HTMLOptionsCollection

This commit is contained in:
Alexandrov Sergey 2016-09-22 21:12:15 +03:00
parent cf284cc035
commit 2173545cdb
8 changed files with 128 additions and 149 deletions

View file

@ -37713,7 +37713,16 @@
"local_changes": {
"deleted": [],
"deleted_reftests": {},
"items": {},
"items": {
"testharness": {
"html/semantics/forms/the-select-element/common-HTMLOptionsCollection-add.html": [
{
"path": "html/semantics/forms/the-select-element/common-HTMLOptionsCollection-add.html",
"url": "/html/semantics/forms/the-select-element/common-HTMLOptionsCollection-add.html"
}
]
}
},
"reftest_nodes": {}
},
"reftest_nodes": {

View file

@ -1083,27 +1083,6 @@
[HTMLCollection interface: calling namedItem(DOMString) on document.createElement("form").elements with too few arguments must throw TypeError]
expected: FAIL
[HTMLOptionsCollection interface: existence and properties of interface object]
expected: FAIL
[HTMLOptionsCollection interface object length]
expected: FAIL
[HTMLOptionsCollection interface: existence and properties of interface prototype object]
expected: FAIL
[HTMLOptionsCollection interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[HTMLOptionsCollection interface: attribute length]
expected: FAIL
[HTMLOptionsCollection interface: operation add([object Object\],[object Object\],[object Object\],[object Object\])]
expected: FAIL
[HTMLOptionsCollection interface: operation remove(long)]
expected: FAIL
[HTMLOptionsCollection interface: attribute selectedIndex]
expected: FAIL
@ -3747,18 +3726,6 @@
[HTMLSelectElement interface: attribute required]
expected: FAIL
[HTMLSelectElement interface: attribute options]
expected: FAIL
[HTMLSelectElement interface: operation namedItem(DOMString)]
expected: FAIL
[HTMLSelectElement interface: operation remove()]
expected: FAIL
[HTMLSelectElement interface: operation remove(long)]
expected: FAIL
[HTMLSelectElement interface: attribute selectedOptions]
expected: FAIL
@ -3792,15 +3759,6 @@
[HTMLSelectElement interface: document.createElement("select") must inherit property "required" with the proper type (6)]
expected: FAIL
[HTMLSelectElement interface: document.createElement("select") must inherit property "options" with the proper type (9)]
expected: FAIL
[HTMLSelectElement interface: document.createElement("select") must inherit property "namedItem" with the proper type (12)]
expected: FAIL
[HTMLSelectElement interface: calling namedItem(DOMString) on document.createElement("select") with too few arguments must throw TypeError]
expected: FAIL
[HTMLSelectElement interface: document.createElement("select") must inherit property "selectedOptions" with the proper type (17)]
expected: FAIL
@ -6456,9 +6414,6 @@
[HTMLAllCollection interface object name]
expected: FAIL
[HTMLOptionsCollection interface object name]
expected: FAIL
[HTMLPropertiesCollection interface object name]
expected: FAIL

View file

@ -1,14 +1,5 @@
[htmloptionscollection.html]
type: testharness
[Original length]
expected: FAIL
[Setting length to original value has no effect]
expected: FAIL
[Setting length to shorter value]
expected: FAIL
[Setting length to longer value]
expected: FAIL
@ -24,48 +15,5 @@
[Insert <optgroup><optgroup><option>6</option></optgroup></optgroup> into <select>]
expected: FAIL
[namedItem id attribute]
expected: FAIL
[namedItem name attribute]
expected: FAIL
[namedItem doesn't match anything]
expected: FAIL
[namedItem multiple IDs]
expected: FAIL
[namedItem multiple names]
expected: FAIL
[namedItem multiple name and ID]
expected: FAIL
[namedItem multiple name and ID with multiple attributes]
expected: FAIL
[namedItem id attribute multiple attributes one element]
expected: FAIL
[namedItem name attribute multiple attributes one element]
expected: FAIL
[HTMLOptionsCollection [index\] method return the item with index]
expected: FAIL
[HTMLOptionsCollection [name\] method return the item with name]
expected: FAIL
[HTMLOptionsCollection.item(index) method return the item with index]
expected: FAIL
[HTMLOptionsCollection.item(name) method return the item with index 0]
expected: FAIL
[HTMLOptionsCollection.add method insert HTMLOptionElement Option element]
expected: FAIL
[HTMLOptionsCollection.remove method remove Option element by index]
expected: FAIL

View file

@ -1,29 +0,0 @@
[common-HTMLOptionsCollection-namedItem.html]
type: testharness
[if only one item has a *name* or id value matching the parameter, return that object and stop]
expected: FAIL
[if only one item has a name or *id* value matching the parameter, return that object and stop]
expected: FAIL
[if no item has a name or id value matching the parameter, return null and stop]
expected: FAIL
[return an HTMLOptionsCollection in correct order for repeated 'id' value]
expected: FAIL
[return an HTMLOptionsCollection in correct order for repeated 'name' value]
expected: FAIL
[return an HTMLOptionsCollection in correct order for repeated mixed value]
expected: FAIL
[if multiple items have a name or *id* value matching the parameter, return the first object and stop]
expected: FAIL
[if multiple items have a *name* or id value matching the parameter, return the first object and stop]
expected: FAIL
[if multiple items have a *name* or *id* value matching the parameter, return the first object and stop]
expected: FAIL

View file

@ -1,14 +0,0 @@
[select-named-getter.html]
type: testharness
[Option with id]
expected: FAIL
[Option with name]
expected: FAIL
[Option with name and id]
expected: FAIL
[Empty string name]
expected: FAIL

View file

@ -1,8 +0,0 @@
[select-remove.html]
type: testharness
[select.remove(n) should work]
expected: FAIL
[select.options.remove(n) should work]
expected: FAIL

View file

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title id='title'>HTMLOptionsCollection</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<select id="selly">
<option id="id1" name="name1">1</option>
<option id="id2" name="name2">2</option>
<option id="id3" name="name3">3</option>
<option id="id4" name="name4">4</option>
<optgroup id="og1">
<option name="nameonly">n1</option>
<option id="id5">5</option>
</optgroup>
<optgroup id="og2">
<option name="nameonly">n2</option>
<option id="id6">6</option>
</optgroup>
</select>
<script>
var selly;
setup(function() {
selly = document.getElementById('selly');
});
test(function () {
var option = document.getElementById('id1');
var optgroup = document.getElementById('og1');
selly.options.add(option, option);
selly.options.add(optgroup, optgroup);
assert_equals(selly.children.length, 6);
assert_equals(selly.length, 8);
}, "if before and node are the same element nothing should be done");
test(function () {
var o1 = document.createElement("option");
o1.value = "a";
var o2 = document.createElement("option");
o2.value = "b";
var o3 = document.createElement("option");
o3.value = "c";
var optgroup = document.getElementById('og1');
selly.options.add(o1, null);
selly.options.add(o2, optgroup);
selly.options.add(o3, 0);
var elarray = [];
for (var i = 0; i < selly.length; i++) {
elarray.push(selly[i].value);
}
assert_array_equals(elarray, ["c", "1", "2", "3", "4", "b", "n1", "5", "n2", "6", "a"]);
}, "add method should add option elements correctly");
test(function () {
var og1 = document.createElement("optgroup");
var o1 = document.createElement("option");
o1.value = "a";
o1.appendChild(og1);
var og2 = document.createElement("optgroup");
var o2 = document.createElement("option");
o2.value = "b";
o2.appendChild(og2);
var og3 = document.createElement("optgroup");
var o3 = document.createElement("option");
o3.value = "c";
o3.appendChild(og3);
var optgroup = document.getElementById('og1');
selly.options.add(og1, null);
selly.options.add(og2, optgroup);
selly.options.add(og3, 0);
var elarray = [];
for (var i = 0; i < selly.length; i++) {
elarray.push(selly[i].value);
}
assert_array_equals(elarray, ["c", "1", "2", "3", "4", "b", "n1", "5", "n2", "6", "a"]);
}, "add method should add option groups correctly");
</script>
</body>
</html>

View file

@ -67,4 +67,33 @@ test(function () {
assert_equals(selly.children.length, 4,
"Number of children should have changed");
}, "Setting a length lower than the old length trims nodes from the end");
test(function () {
var opts = selly.options;
opts[3] = null;
assert_equals(selly[3], undefined,
"previously set node is now undefined");
assert_equals(selly.length, 3,
"Number of nodes in collection is correctly changed");
assert_equals(selly.children.length, 3,
"Number of children should have changed");
}, "Setting element to null by index removed the element");
test(function () {
var opts = selly.options;
var new_option = document.createElement("option");
var replace_option = new_option.cloneNode(true);
new_option.value = "-1";
replace_option.value = "a";
opts[5] = new_option;
opts[0] = replace_option;
var elarray = [];
for (var i = 0; i < selly.length; i++) {
elarray.push(selly[i].value);
}
assert_array_equals(elarray, ["a", "2", "3", "", "", "-1"]);
}, "Setting element by index should correctly append and replace elements");
</script>