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
authorOphir LOJKINE <pere.jobs@gmail.com>
Thu, 01 May 2014 21:29:23 -0400
changeset 181315 864680954235e3154122d813693614906d6f6d74
parent 181314 cfa3ce9b653fcde310010053e2832daa15316f47
child 181316 b9ba9a6b8a97bc4258fb6d0e911a5efa13fc6398
push id26699
push usercbook@mozilla.com
push dateFri, 02 May 2014 12:30:59 +0000
treeherdermozilla-central@66ea09d0c951 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1003539
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
content/html/content/src/HTMLTableElement.cpp
content/html/content/test/mochitest.ini
content/html/content/test/test_bug1003539.html
dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/test_table-insertRow.html.json
--- a/content/html/content/src/HTMLTableElement.cpp
+++ b/content/html/content/src/HTMLTableElement.cpp
@@ -543,27 +543,22 @@ HTMLTableElement::InsertRow(int32_t aInd
       }
 
       if (aError.Failed()) {
         return nullptr;
       }
     }
   } 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;
       }
     }
 
     if (!rowGroup) { // need to create a TBODY
       nsCOMPtr<nsINodeInfo> nodeInfo;
       nsContentUtils::NameChanged(mNodeInfo, nsGkAtoms::tbody,
--- a/content/html/content/test/mochitest.ini
+++ b/content/html/content/test/mochitest.ini
@@ -405,16 +405,17 @@ skip-if = (toolkit == 'gonk' && debug) |
 [test_bug845057.html]
 [test_bug869040.html]
 [test_bug870787.html]
 [test_bug874758.html]
 [test_bug879319.html]
 [test_bug885024.html]
 [test_bug893537.html]
 [test_bug969346.html]
+[test_bug1003539.html]
 [test_change_crossorigin.html]
 [test_checked.html]
 [test_dir_attributes_reflection.html]
 [test_dl_attributes_reflection.html]
 [test_element_prototype.html]
 [test_embed_attributes_reflection.html]
 [test_formData.html]
 [test_formSubmission.html]
new file mode 100644
--- /dev/null
+++ b/content/html/content/test/test_bug1003539.html
@@ -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>
--- a/dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/test_table-insertRow.html.json
+++ b/dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/test_table-insertRow.html.json
@@ -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
 }