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,41 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>HTMLTableCellElement.cellIndex</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var th = document.createElement("th");
assert_true("cellIndex" in th, '"cellIndex" in th');
var td = document.createElement("td");
assert_true("cellIndex" in td, '"cellIndex" in td');
}, "cellIndex should exist.")
test(function() {
var th = document.createElement("th");
assert_equals(th.cellIndex, -1);
var td = document.createElement("td");
assert_equals(td.cellIndex, -1);
}, "For cells without a parent, cellIndex should be -1.")
test(function() {
var table = document.createElement("table");
var th = table.appendChild(document.createElement("th"));
assert_equals(th.cellIndex, -1);
var td = table.appendChild(document.createElement("td"));
assert_equals(td.cellIndex, -1);
}, "For cells whose parent is not a tr, cellIndex should be -1.")
test(function() {
var tr = document.createElementNS("", "tr");
var th = tr.appendChild(document.createElement("th"));
assert_equals(th.cellIndex, -1);
var td = tr.appendChild(document.createElement("td"));
assert_equals(td.cellIndex, -1);
}, "For cells whose parent is not a HTML tr, cellIndex should be -1.")
test(function() {
var tr = document.createElement("tr");
var th = tr.appendChild(document.createElement("th"));
assert_equals(th.cellIndex, 0);
var td = tr.appendChild(document.createElement("td"));
assert_equals(td.cellIndex, 1);
}, "For cells whose parent is a tr, cellIndex should be the index.")
</script>

View file

@ -0,0 +1,10 @@
[
{
"id": "forming-a-table",
"original_id": "forming-a-table"
},
{
"id": "header-and-data-cell-semantics",
"original_id": "header-and-data-cell-semantics"
}
]

View file

@ -0,0 +1,69 @@
<!DOCTYPE HTML>
<html>
<head>
<title>HTML5 Table API Tests</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<link rel="author" title="Microsoft" href="http://www.microsoft.com/" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-caption-element" />
</head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<div id="log"></div>
<table id="table1" style="display:none">
<tr><td></td></tr>
<caption>first caption</caption>
<caption>second caption</caption>
</table>
<table id="table2" style="display:none">
<tr><td></td></tr>
</table>
<table id="table3" style="display:none">
<tr><td></td></tr>
</table>
<table id="table4" style="display:none">
<tr><td></td></tr>
<caption>first caption</caption>
</table>
<script>
test(function () {
assert_equals(document.getElementById('table1').caption.innerHTML, "first caption");
}, "first caption element child of the first table element");
test(function () {
var caption = document.createElement("caption");
caption.innerHTML = "new caption";
var table = document.getElementById('table1');
table.caption = caption;
assert_equals(caption.parentNode, table);
assert_equals(table.caption.innerHTML, "new caption");
captions = table.getElementsByTagName('caption');
assert_equals(captions.length, 2);
assert_equals(captions[0].innerHTML, "new caption");
assert_equals(captions[1].innerHTML, "second caption");
}, "setting caption on a table");
test(function () {
assert_equals(document.getElementById('table2').caption, null);
}, "caption IDL attribute is null");
test(function () {
var table = document.getElementById('table3');
var caption = document.createElement("caption")
table.rows[0].appendChild(caption);
assert_equals(table.caption, null);
}, "caption of the third table element should be null");
test(function () {
assert_not_equals(document.getElementById('table4').caption, null);
var parent = document.getElementById('table4').caption.parentNode;
parent.removeChild(document.getElementById('table4').caption);
assert_equals(document.getElementById('table4').caption, null);
}, "dynamically removing caption on a table");
</script>
</body>
</html>

View file

