Bug 1268677 - embedded object index might be not update, r=yzen a=lizzard
authorAlexander Surkov <surkov.alexander@gmail.com>
Mon, 02 May 2016 15:55:35 -0400
changeset 332717 e6ca64925a10f789262cc3a8ef84a0b449187998
parent 332716 0162b3b3ee740c7a9dbcb05e7d8905034a38090f
child 332718 ec8ac20d8d26b41d8e383451bfc3e752e4d28c17
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, lizzard
bugs1268677
milestone48.0a2
Bug 1268677 - embedded object index might be not update, r=yzen a=lizzard
accessible/base/EventTree.cpp
accessible/tests/mochitest/hypertext/test_update.html
--- a/accessible/base/EventTree.cpp
+++ b/accessible/base/EventTree.cpp
@@ -148,16 +148,17 @@ TreeMutation::Done()
   for (uint32_t idx = 0; idx < mStartIdx && idx < length; idx++) {
     MOZ_ASSERT(mParent->mChildren[idx]->mIndexInParent == static_cast<int32_t>(idx),
                "Wrong index detected");
   }
 #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->mStateFlags |= mStateFlagsCopy & Accessible::eKidsMutating;
--- a/accessible/tests/mochitest/hypertext/test_update.html
+++ b/accessible/tests/mochitest/hypertext/test_update.html
@@ -119,28 +119,54 @@
       }
 
       this.getID = function removeChild_getID()
       {
         return "check text after removing child from '" + aContainerID + "'";
       }
     }
 
+    function removeFirstChild(aContainer)
+    {
+      this.ht = getAccessible(aContainer, [ nsIAccessibleHyperText ]);
+      this.eventSeq = [
+        new invokerChecker(EVENT_REORDER, aContainer)
+      ];
 
+      this.invoke = function removeFirstChild_invoke()
+      {
+        is(this.ht.linkCount, 2, "Wrong embedded objects count before removal");
+
+        getNode(aContainer).removeChild(getNode(aContainer).firstElementChild);
+      }
+
+      this.finalCheck = function removeFirstChild_finalCheck()
+      {
+        // check list index before link count
+        is(this.ht.getLinkIndex(this.ht.firstChild), 0, "Wrong child index");
+        is(this.ht.linkCount, 1, "Wrong embedded objects count after removal");
+      }
+
+      this.getID = function removeFirstChild_getID()
+      {
+        return "Remove first child and check embedded object indeces";
+      }
+    }
 
     //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.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
@@ -164,10 +190,14 @@
   <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>
+  <form id="c4">
+    <label for="c4_input">label</label>
+    <input id="c4_input">
+  </form>
 </body>
 </html>