Bug 1268069 - Embeded object collection may be not updated on removals. r=yzen, a=ritu
authorAlexander Surkov <surkov.alexander@gmail.com>
Wed, 25 May 2016 15:48:45 -0400
changeset 333082 2ab4b64da78750d82f120faa25327f25cf11e579
parent 333081 3cab4d427bfab94df5927f8354af449b850c6a57
child 333083 f8e493cd1e87a482c0246f4a8fe4229142bc1ccc
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyzen, ritu
bugs1268069
milestone48.0a2
Bug 1268069 - Embeded object collection may be not updated on removals. r=yzen, a=ritu
accessible/base/EventTree.cpp
accessible/tests/mochitest/hypertext/test_update.html
--- a/accessible/base/EventTree.cpp
+++ b/accessible/base/EventTree.cpp
@@ -152,20 +152,17 @@ TreeMutation::Done()
 #endif
 
   for (uint32_t idx = mStartIdx; idx < length; idx++) {
     mParent->mChildren[idx]->mIndexInParent = idx;
     mParent->mChildren[idx]->mInt.mIndexOfEmbeddedChild = -1;
     mParent->mChildren[idx]->mStateFlags |= Accessible::eGroupInfoDirty;
   }
 
-  if (mStartIdx < mParent->mChildren.Length() - 1) {
-    mParent->mEmbeddedObjCollector = nullptr;
-  }
-
+  mParent->mEmbeddedObjCollector = nullptr;
   mParent->mStateFlags |= mStateFlagsCopy & Accessible::eKidsMutating;
 
 #ifdef DEBUG
   mIsDone = true;
 #endif
 
 #ifdef A11Y_LOG
   if (mEventTree != kNoEventTree && logging::IsEnabled(logging::eEventTree)) {
--- a/accessible/tests/mochitest/hypertext/test_update.html
+++ b/accessible/tests/mochitest/hypertext/test_update.html
@@ -146,27 +146,59 @@
       }
 
       this.getID = function removeFirstChild_getID()
       {
         return "Remove first child and check embedded object indeces";
       }
     }
 
+    function removeLastChild(aContainer)
+    {
+      this.ht = getAccessible(aContainer, [ nsIAccessibleHyperText ]);
+      this.eventSeq = [
+        new invokerChecker(EVENT_REORDER, aContainer)
+      ];
+
+      this.invoke = function removeLastChild_invoke()
+      {
+        is(this.ht.linkCount, 1, "Wrong embedded objects count before removal");
+
+        getNode(aContainer).removeChild(getNode(aContainer).lastElementChild);
+      }
+
+      this.finalCheck = function removeLastChild_finalCheck()
+      {
+        is(this.ht.linkCount, 0, "Wrong embedded objects count after removal");
+
+        var link = null;
+        try {
+          link = this.ht.getLinkAt(0);
+        } catch (e) { }
+        ok(!link, "No embedded object is expected");
+      }
+
+      this.getID = function removeLastChild_getID()
+      {
+        return "Remove last child and try its embedded object";
+      }
+    }
+
     //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.push(new removeFirstChild("c4"));
+      gQueue.push(new removeLastChild("c5"));
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
@@ -194,10 +226,11 @@
 
   <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>
   <form id="c4">
     <label for="c4_input">label</label>
     <input id="c4_input">
   </form>
+  <div id="c5">TextLeaf<input id="c5_input"></div>
 </body>
 </html>