@ -0,0 +1,56 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Creating and deleting captions</title>
<link rel="author" title="Erika Navara" href="mailto:edoyle@microsoft.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-table-element" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-createcaption" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-deletecaption" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<table id="table1" style="display:none">
<caption id="caption1">caption</caption>
<tr>
<td>cell</td>
<td>cell</td>
</tr>
</table>
<table id="table2" style="display:none">
<tr>
<td>cell</td>
<td>cell</td>
</tr>
</table>
<table id="table3" style="display:none">
<caption id="caption3">caption 3</caption>
<tr>
<td>cell</td>
<td>cell</td>
</tr>
</table>
<script>
test(function () {
var table1 = document.getElementById('table1');
var testCaption = table1.createCaption();
var table1FirstCaption = table1.caption;
assert_equals(testCaption, table1FirstCaption);
}, "createCaption method returns the first caption element child of the table")
test(function () {
var table2 = document.getElementById('table2');
var test2Caption = table2.createCaption();
var table2FirstNode = table2.firstChild;
assert_true(test2Caption instanceof HTMLTableCaptionElement);
assert_equals(table2FirstNode, test2Caption);
}, "createCaption method creates a new caption and inserts it as the first node of the table element")
test(function () {
var table3 = document.getElementById('table3');
assert_equals(table3.caption.textContent, "caption 3");
table3.deleteCaption();
assert_equals(table3.caption, null);
}, "deleteCaption method removes the first caption element child of the table element")
</script>
</body>
</html>

View file

@ -0,0 +1,10 @@
[
{
"id": "table-descriptions-techniques",
"original_id": "table-descriptions-techniques"
},
{
"id": "table-layout-techniques",
"original_id": "table-layout-techniques"
}
]

View file

