summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/tabular-data
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/semantics/tabular-data
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/semantics/tabular-data')
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/META.yml2
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/attributes-common-to-td-and-th-elements/cellIndex.html50
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/historical.html25
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/html-table-section-element.js22
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html59
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/span-limits.html66
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-caption-element/caption_001.html70
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/caption-methods.html276
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/createTBody.html173
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/delete-caption.html94
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-01.html24
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-02.html34
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-03.html32
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/remove-row.html64
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tBodies.html40
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tFoot.html65
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tHead.html74
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/table-insertRow.html56
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-table-element/table-rows.html234
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/deleteRow.html61
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/insertRow.html56
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/rows.html15
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-tfoot-element/rows.html15
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-thead-element/rows.html15
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/cells.html28
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/deleteCell.html61
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/insertCell.html64
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/rowIndex.html77
-rw-r--r--testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/sectionRowIndex.html130
29 files changed, 1982 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/META.yml b/testing/web-platform/tests/html/semantics/tabular-data/META.yml
new file mode 100644
index 0000000000..ce84e4ae4c
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/META.yml
@@ -0,0 +1,2 @@
+suggested_reviewers:
+ - tkent-google
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/attributes-common-to-td-and-th-elements/cellIndex.html b/testing/web-platform/tests/html/semantics/tabular-data/attributes-common-to-td-and-th-elements/cellIndex.html
new file mode 100644
index 0000000000..b8449229d5
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/attributes-common-to-td-and-th-elements/cellIndex.html
@@ -0,0 +1,50 @@
+<!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.")
+test(function() {
+ var tr = document.createElement("tr");
+ var th = tr.appendChild(document.createElement("th"));
+ assert_equals(th.cellIndex, 0);
+ tr.appendChild(document.createElement("div"));
+ tr.appendChild(document.createTextNode("Hello World"));
+ var td = tr.appendChild(document.createElement("td"));
+ assert_equals(td.cellIndex, 1)
+}, "For cells whose parent is a tr with non td/th sibling, cellIndex should skip those non td/th siblings.")
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/historical.html b/testing/web-platform/tests/html/semantics/tabular-data/historical.html
new file mode 100644
index 0000000000..a6be56e13d
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/historical.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>Historical table features should not be supported</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+function t(property, tagNames) {
+ if (typeof tagNames === "string") {
+ tagNames = [tagNames];
+ }
+ tagNames.forEach(function(tagName) {
+ test(function() {
+ assert_false(property in document.createElement(tagName));
+ }, tagName + '.' + property + ' should not be supported');
+ });
+}
+
+// added in https://github.com/whatwg/html/commit/6db0d8d4e3456140de958c963afe9bb9ec7b6a25
+// removed in https://github.com/whatwg/html/commit/59b7e2466c2b7c5c408a4963b05b13fd808aa07a
+t('onsort', 'table');
+t('sortable', 'table');
+t('stopSorting', 'table');
+t('sorted', 'th');
+t('sort', 'th');
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/html-table-section-element.js b/testing/web-platform/tests/html/semantics/tabular-data/html-table-section-element.js
new file mode 100644
index 0000000000..68b68ceed8
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/html-table-section-element.js
@@ -0,0 +1,22 @@
+// https://html.spec.whatwg.org/multipage/#dom-tbody-rows
+function testRowsAttribute(localName) {
+ var elem = document.createElement(localName);
+ assert_equals(elem.rows.length, 0);
+
+ // Child <p> should *not* count as a row
+ elem.appendChild(document.createElement("p"));
+ assert_equals(elem.rows.length, 0);
+
+ // Child <tr> should count as a row
+ var childTr = document.createElement("tr");
+ elem.appendChild(childTr);
+ assert_equals(elem.rows.length, 1);
+
+ // Nested table with child <tr> should *not* count as a row
+ var nested = document.createElement(localName);
+ nested.appendChild(document.createElement("tr"));
+ var nestedTable = document.createElement("table");
+ nestedTable.appendChild(nested);
+ childTr.appendChild(nestedTable);
+ assert_equals(elem.rows.length, 1);
+}
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html b/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html
new file mode 100644
index 0000000000..a4a425b9c1
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/col-span-limits.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<title>Limits on col/colgroup.span</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<style>
+ div.square {
+ height:20px;
+ width:20px;
+ border:1px solid lime;
+ }
+ main table {
+ border-collapse:collapse;
+ border:1px solid blue;
+ }
+ main table col {
+ border-left:2px solid black;
+ }
+</style>
+<div id=log></div>
+<main>
+<table id=table1>
+ <col span=1000>
+ <tr>
+ <td colspan=999><div class="square"></div></td>
+ <td><div class="square"></div></td>
+ </tr>
+ <tr>
+ <td colspan=1000><div class="square"></div></td>
+ </tr>
+</table>
+<br>
+These two must look the same, each having 2 cells in one row:
+<table id=table2>
+ <col span=1000>
+ <tr>
+ <td colspan=1000><div class="square"></div></td>
+ <td><div class="square"></div></td>
+ </tr>
+</table>
+<br>
+<table id=table3>
+ <col span=1001>
+ <tr>
+ <td colspan=1000><div class="square"></div></td>
+ <td><div class="square"></div></td>
+ </tr>
+</table>
+</main>
+
+<script>
+test(() => {
+ assert_equals(table1.offsetWidth, 53);
+}, "col span of 1000 must work");
+
+test(() => {
+ assert_equals(table2.offsetWidth, 51, "table2 width");
+ assert_equals(table3.offsetWidth, 51, "table3 width");
+}, "col span of 1001 must be treated as 1000");
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/span-limits.html b/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/span-limits.html
new file mode 100644
index 0000000000..cdfa61bbcd
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/processing-model-1/span-limits.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<title>Limits on colSpan/rowSpan</title>
+<meta name="timeout" content="long">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id=log></div>
+
+<table border=1>
+ <tr><td colspan=500>a<td colspan=500 id=a1>a
+ <!-- This cell must span the previous two -->
+ <tr><td colspan=1000 id=a2>a
+</table>
+
+<table border=1>
+ <tr><td colspan=1000 id=b1>a<td>a
+ <!-- This cell must span only the first cell in the previous row -->
+ <tr><td colspan=1001 id=b2>a
+</table>
+
+<table border=1 style="float:left">
+ <!-- The first column must go all the way down to the bottom -->
+ <tr><td rowspan=65534 id=c1>a<td>
+ <!-- We'll add another 65533 rows later -->
+</table>
+
+<table border=1>
+ <!-- The first column must go one cell below the bottom -->
+ <tr><td rowspan=65535 id=d1>a<td>
+ <!-- We'll add another 65534 rows later -->
+</table>
+
+<script>
+var $ = document.querySelector.bind(document);
+
+test(() => {
+ assert_equals($("#a2").getBoundingClientRect().right,
+ $("#a1").getBoundingClientRect().right);
+}, "colspan of 1000 must work");
+
+test(() => {
+ assert_equals($("#b2").getBoundingClientRect().right,
+ $("#b1").getBoundingClientRect().right);
+}, "colspan of 1001 must be treated as 1000");
+
+test(() => {
+ var s = "";
+ for (var i = 0; i < 65532; i++) {
+ s += "<tr><td>";
+ }
+ s += "<tr><td id=c2>";
+ document.querySelectorAll("table")[2].firstElementChild.innerHTML += s;
+ assert_equals($("#c1").getBoundingClientRect().bottom,
+ $("#c2").getBoundingClientRect().bottom);
+}, "rowspan of 65534 must work");
+
+test(() => {
+ var s = "";
+ for (var i = 0; i < 65532; i++) {
+ s += "<tr><td>";
+ }
+ s += "<tr><td id=d2><tr><td>a<td>";
+ document.querySelectorAll("table")[3].firstElementChild.innerHTML += s;
+ assert_equals($("#d1").getBoundingClientRect().bottom,
+ $("#d2").getBoundingClientRect().bottom);
+}, "rowspan of 65535 must be treated as 65534");
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-caption-element/caption_001.html b/testing/web-platform/tests/html/semantics/tabular-data/the-caption-element/caption_001.html
new file mode 100644
index 0000000000..ecb1bef854
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-caption-element/caption_001.html
@@ -0,0 +1,70 @@
+<!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.firstChild, caption);
+ 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>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/caption-methods.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/caption-methods.html
new file mode 100644
index 0000000000..a349ed2b77
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/caption-methods.html
@@ -0,0 +1,276 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <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="table0" style="display:none">
+ </table>
+ <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">
+ <foo:caption>caption</foo:caption>
+ <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>
+ <table id="table4" style="display:none">
+ </table>
+ <table id="table5" style="display:none">
+ </table>
+ <table id="table6" style="display:none">
+ <caption id="caption6">caption 6</caption>
+ <tr>
+ <td>cell</td>
+ <td>cell</td>
+ </tr>
+ </table>
+ <table id="table7" style="display:none">
+ <caption id="caption7">caption 7</caption>
+ <tbody id="tbody7">
+ <tr>
+ <td>cell</td>
+ <td>cell</td>
+ </tr>
+ </tbody>
+ </table>
+ <table id="table10" style="display:none">
+ <tbody>
+ <tr>
+ <td>cell</td>
+ <td>cell</td>
+ </tr>
+ </tbody>
+ <caption>caption 10</caption>
+ </table>
+ <table id="table11" style="display:none">
+ <caption id="caption11">caption 11</caption>
+ </table>
+ <table id="table12" style="display:none">
+ <caption>caption 1</caption>
+ <caption>caption 2</caption>
+ </table>
+ <table id="table13" style="display:none">
+ </table>
+ <table id="table14" style="display:none">
+ <tbody>
+ <tr>
+ <td>cell</td>
+ <td>cell</td>
+ </tr>
+ </tbody>
+ <caption id="caption14">caption 14</caption>
+ </table>
+ <script>
+ test(function () {
+ var table0 = document.getElementById('table0');
+ var caption = document.createElementNS("foo", "caption");
+ table0.appendChild(caption);
+ var table0FirstNode = table0.firstChild;
+ var testCaption = table0.createCaption();
+ assert_not_equals(testCaption, table0FirstNode);
+ assert_equals(testCaption, table0.firstChild);
+ }, "createCaption method creates new caption if existing caption is not in html namespace")
+
+ 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 table = document.createElement('table');
+ assert_equals(table.createCaption(), table.createCaption());
+ }, "createCaption will not create new caption if one exists")
+
+ test(function () {
+ var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:table")
+ var caption = table.createCaption();
+ assert_equals(caption.prefix, null);
+ }, "createCaption will not copy table's prefix")
+
+ 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")
+
+ test(function () {
+ var table4 = document.getElementById('table4');
+ var caption = document.createElementNS("foo", "caption");
+ table4.appendChild(caption);
+ table4.deleteCaption();
+ assert_equals(caption.parentNode, table4);
+ }, "deleteCaption method not remove caption that is not in html namespace")
+
+ test(function() {
+ var table5 = document.getElementById('table5');
+ var caption = document.createElement('caption');
+ caption.appendChild(table5)
+
+ // Node cannot be inserted at the specified point in the hierarchy
+ assert_throws_dom("HierarchyRequestError", function() {
+ table5.caption = caption;
+ });
+
+ assert_not_equals(table5.caption, caption);
+ }, "Setting caption rethrows exception");
+
+ test(function() {
+ var table6 = document.getElementById("table6");
+ var caption = document.getElementById("caption6");
+ assert_equals(table6.caption, caption);
+
+ var newCaption = document.createElement("caption");
+ table6.caption = newCaption;
+ assert_equals(newCaption.parentNode, table6);
+ assert_equals(table6.firstChild, newCaption);
+ assert_equals(table6.caption, newCaption);
+ }, "Assigning a caption to table.caption")
+
+ test(function() {
+ var table7 = document.getElementById("table7");
+ var caption = document.getElementById("caption7");
+ assert_equals(table7.caption, caption);
+
+ table7.caption = null;
+ assert_equals(caption.parentNode, null);
+ assert_equals(table7.firstElementChild, document.getElementById("tbody7"));
+ assert_equals(table7.caption, null);
+ }, "Assigning null to table.caption")
+
+ test(function() {
+ var table8 = document.createElement("table");
+ var caption = document.createElement("captÄ°on");
+ assert_throws_js(TypeError, function() {
+ table8.caption = caption;
+ });
+ }, "Assigning a non-caption to table.caption")
+
+ test(function() {
+ var table9 = document.createElement("table");
+ var caption = document.createElementNS("http://www.example.com", "caption");
+ assert_throws_js(TypeError, function() {
+ table9.caption = caption;
+ });
+ }, "Assigning a foreign caption to table.caption")
+
+ test(function() {
+ var table = document.createElement("table");
+ var caption = document.createElement("caption");
+ caption.innerHTML = "new caption";
+ table.caption = caption;
+
+ assert_equals(caption.parentNode, table);
+ assert_equals(table.firstChild, caption);
+ assert_equals(table.caption.innerHTML, "new caption");
+ }, "Set table.caption when the table doesn't already have a caption")
+
+ test(function() {
+ var table10 = document.getElementById("table10");
+ var caption = document.createElement("caption");
+ caption.innerHTML = "new caption";
+ table10.caption = caption;
+
+ assert_equals(caption.parentNode, table10);
+ assert_equals(table10.firstChild, caption);
+ assert_equals(table10.caption.innerHTML, "new caption");
+
+ var captions = table10.getElementsByTagName('caption');
+ assert_equals(captions.length, 1);
+ }, "Set table.caption when the table has a caption child but with other siblings before it")
+
+ test(function() {
+ var table11 = document.getElementById("table11");
+ var caption = document.createElement("caption");
+ caption.innerHTML = "new caption";
+ table11.caption = caption;
+
+ assert_equals(caption.parentNode, table11);
+ assert_equals(table11.firstChild, caption);
+ assert_equals(table11.caption.innerHTML, "new caption");
+
+ var captions = table11.getElementsByTagName('caption');
+ assert_equals(captions.length, 1);
+ }, "Set table.caption when the table has a caption descendant")
+
+ test(function() {
+ var table12 = document.getElementById("table12");
+ var caption = document.createElement("caption");
+ caption.innerHTML = "new caption";
+ table12.caption = caption;
+
+ assert_equals(caption.parentNode, table12);
+ assert_equals(table12.firstChild, caption);
+ assert_equals(table12.caption.innerHTML, "new caption");
+
+ var captions = table12.getElementsByTagName('caption');
+ assert_equals(captions.length, 2);
+ assert_equals(captions[0].innerHTML, "new caption");
+ assert_equals(captions[1].innerHTML, "caption 2");
+ }, "Set table.caption when the table has two caption children")
+
+ promise_test(async t => {
+ var table13 = document.getElementById("table13");
+ var iframe = document.createElement("iframe");
+ iframe.srcdoc = '<table><caption id="caption13">caption 13</caption></table>';
+ document.body.appendChild(iframe);
+
+ var iframeWatcher = new EventWatcher(t, iframe, "load");
+ await iframeWatcher.wait_for("load");
+ var caption = iframe.contentWindow.document.getElementById("caption13");
+ table13.caption = caption;
+
+ assert_equals(caption.parentNode, table13);
+ assert_equals(table13.firstChild, caption);
+ assert_equals(table13.caption.innerHTML, "caption 13");
+
+ var captions = table13.getElementsByTagName('caption');
+ assert_equals(captions.length, 1);
+ }, "Assigning a caption has a different owner document to table.caption")
+
+ test(function() {
+ var table14 = document.getElementById("table14");
+ var caption = document.getElementById("caption14");
+ table14.caption = caption;
+
+ assert_equals(caption.parentNode, table14);
+ assert_equals(table14.firstChild, caption);
+
+ var captions = table14.getElementsByTagName('caption');
+ assert_equals(captions.length, 1);
+ }, "Assigning the caption already in the table to table.caption")
+ </script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/createTBody.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/createTBody.html
new file mode 100644
index 0000000000..6100aedfdf
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/createTBody.html
@@ -0,0 +1,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>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/delete-caption.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/delete-caption.html
new file mode 100644
index 0000000000..6183fa98b8
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/delete-caption.html
@@ -0,0 +1,94 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>deleteCaption()</title>
+ <link rel="author" title="Ben Boyle" href="mailto:benjamins.boyle@gmail.com">
+ <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>
+ <table id="one-caption">
+ <caption>Fixture table caption</caption>
+ </table>
+
+ <table id="two-captions">
+ <caption>Fixture table caption</caption>
+ <caption>A second caption element</caption>
+ </table>
+
+ <table id="zero-captions"></table>
+
+ <table id="descendent-caption">
+ <tr>
+ <td>
+ <table>
+ <caption>Nested caption</caption>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+ <script>
+ // The deleteCaption() method must remove the first caption element child of the table element, if any.
+ // https://html.spec.whatwgorg/multipage/tables.html#dom-table-deletecaption
+ test(function() {
+ var table = document.getElementById('one-caption');
+
+ table.deleteCaption();
+ assert_equals(table.getElementsByTagName('caption').length, 0, 'caption was removed');
+
+ }, 'deleteCaption() delete only caption on table');
+
+ test(function() {
+ var table = document.getElementById('one-caption');
+ var result;
+
+ result = table.deleteCaption();
+ // does .deleteCaption() have a return value?
+ assert_equals(result, undefined, '.deleteCaption() returns undefined');
+ }, 'deleteCaption() returns undefined');
+
+ test(function() {
+ var table = document.getElementById('two-captions');
+
+ table.deleteCaption();
+ assert_equals(table.getElementsByTagName('caption').length, 1, '1 caption (of 2) was removed');
+ assert_equals(table.getElementsByTagName('caption')[0].textContent, 'A second caption element', 'The first caption was removed');
+
+ // removing the only caption
+ table.deleteCaption();
+ assert_equals(table.getElementsByTagName('caption').length, 0, 'last caption was removed');
+ }, 'deleteCaption()');
+
+ test(function() {
+ var table = document.getElementById('zero-captions');
+ // removing a caption when none exists
+ table.deleteCaption();
+
+ assert_equals(table.getElementsByTagName('caption').length, 0, 'no exceptions using .deleteCaption() on a table without any captions');
+
+ }, 'deleteCaption() does not throw any exceptions when called on a table without a caption');
+
+ test(function() {
+ var table = document.getElementById( 'descendent-caption' );
+ table.deleteCaption();
+
+ assert_equals(table.getElementsByTagName('caption').length, 1, 'descendent caption was not deleted');
+ }, 'deleteCaption() does not delete captions in descendent tables');
+
+ test(function() {
+ var table = document.getElementById('zero-captions');
+ var caption;
+
+ caption = document.createElementNS('http://www.w3.org/2000/svg', 'caption');
+ table.insertBefore(caption, table.firstChild);
+ assert_equals(table.getElementsByTagName('caption').length, 1, 'SVG:caption is created');
+
+ table.deleteCaption();
+ assert_equals(table.getElementsByTagName('caption').length, 1, 'SVG:caption is not deleted');
+
+ }, 'deleteCaption() handles captions from different namespaces');
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-01.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-01.html
new file mode 100644
index 0000000000..8ed7b5fad6
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-01.html
@@ -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_dom("INDEX_SIZE_ERR", function() {
+ table.insertRow(-2);
+ })
+ assert_throws_dom("INDEX_SIZE_ERR", function() {
+ table.insertRow(2);
+ })
+});
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-02.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-02.html
new file mode 100644
index 0000000000..410425fb1e
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-02.html
@@ -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>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-03.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-03.html
new file mode 100644
index 0000000000..19c3ceb3c6
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/insertRow-method-03.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<title>insertRow(): non-empty table</title>
+<link rel="author" title="g-k" href="mailto:greg.guthe@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>
+ <tbody><tr id="first"></tr><tr id="second"></tr></tbody>
+ </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, 3);
+ assert_equals(table.rows.length, 2);
+ }, "table should start out with two rows")
+
+ var tr;
+ test(function() {
+ tr = table.insertRow(1);
+ assert_equals(tr.localName, "tr");
+ assert_equals(tr.namespaceURI, HTML);
+ assert_equals(table.getElementsByTagName("tr")[0].id, "first");
+ assert_equals(table.getElementsByTagName("tr")[1].id, "");
+ assert_equals(table.getElementsByTagName("tr")[2].id, "second");
+ }, "insertRow should insert a tr element before the second row")
+});
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/remove-row.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/remove-row.html
new file mode 100644
index 0000000000..43a128c57e
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/remove-row.html
@@ -0,0 +1,64 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>Delete Row tests</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<table id="element">
+ <thead>
+ <th>First column</th>
+ <th>Second column</th>
+ </thead>
+ <tbody>
+ <tr>
+ <td>1.1</td>
+ <td>1.2</td>
+ </tr>
+ <tr>
+ <td>2.1</td>
+ <td>2.2</td>
+ </tr>
+ </tbody>
+</table>
+
+<script>
+var el = document.getElementById('element');
+
+test(function() {
+ assert_throws_dom("IndexSizeError", function() {
+ el.deleteRow(-2)
+ })
+}, 'deleteRow function invalid argument');
+test(function() {
+ assert_throws_dom("IndexSizeError", function() {
+ el.deleteRow(el.rows.length)
+ })
+}, 'deleteRow function invalid argument bis');
+
+test(function() {
+ var old_length = el.rows.length;
+ el.insertRow(-1);
+ el.deleteRow(-1);
+ assert_equals(old_length, el.rows.length);
+}, "check normal deleteRow");
+test(function() {
+ assert_equals(el.rows.length, 3);
+ do {
+ var old_length = el.rows.length;
+ el.deleteRow(-1);
+ assert_equals(el.rows.length, old_length - 1);
+ } while (el.rows.length);
+}, "check normal deleteRow bis");
+
+test(function() {
+ assert_equals(el.rows.length, 0);
+ el.deleteRow(-1);
+}, 'deleteRow(-1) with no rows');
+
+test(function() {
+ assert_equals(el.rows.length, 0);
+ assert_throws_dom("IndexSizeError", function() {
+ el.deleteRow(0);
+ });
+}, 'deleteRow(0) with no rows');
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tBodies.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tBodies.html
new file mode 100644
index 0000000000..128dbc9f7d
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tBodies.html
@@ -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>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tFoot.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tFoot.html
new file mode 100644
index 0000000000..40220bc1e2
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tFoot.html
@@ -0,0 +1,65 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>tFoot tests</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<table id="t">
+<caption id="tcaption"></caption><thead id="thead"></thead><tbody id="tbody1"></tbody><tbody id="tbody2"></tbody><tfoot id="tfoot1"></tfoot><tfoot id="tfoot2"></tfoot><tfoot id="tfoot3"></tfoot></table>
+<script>
+test(function() {
+ var t = document.getElementById("t");
+ var tfoot1 = document.getElementById("tfoot1");
+
+ assert_equals(t.tFoot, tfoot1);
+
+ var tfoot2 = document.getElementById("tfoot2");
+ t.tFoot = null;
+
+ assert_equals(t.tFoot, tfoot2);
+
+ var tfoot3 = document.getElementById("tfoot3");
+ t.deleteTFoot();
+
+ assert_equals(t.tFoot, tfoot3);
+
+ var tfoot = t.createTFoot();
+ assert_equals(t.tFoot, tfoot);
+ assert_equals(tfoot, tfoot3);
+
+ t.deleteTFoot();
+ assert_equals(t.tFoot, null);
+
+ var tbody2 = document.getElementById("tbody2");
+
+ tfoot = t.createTFoot();
+ assert_equals(t.tFoot, tfoot);
+
+ assert_equals(t.tFoot.previousSibling, tbody2);
+ assert_equals(t.tFoot.nextSibling, null);
+
+ t.deleteTFoot();
+ assert_equals(t.tFoot, null);
+
+ t.tFoot = tfoot;
+ assert_equals(t.tFoot, tfoot);
+
+ assert_equals(t.tFoot.previousSibling, tbody2);
+ assert_equals(t.tFoot.nextSibling, null);
+
+ assert_throws_js(TypeError, function(){
+ t.tFoot = document.createElement("div");
+ });
+
+ assert_throws_dom("HierarchyRequestError", function(){
+ t.tFoot = document.createElement("thead");
+ });
+})
+
+test(function () {
+ var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:table")
+ var tfoot = table.createTFoot();
+
+ assert_equals(table.tFoot, tfoot);
+ assert_equals(tfoot.prefix, null);
+});
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tHead.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tHead.html
new file mode 100644
index 0000000000..fadebecd6f
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/tHead.html
@@ -0,0 +1,74 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>tHead tests</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<table id="t">
+<caption id="tcaption"></caption><thead id="thead1"></thead><thead id="thead2"></thead><thead id="thead3"></thead><tbody id="tbody1"></tbody><tbody id="tbody2"></tbody><tfoot id="tfoot"></tfoot>
+</table>
+<table>
+<thead id="t2thead">
+<td>
+<table id="t2">
+</table>
+</table>
+<script>
+test(function() {
+ var t = document.getElementById("t");
+ var thead1 = document.getElementById("thead1");
+
+ assert_equals(t.tHead, thead1);
+
+ var thead2 = document.getElementById("thead2");
+ t.tHead = null;
+
+ assert_equals(t.tHead, thead2);
+
+ var thead3 = document.getElementById("thead3");
+ t.deleteTHead();
+
+ assert_equals(t.tHead, thead3);
+
+ var thead = t.createTHead();
+ assert_equals(t.tHead, thead);
+ assert_equals(thead, thead3);
+
+ t.deleteTHead();
+ assert_equals(t.tHead, null);
+
+ var tcaption = document.getElementById("tcaption");
+ var tbody1 = document.getElementById("tbody1");
+
+ thead = t.createTHead();
+ assert_equals(t.tHead, thead);
+
+ assert_equals(t.tHead.previousSibling, tcaption);
+ assert_equals(t.tHead.nextSibling, tbody1);
+
+ assert_throws_js(TypeError, function(){
+ t.tHead = document.createElement("div");
+ });
+
+ assert_throws_dom("HierarchyRequestError", function(){
+ t.tHead = document.createElement("tbody");
+ });
+
+});
+
+test(function() {
+ var t2 = document.getElementById("t2");
+ var t2thead = document.getElementById("t2thead");
+
+ assert_throws_dom("HierarchyRequestError", function() {
+ t2.tHead = t2thead;
+ });
+});
+
+test(function () {
+ var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:table")
+ var thead = table.createTHead();
+
+ assert_equals(table.tHead, thead);
+ assert_equals(thead.prefix, null);
+});
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/table-insertRow.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/table-insertRow.html
new file mode 100644
index 0000000000..8a9574ecdd
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/table-insertRow.html
@@ -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>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/table-rows.html b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/table-rows.html
new file mode 100644
index 0000000000..8bc23d5a7c
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-table-element/table-rows.html
@@ -0,0 +1,234 @@
+<!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);
+ assert_array_equals(Object.getOwnPropertyNames(table.rows), [
+ "0",
+ "1",
+ "2",
+ "3",
+ "foo",
+ "bar"
+ ]);
+}
+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
+ ]);
+ assert_array_equals(Object.getOwnPropertyNames(table.rows), [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "head1row1",
+ "head1row2",
+ "head2row1",
+ "head2row2",
+ "orphan1",
+ "orphan2",
+ "orphan3",
+ "body1row1",
+ "body1row2",
+ "orphan4",
+ "body2row1",
+ "body2row2",
+ "orphan5",
+ "orphan6",
+ "orphan7",
+ "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>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/deleteRow.html b/testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/deleteRow.html
new file mode 100644
index 0000000000..695c1ea50b
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/deleteRow.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTMLTableSectionElement#deleteRow</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<div id ="log"></div>
+
+<table>
+ <tbody id="testBody">
+ <tr><td>ABCDEF</td></tr>
+ <tr><td>12345</td></tr>
+ <tr><td>ABC12345DEF</td></tr>
+ </tbody>
+</table>
+
+<script>
+
+var tbody = document.getElementById("testBody");
+
+test(function () {
+ tbody.deleteRow(0);
+ assert_equals(tbody.rows.length, 2);
+ assert_equals(tbody.rows[0].childNodes[0].innerHTML, "12345");
+}, "HTMLTableSectionElement deleteRow(0)");
+
+test(function () {
+ tbody.deleteRow(-1);
+ assert_equals(tbody.rows.length, 1);
+ assert_equals(tbody.rows[0].childNodes[0].innerHTML, "12345");
+}, "HTMLTableSectionElement deleteRow(-1)");
+
+test(function () {
+ assert_throws_dom("IndexSizeError", function () {
+ tbody.deleteRow(tbody.rows.length);
+ });
+}, "HTMLTableSectionElement deleteRow(rows.length)");
+
+test(function () {
+ assert_throws_dom("IndexSizeError", function () {
+ tbody.deleteRow(-2);
+ });
+}, "HTMLTableSectionElement deleteRow(-2)");
+
+test(function () {
+ assert_equals(tbody.rows.length, 1);
+ tbody.deleteRow(-1);
+ assert_equals(tbody.rows.length, 0);
+ tbody.deleteRow(-1);
+ assert_equals(tbody.rows.length, 0);
+}, "HTMLTableSectionElement deleteRow(-1) with no rows");
+
+test(function () {
+ assert_equals(tbody.rows.length, 0);
+ assert_throws_dom("IndexSizeError", function () {
+ tbody.deleteRow(0);
+ });
+}, "HTMLTableSectionElement deleteRow(0) with no rows");
+
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/insertRow.html b/testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/insertRow.html
new file mode 100644
index 0000000000..f5c2227ca6
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/insertRow.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTMLTableSectionElement#insertRow</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<div id ="log"></div>
+
+<table>
+ <tbody id="testBody">
+ <tr><td>ABCDEF</td></tr>
+ </tbody>
+</table>
+
+<script>
+
+var tbody = document.getElementById("testBody");
+
+test(function () {
+ var trEle = tbody.insertRow(0);
+ assert_equals(tbody.rows[0], trEle);
+ assert_equals(tbody.rows.length, 2);
+}, "HTMLTableSectionElement insertRow(0)");
+
+test(function () {
+ var trEle = tbody.insertRow(-1);
+ assert_equals(tbody.rows[tbody.rows.length - 1], trEle);
+ assert_equals(tbody.rows.length, 3);
+}, "HTMLTableSectionElement insertRow(-1)");
+
+test(function () {
+ var trEle = tbody.insertRow();
+ assert_equals(tbody.rows[tbody.rows.length - 1], trEle);
+ assert_equals(tbody.rows.length, 4);
+}, "HTMLTableSectionElement insertRow()");
+
+test(function () {
+ var trEle = tbody.insertRow(tbody.rows.length);
+ assert_equals(tbody.rows[tbody.rows.length - 1], trEle);
+ assert_equals(tbody.rows.length, 5);
+}, "HTMLTableSectionElement insertRow(rows.length)");
+
+test(function () {
+ assert_throws_dom("IndexSizeError", function () {
+ tbody.insertRow(-2);
+ });
+}, "HTMLTableSectionElement insertRow(-2)");
+
+test(function () {
+ assert_throws_dom("IndexSizeError", function () {
+ tbody.insertRow(tbody.rows.length + 1);
+ });
+}, "HTMLTableSectionElement insertRow(rows.length + 1)");
+
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/rows.html b/testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/rows.html
new file mode 100644
index 0000000000..eb155de774
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-tbody-element/rows.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>'tbody' element, 'rows' attribute</title>
+<link rel="author" title="Corey Farwell" href="mailto:coreyf@rwell.org">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/html/semantics/tabular-data/html-table-section-element.js"></script>
+
+<div id ="log"></div>
+
+<script>
+test(function () {
+ testRowsAttribute('tbody');
+});
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-tfoot-element/rows.html b/testing/web-platform/tests/html/semantics/tabular-data/the-tfoot-element/rows.html
new file mode 100644
index 0000000000..fe70d6f286
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-tfoot-element/rows.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>'tfoot' element, 'rows' attribute</title>
+<link rel="author" title="Corey Farwell" href="mailto:coreyf@rwell.org">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/html/semantics/tabular-data/html-table-section-element.js"></script>
+
+<div id ="log"></div>
+
+<script>
+test(function () {
+ testRowsAttribute('tfoot');
+});
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-thead-element/rows.html b/testing/web-platform/tests/html/semantics/tabular-data/the-thead-element/rows.html
new file mode 100644
index 0000000000..7830281a01
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-thead-element/rows.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>'thead' element, 'rows' attribute</title>
+<link rel="author" title="Corey Farwell" href="mailto:coreyf@rwell.org">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/html/semantics/tabular-data/html-table-section-element.js"></script>
+
+<div id ="log"></div>
+
+<script>
+test(function () {
+ testRowsAttribute('thead');
+});
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/cells.html b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/cells.html
new file mode 100644
index 0000000000..2678d3b1c2
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/cells.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTMLTableRowElement#cells</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<div id="log"></div>
+
+<table>
+ <tr id="testTr">
+ <td>First</td>
+ <div><td>Second</td></div>
+ <td>Third
+ <table>
+ <tr><td>Nested first</td></tr>
+ </table>
+ </td>
+ <img>
+ </tr>
+</table>
+<script>
+var tr = document.getElementById("testTr");
+
+test(function () {
+ tr.insertBefore(document.createElementNS("foo", "td"), tr.children[1]);
+ assert_array_equals(tr.cells, [tr.children[0], tr.children[2], tr.children[3]]);
+}, "HTMLTableRowElement cells ignores nested tables and non-HTML elements");
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/deleteCell.html b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/deleteCell.html
new file mode 100644
index 0000000000..9962617a71
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/deleteCell.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTMLTableRowElement#deleteCell</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<div id="log"></div>
+
+<table>
+ <tr id="testTr">
+ <td>ABCDE</td>
+ <td>12345</td>
+ <td>ABC12</td>
+ </tr>
+</table>
+
+<script>
+
+var tr = document.getElementById("testTr");
+
+test(function () {
+ tr.deleteCell(0);
+ assert_equals(tr.cells[0].innerHTML, "12345");
+ assert_equals(tr.cells.length, 2);
+}, "HTMLTableRowElement deleteCell(0)");
+
+test(function () {
+ tr.deleteCell(-1);
+ assert_equals(tr.cells[tr.cells.length - 1].innerHTML, "12345");
+ assert_equals(tr.cells.length, 1);
+}, "HTMLTableRowElement deleteCell(-1)");
+
+test(function () {
+ assert_throws_dom("IndexSizeError", function () {
+ tr.deleteCell(-2);
+ });
+}, "HTMLTableRowElement deleteCell(-2)");
+
+test(function () {
+ assert_throws_dom("IndexSizeError", function () {
+ tr.deleteCell(tr.cells.length);
+ });
+}, "HTMLTableRowElement deleteCell(cells.length)");
+
+test(function () {
+ assert_equals(tr.cells.length, 1);
+ tr.deleteCell(-1);
+ assert_equals(tr.cells.length, 0);
+ tr.deleteCell(-1);
+ assert_equals(tr.cells.length, 0);
+}, "HTMLTableRowElement deleteCell(-1) with no cells");
+
+test(function () {
+ assert_equals(tr.cells.length, 0);
+ assert_throws_dom("IndexSizeError", function () {
+ tr.deleteCell(0);
+ });
+}, "HTMLTableRowElement deleteCell(0) with no cells");
+
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/insertCell.html b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/insertCell.html
new file mode 100644
index 0000000000..11cd213fe7
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/insertCell.html
@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>HTMLTableRowElement#insertCell</title>
+<link rel="author" title="Intel" href="http://www.intel.com/">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<div id="log"></div>
+
+<table>
+ <tr id="testTr"></tr>
+</table>
+
+<script>
+
+var tr = document.getElementById("testTr");
+
+test(function () {
+ var tdEle = tr.insertCell(0);
+ assert_equals(tr.cells[0], tdEle);
+ assert_equals(tr.cells.length, 1);
+}, "HTMLTableRowElement insertCell(0)");
+
+test(function () {
+ var tdEle = tr.insertCell(-1);
+ assert_equals(tr.cells[tr.cells.length - 1], tdEle);
+ assert_equals(tr.cells.length, 2);
+}, "HTMLTableRowElement insertCell(-1)");
+
+
+test(function () {
+ var tdEle = tr.insertCell(tr.cells.length);
+ assert_equals(tr.cells[tr.cells.length - 1], tdEle);
+ assert_equals(tr.cells.length, 3);
+}, "HTMLTableRowElement insertCell(cells.length)");
+
+test(function () {
+ var tdEle = tr.insertCell();
+ assert_equals(tr.cells[tr.cells.length - 1], tdEle);
+ assert_equals(tr.cells.length, 4);
+}, "HTMLTableRowElement insertCell()");
+
+test(function () {
+ assert_throws_dom("IndexSizeError", function () {
+ tr.insertCell(-2);
+ });
+}, "HTMLTableRowElement insertCell(-2)");
+
+test(function () {
+ assert_throws_dom("IndexSizeError", function () {
+ tr.insertCell(tr.cells.length + 1);
+ });
+}, "HTMLTableRowElement insertCell(cells.length + 1)");
+
+test(function () {
+ var table = document.createElementNS("http://www.w3.org/1999/xhtml", "foo:table")
+ var row = table.insertRow(0);
+ var cell = row.insertCell(0);
+
+ assert_equals(row.cells[0], cell);
+ assert_equals(cell.prefix, null);
+}, "HTMLTableRowElement insertCell will not copy table's prefix");
+
+</script>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/rowIndex.html b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/rowIndex.html
new file mode 100644
index 0000000000..117712563d
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/rowIndex.html
@@ -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>
diff --git a/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/sectionRowIndex.html b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/sectionRowIndex.html
new file mode 100644
index 0000000000..ef5366739e
--- /dev/null
+++ b/testing/web-platform/tests/html/semantics/tabular-data/the-tr-element/sectionRowIndex.html
@@ -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>