Bug 630841 - add mochitest for bug 630841, r=surkov, a=test
authorFernando Herrera <fherrera@onirica.com>
Thu, 03 Feb 2011 22:28:57 +0800
changeset 61841 02b5151b2a191b0e10074fb4ccf92f2a58d27404
parent 61840 f911fba0ea0bc71b96d788e42b4d2c96e05958ba
child 61842 f6cbc806e87cdf852218c232bd261666a4844f88
push idunknown
push userunknown
push dateunknown
reviewerssurkov, test
bugs630841
milestone2.0b12pre
Bug 630841 - add mochitest for bug 630841, r=surkov, a=test
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>