Bug 1003539 - change HTMLTableElement::insertRow so that it when no row is present, it adds a row to the last TBODY element of the table; r=bzbarsky

This commit is contained in:
Ophir LOJKINE 2014-05-01 21:29:23 -04:00
parent 18ed3a9494
commit ba35dedd06
4 changed files with 43 additions and 12 deletions

View File

@ -548,17 +548,12 @@ HTMLTableElement::InsertRow(int32_t aIndex, ErrorResult& aError)
}
} else {
// the row count was 0, so
// find the first row group and insert there as first child
// find the last row group and insert there as first child
nsCOMPtr<nsIContent> rowGroup;
for (nsIContent* child = nsINode::GetFirstChild();
for (nsIContent* child = nsINode::GetLastChild();
child;
child = child->GetNextSibling()) {
nsINodeInfo *childInfo = child->NodeInfo();
nsIAtom *localName = childInfo->NameAtom();
if (childInfo->NamespaceID() == kNameSpaceID_XHTML &&
(localName == nsGkAtoms::thead ||
localName == nsGkAtoms::tbody ||
localName == nsGkAtoms::tfoot)) {
child = child->GetPreviousSibling()) {
if (child->IsHTML(nsGkAtoms::tbody)) {
rowGroup = child;
break;
}

View File

@ -410,6 +410,7 @@ skip-if = (toolkit == 'gonk' && debug) || e10s #debug-only failure
[test_bug885024.html]
[test_bug893537.html]
[test_bug969346.html]
[test_bug1003539.html]
[test_change_crossorigin.html]
[test_checked.html]
[test_dir_attributes_reflection.html]

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1003539
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1003539</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 1003539 **/
// Refering to this specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/tabular-data.html#dom-table-insertrow
var tab;
tab = document.createElement("table");
tab.createTHead();
tab.insertRow();
is(tab.innerHTML, '<thead></thead><tbody><tr></tr></tbody>', "Row should be inserted in the tbody.");
tab = document.createElement("table");
tab.createTBody();
tab.createTBody();
tab.insertRow();
is(tab.innerHTML, '<tbody></tbody><tbody><tr></tr></tbody>', "Row should be inserted in the last tbody.");
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1003539">Mozilla Bug 1003539</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>

View File

@ -1,5 +1,3 @@
{
"insertRow should not copy prefixes": true,
"insertRow should insert into a tbody, not into a thead, if table.rows is empty": true,
"insertRow should insert into a tbody, not into a tfoot, if table.rows is empty": true
"insertRow should not copy prefixes": true
}