Bug 900943 - Multiline textbox contains bogus <br>. r=tbsaunde, a=akeybl
authorAlexander Surkov <surkov.alexander@gmail.com>
Mon, 05 Aug 2013 22:09:05 -0400
changeset 153671 09b3abb00078d1a0e33291ae3a1e3a6947d5b03a
parent 153670 67a933f6521ff4976544052387acb6ea609c007e
child 153672 5ad8291595325a490d964a04a1a8678e5d4a5ed1
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde, akeybl
bugs900943
milestone25.0a2
Bug 900943 - Multiline textbox contains bogus <br>. r=tbsaunde, a=akeybl
accessible/src/xul/XULFormControlAccessible.cpp
accessible/tests/mochitest/text/Makefile.in
accessible/tests/mochitest/text/test_general.xul
accessible/tests/mochitest/text/test_label.xul
accessible/tests/mochitest/tree/test_txtctrl.xul
--- a/accessible/src/xul/XULFormControlAccessible.cpp
+++ b/accessible/src/xul/XULFormControlAccessible.cpp
@@ -812,20 +812,27 @@ XULTextFieldAccessible::CacheChildren()
 {
   NS_ENSURE_TRUE_VOID(mDoc);
   // Create child accessibles for native anonymous content of underlying HTML
   // input element.
   nsCOMPtr<nsIContent> inputContent(GetInputField());
   if (!inputContent)
     return;
 
+  // XXX: entry shouldn't contain anything but text leafs. Currently it may
+  // contain a trailing fake HTML br element added for layout needs. We don't
+  // need to expose it since it'd be confusing for AT.
   TreeWalker walker(this, inputContent);
-
   Accessible* child = nullptr;
-  while ((child = walker.NextChild()) && AppendChild(child));
+  while ((child = walker.NextChild())) {
+    if (child->IsTextLeaf())
+      AppendChild(child);
+    else
+      Document()->UnbindFromDocument(child);
+  }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTextFieldAccessible: HyperTextAccessible protected
 
 already_AddRefed<nsFrameSelection>
 XULTextFieldAccessible::FrameSelection()
 {
--- a/accessible/tests/mochitest/text/Makefile.in
+++ b/accessible/tests/mochitest/text/Makefile.in
@@ -11,19 +11,19 @@ relativesrcdir	= @relativesrcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MOCHITEST_A11Y_FILES = \
 		doc.html \
 		test_atcaretoffset.html \
 		test_charboundary.html \
 		test_doc.html \
+		test_general.xul \
 		test_gettext.html \
 		test_hypertext.html \
 		test_lineboundary.html \
-		test_label.xul \
 		test_passwords.html \
 		test_selection.html \
 		test_wordboundary.html \
 		test_words.html \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
rename from accessible/tests/mochitest/text/test_label.xul
rename to accessible/tests/mochitest/text/test_general.xul
--- a/accessible/tests/mochitest/text/test_label.xul
+++ b/accessible/tests/mochitest/text/test_general.xul
@@ -21,44 +21,60 @@
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Testing
 
     var gQueue = null;
     function doTests()
     {
+      //////////////////////////////////////////////////////////////////////////
+      // XUL label
+
       var ids = ["label1", "label2"];
 
       testCharacterCount(ids, 5);
 
       testText(ids, 0, -1, "Hello");
       testText(ids, 0, 1, "H");
 
       testCharAfterOffset(ids, 0, "e", 1, 2);
       testCharBeforeOffset(ids, 1, "H", 0, 1);
       testCharAtOffset(ids, 1, "e", 1, 2);
 
+      //////////////////////////////////////////////////////////////////////////
+      // XUL textbox
+
+      testTextAtOffset([ "tbox1" ], BOUNDARY_LINE_START,
+                       [ [ 0, 4, "test", 0, 4 ] ]);
+
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTests);
   ]]>
   </script>
 
   <vbox flex="1" style="overflow: auto;">
   <body xmlns="http://www.w3.org/1999/xhtml">
     <a target="_blank"
         href="https://bugzilla.mozilla.org/show_bug.cgi?id=396166"
         title="xul:label@value accessible should implement nsIAccessibleText">
       Bug 396166
     </a>
+    <a target="_blank"
+        href="https://bugzilla.mozilla.org/show_bug.cgi?id=899433"
+        title="Accessibility returns empty line for last line in certain cases">
+      Bug 899433
+    </a>
     <p id="display"></p>
     <div id="content" style="display: none">
     </div>
     <pre id="test">
     </pre>
   </body>
   <label id="label1" value="Hello"/>
   <label id="label2">Hello</label>
+
+  <textbox id="tbox1" value="test" multiline="true"/>
   </vbox>
 </window>
--- a/accessible/tests/mochitest/tree/test_txtctrl.xul
+++ b/accessible/tests/mochitest/tree/test_txtctrl.xul
@@ -67,20 +67,16 @@
       // multiline textbox
       ////////////////////
       accTree = {
         role: ROLE_ENTRY,
         children: [
           {
             role: ROLE_TEXT_LEAF,
             children: []
-          },
-          {
-            role: ROLE_WHITESPACE,
-            children: []
           }
         ]
       };
 
       testAccessibleTree("txc6", accTree);
 
       ////////////////////
       // autocomplete textbox