@ -0,0 +1,165 @@
<!doctype html>
<meta charset=utf-8>
<title>HTMLTableElement.createTBody</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
function assert_tbody(tbody) {
assert_equals(tbody.localName, "tbody");
assert_equals(tbody.namespaceURI, htmlNS);
assert_equals(tbody.prefix, null);
}
var htmlNS = "http://www.w3.org/1999/xhtml";
test(function() {
var table = document.createElement("table");
var tbody = table.createTBody();
assert_equals(table.firstChild, tbody);
assert_tbody(tbody);
}, "No child nodes");
test(function() {
var table = document.createElement("table");
var before = table.appendChild(document.createElement("tbody"));
assert_array_equals(table.childNodes, [before]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before, tbody]);
assert_tbody(tbody);
}, "One tbody child node");
test(function() {
var table = document.createElement("table");
var before1 = table.appendChild(document.createElement("tbody"));
var before2 = table.appendChild(document.createElement("tbody"));
assert_array_equals(table.childNodes, [before1, before2]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before1, before2, tbody]);
assert_tbody(tbody);
}, "Two tbody child nodes");
test(function() {
var table = document.createElement("table");
var before1 = table.appendChild(document.createElement("thead"));
var before2 = table.appendChild(document.createElement("tbody"));
assert_array_equals(table.childNodes, [before1, before2]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before1, before2, tbody]);
assert_tbody(tbody);
}, "A thead and a tbody child node");
test(function() {
var table = document.createElement("table");
var before1 = table.appendChild(document.createElement("tfoot"));
var before2 = table.appendChild(document.createElement("tbody"));
assert_array_equals(table.childNodes, [before1, before2]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before1, before2, tbody]);
assert_tbody(tbody);
}, "A tfoot and a tbody child node");
test(function() {
var table = document.createElement("table");
var before = table.appendChild(document.createElement("tbody"));
var after = table.appendChild(document.createElement("thead"));
assert_array_equals(table.childNodes, [before, after]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before, tbody, after]);
assert_tbody(tbody);
}, "A tbody and a thead child node");
test(function() {
var table = document.createElement("table");
var before = table.appendChild(document.createElement("tbody"));
var after = table.appendChild(document.createElement("tfoot"));
assert_array_equals(table.childNodes, [before, after]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before, tbody, after]);
assert_tbody(tbody);
}, "A tbody and a tfoot child node");
test(function() {
var table = document.createElement("table");
var before1 = table.appendChild(document.createElement("tbody"));
var before2 = table.appendChild(document.createElement("tbody"));
var after = table.appendChild(document.createElement("div"));
assert_array_equals(table.childNodes, [before1, before2, after]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before1, before2, tbody, after]);
assert_tbody(tbody);
}, "Two tbody child nodes and a div");
test(function() {
var table = document.createElement("table");
var before = table.appendChild(document.createElement("tbody"));
var after = table.appendChild(document.createElementNS("x", "tbody"));
assert_array_equals(table.childNodes, [before, after]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before, tbody, after]);
assert_tbody(tbody);
}, "One HTML and one namespaced tbody child node");
test(function() {
var table = document.createElement("table");
var before1 = table.appendChild(document.createElement("tbody"));
var before2 = before1.appendChild(document.createElement("tbody"));
assert_array_equals(table.childNodes, [before1]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before1, tbody]);
assert_tbody(tbody);
}, "Two nested tbody child nodes");
test(function() {
var table = document.createElement("table");
var before1 = table.appendChild(document.createElement("thead"));
var before2 = before1.appendChild(document.createElement("tbody"));
assert_array_equals(table.childNodes, [before1]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before1, tbody]);
assert_tbody(tbody);
}, "A tbody node inside a thead child node");
test(function() {
var table = document.createElement("table");
var before1 = table.appendChild(document.createElement("tfoot"));
var before2 = before1.appendChild(document.createElement("tbody"));
assert_array_equals(table.childNodes, [before1]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before1, tbody]);
assert_tbody(tbody);
}, "A tbody node inside a tfoot child node");
test(function() {
var table = document.createElement("table");
var before = table.appendChild(document.createElement("tbody"));
var after1 = table.appendChild(document.createElement("thead"));
var after2 = after1.appendChild(document.createElement("tbody"));
assert_array_equals(table.childNodes, [before, after1]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before, tbody, after1]);
assert_tbody(tbody);
}, "A tbody node inside a thead child node after a tbody child node");
test(function() {
var table = document.createElement("table");
var before = table.appendChild(document.createElement("tbody"));
var after1 = table.appendChild(document.createElement("tfoot"));
var after2 = after1.appendChild(document.createElement("tbody"));
assert_array_equals(table.childNodes, [before, after1]);
var tbody = table.createTBody();
assert_array_equals(table.childNodes, [before, tbody, after1]);
assert_tbody(tbody);
}, "A tbody node inside a tfoot child node after a tbody child node");
</script>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<title>insertRow(): INDEX_SIZE_ERR</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-insertrow">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<table>
<tr>
<td>
</table>
</div>
<script>
test(function() {
var table = document.getElementById("test").getElementsByTagName("table")[0];
assert_throws("INDEX_SIZE_ERR", function() {
table.insertRow(-2);
})
assert_throws("INDEX_SIZE_ERR", function() {
table.insertRow(2);
})
});
</script>

View file

@ -0,0 +1,34 @@
<!DOCTYPE html>
<title>insertRow(): Empty table</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-table-insertrow">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<div id="test">
<table></table>
</div>
<script>
var HTML = "http://www.w3.org/1999/xhtml";
test(function() {
var table = document.getElementById("test").getElementsByTagName("table")[0];
test(function() {
assert_equals(table.childNodes.length, 0);
assert_equals(table.rows.length, 0);
}, "table should start out empty")
var tr;
test(function() {
tr = table.insertRow(0);
assert_equals(tr.localName, "tr");
assert_equals(tr.namespaceURI, HTML);
}, "insertRow should insert a tr element")
var tbody = tr.parentNode;
test(function() {
assert_equals(tbody.localName, "tbody");
assert_equals(tbody.namespaceURI, HTML);
assert_equals(tbody.parentNode, table);
}, "insertRow should insert a tbody element")
});
</script>

View file

