Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for createTBody. #95

Merged
merged 1 commit into from
May 9, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions html/semantics/tabular-data/the-table-element/MANIFEST
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
createTBody.html
insertRow-method-01.html
insertRow-method-02.html
table-insertRow.html
Expand Down
165 changes: 165 additions & 0 deletions html/semantics/tabular-data/the-table-element/createTBody.html
Original file line number Diff line number Diff line change
@@ -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>