Mochitest for Bug 630841 - Crash in nsHyperTextAccessible::GetText(), r=surkov GECKO20b11_2011020209_RELBRANCH
authorFernando Herrera <fherrera@onirica.com>
Thu, 03 Feb 2011 19:00:31 +0100
branchGECKO20b11_2011020209_RELBRANCH
changeset 61867 bb8247382c3e27be839e83eec90e946eb9209f48
parent 61866 6d9ac157fc84be6c489ecfcdc6a4dfb5fc3b8b0d
child 61868 7893f45c72c5dd307ed6747c7d351375586bcad9
push idunknown
push userunknown
push dateunknown
reviewerssurkov
bugs630841
milestone2.0b11
Mochitest for Bug 630841 - Crash in nsHyperTextAccessible::GetText(), r=surkov
accessible/tests/mochitest/hypertext/test_update.html
--- a/accessible/tests/mochitest/hypertext/test_update.html
+++ b/accessible/tests/mochitest/hypertext/test_update.html
@@ -85,24 +85,64 @@
       }
 
       this.getID = function updateText_getID()
       {
         return "update text for '" + aContainerID + "'";
       }
     }
 
+    /**
+     * Text offsets must be updated when hypertext child is removed.
+     */
+    function removeChild(aContainerID, aChildID, aInitialText, aFinalText)
+    {
+      this.containerNode = getNode(aContainerID);
+      this.container = getAccessible(this.containerNode, nsIAccessibleText);
+      this.childNode = getNode(aChildID);
+
+      // Call first to getText so offsets are cached
+      is(this.container.getText(0, -1), aInitialText,
+         "Wrong text before child removal");
+
+      this.eventSeq = [
+        new invokerChecker(EVENT_REORDER, this.containerNode)
+      ];
+
+      this.invoke = function removeChild_invoke()
+      {
+        this.containerNode.removeChild(this.childNode);
+      }
+
+      this.finalCheck = function removeChild_finalCheck()
+      {
+        is(this.container.getText(0, -1), aFinalText,
+           "Wrong text after child removal");
+        is(this.container.characterCount, aFinalText.length,
+           "Wrong text after child removal");
+      }
+
+      this.getID = function removeChild_getID()
+      {
+        return "check text after removing child from '" + aContainerID + "'";
+      }
+    }
+
+
+
     //gA11yEventDumpToConsole = true; // debug stuff
 
     var gQueue = null;
     function doTest()
     {
       gQueue = new eventQueue();
       gQueue.push(new addLinks("p1"));
       gQueue.push(new updateText("p2"));
+      gQueue.push(new removeChild("div1","div2",
+                                  "hello my good friend", "hello friend"));
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
@@ -112,18 +152,24 @@
      title="Cache links within hypertext accessible"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=572394">
     Mozilla Bug 572394
   </a>
   <a target="_blank"
      title="Text offsets don't get updated when text of first child text accessible is changed"
      href="https://bugzilla.mozilla.org/show_bug.cgi?id=625009">
     Mozilla Bug 625009
+  </a>
+  <a target="_blank"
+     title="Crash in nsHyperTextAccessible::GetText()"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=630841">
+    Mozilla Bug 630841
   </a><br>
   <p id="display"></p>
   <div id="content" style="display: none"></div>
   <pre id="test">
   </pre>
 
   <p id="p1"></p>
   <p id="p2"><b>hello</b><a>friend</a></p>
+  <div id="div1">hello<span id="div2"> my<span id="div3"> good</span></span> friend</span></div>
 </body>
 </html>