@ -0,0 +1,40 @@
<!DOCTYPE html>
<title>HTMLTableElement.tBodies</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var text =
'<html xmlns="http://www.w3.org/1999/xhtml">' +
' <head>' +
' <title>Virtual Library</title>' +
' </head>' +
' <body>' +
' <table id="mytable" border="1">' +
' <tbody>' +
' <tr><td>Cell 1</td><td>Cell 2</td></tr>' +
' <tr><td>Cell 3</td><td>Cell 4</td></tr>' +
' </tbody>' +
' </table>' +
' </body>' +
'</html>';
var parser = new DOMParser();
var doc = parser.parseFromString(text, "text/xml");
// import <table>
var table = doc.documentElement.getElementsByTagName('table')[0];
var mytable = document.body.appendChild(document.importNode(table, true));
assert_equals(mytable.tBodies.length, 1);
var tbody = document.createElement('tbody');
mytable.appendChild(tbody);
var tr = tbody.insertRow(-1);
tr.insertCell(-1).appendChild(document.createTextNode('Cell 5'));
tr.insertCell(-1).appendChild(document.createTextNode('Cell 6'));
assert_equals(mytable.tBodies.length, 2);
assert_equals(mytable.rows.length, 3);
assert_equals(tr.rowIndex, 2);
});
</script>

View file

@ -0,0 +1,56 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>HTMLTableElement.insertRow</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var HTMLNS = "http://www.w3.org/1999/xhtml"
var parentEl = document.createElementNS(HTMLNS, "html:table")
assert_equals(parentEl.namespaceURI, HTMLNS, "Parent should be in the HTML namespace")
assert_equals(parentEl.prefix, "html", "Parent prefix should be html")
assert_equals(parentEl.localName, "table", "Parent local name should be table")
assert_equals(parentEl.tagName, "HTML:TABLE", "Parent tag name should be HTML:TABLE")
var row = parentEl.insertRow(-1)
assert_equals(row.namespaceURI, HTMLNS, "Row should be in the HTML namespace")
assert_equals(row.prefix, null, "Row prefix should be null")
assert_equals(row.localName, "tr", "Row local name should be tr")
assert_equals(row.tagName, "TR", "Row tag name should be TR")
var body = row.parentNode
assert_equals(body.namespaceURI, HTMLNS, "Body should be in the HTML namespace")
assert_equals(body.prefix, null, "Body prefix should be null")
assert_equals(body.localName, "tbody", "Body local name should be tr")
assert_equals(body.tagName, "TBODY", "Body tag name should be TR")
assert_array_equals(parentEl.childNodes, [body])
assert_array_equals(body.childNodes, [row])
assert_array_equals(parentEl.rows, [row])
}, "insertRow should not copy prefixes")
test(function() {
var table = document.createElement("table")
var head = table.appendChild(document.createElement("thead"))
assert_array_equals(table.rows, [])
var row = table.insertRow(-1)
var body = row.parentNode
assert_array_equals(table.childNodes, [head, body])
assert_array_equals(head.childNodes, [])
assert_array_equals(body.childNodes, [row])
assert_array_equals(table.rows, [row])
}, "insertRow should insert into a tbody, not into a thead, if table.rows is empty")
test(function() {
var table = document.createElement("table")
var foot = table.appendChild(document.createElement("tfoot"))
assert_array_equals(table.rows, [])
var row = table.insertRow(-1)
var body = row.parentNode
assert_array_equals(table.childNodes, [foot, body])
assert_array_equals(foot.childNodes, [])
assert_array_equals(body.childNodes, [row])
assert_array_equals(table.rows, [row])
}, "insertRow should insert into a tbody, not into a tfoot, if table.rows is empty")
</script>

View file

