1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
<!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");
test(function() {
var table = document.createElementNS(htmlNS, "foo:table");
var tbody = table.createTBody();
assert_equals(tbody.prefix, null);
}, "A prefixed table creates tbody without prefix");
</script>
|