Bug 819303 - crash in nsTextEquivUtils::AppendTextEquivFromTextContent. f=marcoz r=surkov
authorDavid Bolter <dbolter@mozilla.com>
Fri, 07 Dec 2012 12:27:17 -0500
changeset 115529 3968fd8edddbe750d4cb57f1bdc32ea68f1959f1
parent 115528 0a8ba2e0ed05bba9e22b2a1b57ac767595016729
child 115530 87c445df408d5cb0e3f1733e0ed387020494a159
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerssurkov
bugs819303
milestone20.0a1
Bug 819303 - crash in nsTextEquivUtils::AppendTextEquivFromTextContent. f=marcoz r=surkov
accessible/src/html/HTMLTableAccessible.cpp
accessible/tests/mochitest/attributes/test_obj.html
--- a/accessible/src/html/HTMLTableAccessible.cpp
+++ b/accessible/src/html/HTMLTableAccessible.cpp
@@ -116,19 +116,21 @@ HTMLTableCellAccessible::NativeAttribute
   // abbr attribute
 
   // Pick up object attribute from abbr DOM element (a child of the cell) or
   // from abbr DOM attribute.
   nsAutoString abbrText;
   if (ChildCount() == 1) {
     Accessible* abbr = FirstChild();
     if (abbr->IsAbbreviation()) {
-      nsTextEquivUtils::
-        AppendTextEquivFromTextContent(abbr->GetContent()->GetFirstChild(),
-                                       &abbrText);
+      nsIContent* firstChildNode = abbr->GetContent()->GetFirstChild();
+      if (firstChildNode) {
+        nsTextEquivUtils::
+          AppendTextEquivFromTextContent(firstChildNode, &abbrText);
+      }
     }
   }
   if (abbrText.IsEmpty())
     mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::abbr, abbrText);
 
   if (!abbrText.IsEmpty())
     nsAccUtils::SetAccAttr(attributes, nsGkAtoms::abbr, abbrText);
 
--- a/accessible/tests/mochitest/attributes/test_obj.html
+++ b/accessible/tests/mochitest/attributes/test_obj.html
@@ -95,16 +95,19 @@ https://bugzilla.mozilla.org/show_bug.cg
       // html
       testAttrs("radio", {"checkable" : "true"}, true); 
       testAttrs("checkbox", {"checkable" : "true"}, true); 
       testAttrs("draggable", {"draggable" : "true"}, true);
       testAttrs("th1", { "abbr": "SS#" }, true);
       testAttrs("th2", { "abbr": "SS#" }, true);
       testAttrs("th2", { "axis": "social" }, true);
 
+      // don't barf on an empty abbr element.
+      testAbsentAttrs("th3", { "abbr": "" }, true);
+
       // application accessible
       if (WIN) {
         var gfxInfo = Components.classes["@mozilla.org/gfx/info;1"].
           getService(Components.interfaces.nsIGfxInfo);
         var attrs = {
           "D2D": (gfxInfo.D2DEnabled ? "true" : "false")
         }
         testAttrs(getApplicationAccessible(), attrs, false);
@@ -149,16 +152,21 @@ https://bugzilla.mozilla.org/show_bug.cg
      title="Add test coverage for tablist as implicit live region">
     Mozilla Bug 663136
   </a>
   <a target="_blank"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=563862"
      title="Expand support for nsIAccessibleEvent::OBJECT_ATTRIBUTE_CHANGE">
     Mozilla Bug 563862
   </a>
+  <a target="_blank"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=819303"
+     title="crash in nsTextEquivUtils::AppendTextEquivFromTextContent">
+    Mozilla Bug 819303
+  </a>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <!-- aria -->
   <div id="atomic" aria-atomic="true"></div>
   <div id="autocomplete" role="textbox" aria-autocomplete="true"></div>
@@ -206,16 +214,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   <!-- html -->
   <input id="radio" type="radio"/>
   <input id="checkbox" type="checkbox"/>
   <div id="draggable" draggable="true">Draggable div</div>
   <table>
     <tr>
       <th id="th1"><abbr title="Social Security Number">SS#</abbr></th>
       <th id="th2" abbr="SS#" axis="social">Social Security Number</th>
+      <th id="th3"><abbr></abbr></th>
     </tr>
   </table>
 
   <ul>
     <li id="listitem">item
   </ul>
 
   <!-- experimental aria -->