@ -0,0 +1,186 @@
<!DOCTYPE html>
<title>HTMLTableElement.rows</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function assert_nodelist_equals(actual, expected) {
assert_equals(actual.length, expected.length);
for (var i = 0; i < actual.length; ++i) {
assert_true(i in actual);
assert_true(actual.hasOwnProperty(i),
"property " + i + " expected to be present on the object");
assert_equals(actual.item(i), expected[i]);
assert_equals(actual[i], expected[i]);
}
}
function test_table_simple(group, table) {
var foo1 = group.appendChild(document.createElement("tr"));
foo1.id = "foo";
var bar1 = group.appendChild(document.createElement("tr"));
bar1.id = "bar";
var foo2 = group.appendChild(document.createElement("tr"));
foo2.id = "foo";
var bar2 = group.appendChild(document.createElement("tr"));
bar2.id = "bar";
assert_true(table.rows instanceof HTMLCollection, "table.rows should be a HTMLCollection.");
assert_nodelist_equals(table.rows, [foo1, bar1, foo2, bar2]);
assert_equals(table.rows.foo, foo1);
assert_equals(table.rows["foo"], foo1);
assert_equals(table.rows.namedItem("foo"), foo1);
assert_equals(table.rows.bar, bar1);
assert_equals(table.rows["bar"], bar1);
assert_equals(table.rows.namedItem("bar"), bar1);
}
test(function() {
var table = document.createElement("table");
test_table_simple(table, table);
}, "Children of table");
test(function() {
var table = document.createElement("table");
var group = table.appendChild(document.createElement("thead"));
test_table_simple(group, table);
}, "Children of thead");
test(function() {
var table = document.createElement("table");
var group = table.appendChild(document.createElement("tbody"));
test_table_simple(group, table);
}, "Children of tbody");
test(function() {
var table = document.createElement("table");
var group = table.appendChild(document.createElement("tfoot"));
test_table_simple(group, table);
}, "Children of tfoot");
test(function() {
var table = document.createElement("table");
var orphan1 = table.appendChild(document.createElement("tr"));
orphan1.id = "orphan1";
var foot1 = table.appendChild(document.createElement("tfoot"));
var orphan2 = table.appendChild(document.createElement("tr"));
orphan2.id = "orphan2";
var foot2 = table.appendChild(document.createElement("tfoot"));
var orphan3 = table.appendChild(document.createElement("tr"));
orphan3.id = "orphan3";
var body1 = table.appendChild(document.createElement("tbody"));
var orphan4 = table.appendChild(document.createElement("tr"));
orphan4.id = "orphan4";
var body2 = table.appendChild(document.createElement("tbody"));
var orphan5 = table.appendChild(document.createElement("tr"));
orphan5.id = "orphan5";
var head1 = table.appendChild(document.createElement("thead"));
var orphan6 = table.appendChild(document.createElement("tr"));
orphan6.id = "orphan6";
var head2 = table.appendChild(document.createElement("thead"));
var orphan7 = table.appendChild(document.createElement("tr"));
orphan7.id = "orphan7";
var foot1row1 = foot1.appendChild(document.createElement("tr"));
foot1row1.id = "foot1row1";
var foot1row2 = foot1.appendChild(document.createElement("tr"));
foot1row2.id = "foot1row2";
var foot2row1 = foot2.appendChild(document.createElement("tr"));
foot2row1.id = "foot2row1";
var foot2row2 = foot2.appendChild(document.createElement("tr"));
foot2row2.id = "foot2row2";
var body1row1 = body1.appendChild(document.createElement("tr"));
body1row1.id = "body1row1";
var body1row2 = body1.appendChild(document.createElement("tr"));
body1row2.id = "body1row2";
var body2row1 = body2.appendChild(document.createElement("tr"));
body2row1.id = "body2row1";
var body2row2 = body2.appendChild(document.createElement("tr"));
body2row2.id = "body2row2";
var head1row1 = head1.appendChild(document.createElement("tr"));
head1row1.id = "head1row1";
var head1row2 = head1.appendChild(document.createElement("tr"));
head1row2.id = "head1row2";
var head2row1 = head2.appendChild(document.createElement("tr"));
head2row1.id = "head2row1";
var head2row2 = head2.appendChild(document.createElement("tr"));
head2row2.id = "head2row2";
// These elements should not end up in any collection.
table.appendChild(document.createElement("div"))
.appendChild(document.createElement("tr"));
foot1.appendChild(document.createElement("div"))
.appendChild(document.createElement("tr"));
body1.appendChild(document.createElement("div"))
.appendChild(document.createElement("tr"));
head1.appendChild(document.createElement("div"))
.appendChild(document.createElement("tr"));
table.appendChild(document.createElementNS("http://example.com/test", "tr"));
foot1.appendChild(document.createElementNS("http://example.com/test", "tr"));
body1.appendChild(document.createElementNS("http://example.com/test", "tr"));
head1.appendChild(document.createElementNS("http://example.com/test", "tr"));
assert_true(table.rows instanceof HTMLCollection, "table.rows should be a HTMLCollection.");
assert_nodelist_equals(table.rows, [
// thead
head1row1,
head1row2,
head2row1,
head2row2,
// tbody + table
orphan1,
orphan2,
orphan3,
body1row1,
body1row2,
orphan4,
body2row1,
body2row2,
orphan5,
orphan6,
orphan7,
// tfoot
foot1row1,
foot1row2,
foot2row1,
foot2row2
]);
var ids = [
"orphan1",
"orphan2",
"orphan3",
"orphan4",
"orphan5",
"orphan6",
"orphan7",
"foot1row1",
"foot1row2",
"foot2row1",
"foot2row2",
"body1row1",
"body1row2",
"body2row1",
"body2row2",
"head1row1",
"head1row2",
"head2row1",
"head2row2"
];
ids.forEach(function(id) {
assert_equals(table.rows.namedItem(id).id, id);
assert_true(id in table.rows);
assert_equals(table.rows[id].id, id);
assert_true(id in table.rows);
});
while (table.firstChild) {
table.removeChild(table.firstChild);
}
ids.forEach(function(id) {
assert_equals(table.rows.namedItem(id), null);
assert_false(id in table.rows);
assert_equals(table.rows[id], undefined);
assert_false(id in table.rows);
});
}, "Complicated case");
</script>

View file

@ -0,0 +1,77 @@
<!DOCTYPE html>
<title>HTMLTableRowElement.rowIndex</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var row = document.createElement("table")
.appendChild(document.createElement("div"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, -1);
});
test(function() {
var row = document.createElement("table")
.appendChild(document.createElement("thead"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, 0);
});
test(function() {
var row = document.createElement("table")
.appendChild(document.createElement("tbody"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, 0);
});
test(function() {
var row = document.createElement("table")
.appendChild(document.createElement("tfoot"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, 0);
});
test(function() {
var row = document.createElement("table")
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, 0);
});
test(function() {
var row = document.createElementNS("", "table")
.appendChild(document.createElement("thead"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, -1);
});
test(function() {
var row = document.createElementNS("", "table")
.appendChild(document.createElement("tbody"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, -1);
});
test(function() {
var row = document.createElementNS("", "table")
.appendChild(document.createElement("tfoot"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, -1);
});
test(function() {
var row = document.createElementNS("", "table")
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, -1);
});
test(function() {
var row = document.createElement("table")
.appendChild(document.createElementNS("", "thead"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, -1);
});
test(function() {
var row = document.createElement("table")
.appendChild(document.createElementNS("", "tbody"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, -1);
});
test(function() {
var row = document.createElement("table")
.appendChild(document.createElementNS("", "tfoot"))
.appendChild(document.createElement("tr"));
assert_equals(row.rowIndex, -1);
});
</script>

View file

@ -0,0 +1,130 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>HTMLTableRowElement.sectionRowIndex</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<table>
<thead>
<tr id="ht1"></tr>
</thead>
<tr id="t1"></tr>
<tr id="t2">
<td>
<table>
<thead>
<tr id="nht1"></tr>
</thead>
<tr></tr>
<tr id="nt1"></tr>
<tbody>
<tr id="nbt1"></tr>
</tbody>
</table>
</td>
</tr>
<tbody>
<tr></tr>
<tr id="bt1"></tr>
</tbody>
<tfoot>
<tr></tr>
<tr></tr>
<tr id="ft1"></tr>
</tfoot>
</table>
<script>
test(function() {
var tHeadRow = document.getElementById('ht1');
assert_equals(tHeadRow.sectionRowIndex, 0);
}, "Row in thead in HTML");
test(function() {
var tRow1 = document.getElementById('t1');
assert_equals(tRow1.sectionRowIndex, 0);
}, "Row in implicit tbody in HTML");
test(function() {
var tRow2 = document.getElementById('t2');
assert_equals(tRow2.sectionRowIndex, 1);
}, "Other row in implicit tbody in HTML");
test(function() {
var tBodyRow = document.getElementById('bt1');
assert_equals(tBodyRow.sectionRowIndex, 1);
}, "Row in explicit tbody in HTML");
test(function() {
var tFootRow = document.getElementById('ft1');
assert_equals(tFootRow.sectionRowIndex, 2);
}, "Row in tfoot in HTML");
test(function() {
var childHeadRow = document.getElementById('nht1');
assert_equals(childHeadRow.sectionRowIndex, 0);
}, "Row in thead in nested table in HTML");
test(function() {
var childRow = document.getElementById('nt1');
assert_equals(childRow.sectionRowIndex, 1);
}, "Row in implicit tbody in nested table in HTML");
test(function() {
var childBodyRow = document.getElementById('nbt1');
assert_equals(childBodyRow.sectionRowIndex, 0);
}, "Row in explicit tbody in nested table in HTML");
/* script create element test */
var mkTrElm = function (elst) {
var elm = document.createElement("table");
elst.forEach(function(item) {
elm = elm.appendChild(document.createElement(item));
});
return elm.appendChild(document.createElement("tr"));
};
test(function() {
assert_equals(mkTrElm([]).sectionRowIndex, 0);
}, "Row in script-created table");
test(function() {
assert_equals(mkTrElm(["div"]).sectionRowIndex, -1);
}, "Row in script-created div in table");
test(function() {
assert_equals(mkTrElm(["thead"]).sectionRowIndex, 0);
}, "Row in script-created thead in table");
test(function() {
assert_equals(mkTrElm(["tbody"]).sectionRowIndex, 0);
}, "Row in script-created tbody in table");
test(function() {
assert_equals(mkTrElm(["tfoot"]).sectionRowIndex, 0);
}, "Row in script-created tfoot in table");
test(function() {
assert_equals(mkTrElm(["tbody", "tr"]).sectionRowIndex, -1);
}, "Row in script-created tr in tbody in table");
test(function() {
assert_equals(mkTrElm(["tbody", "tr", "td"]).sectionRowIndex, -1);
}, "Row in script-created td in tr in tbody in table");
test(function() {
assert_equals(mkTrElm(["tbody", "tr", "td", "table"]).sectionRowIndex, 0);
}, "Row in script-created nested table");
test(function() {
assert_equals(mkTrElm(["tbody", "tr", "td", "table", "thead"]).sectionRowIndex, 0);
}, "Row in script-created thead in nested table");
test(function() {
assert_equals(mkTrElm(["tbody", "tr", "td", "table", "tbody"]).sectionRowIndex, 0);
}, "Row in script-created tbody in nested table");
test(function() {
assert_equals(mkTrElm(["tbody", "tr", "td", "table", "tfoot"]).sectionRowIndex, 0);
}, "Row in script-created tfoot in nested table");
</script>