Bug 1295603: Don't add subtree events to EventTree if container has show and reorder. r=surkov draft
authorMichael Li <michael.li11702@gmail.com>
Wed, 24 Aug 2016 16:10:36 -0400
changeset 405124 f5087b49bcd39dbc0b8e274c9fa865bc202df8b2
parent 404988 01748a2b1a463f24efd9cd8abad9ccfd76b037b8
child 529361 e73d934854aea514763c3a1ae07722f4e822694f
push id27399
push userbmo:mili@mozilla.com
push dateWed, 24 Aug 2016 20:25:11 +0000
reviewerssurkov
bugs1295603
milestone51.0a1
Bug 1295603: Don't add subtree events to EventTree if container has show and reorder. r=surkov MozReview-Commit-ID: 4OwJ2m2klQ4
accessible/base/EventTree.cpp
accessible/tests/mochitest/events/test_coalescence.html
--- a/accessible/base/EventTree.cpp
+++ b/accessible/base/EventTree.cpp
@@ -253,16 +253,34 @@ EventTree::FindOrInsert(Accessible* aCon
     while (parent) {
       // Reached a top, no match for a current event.
       if (parent == top) {
         break;
       }
 
       // We got a match.
       if (parent->Parent() == node->mContainer) {
+        // Reject the node if it's contained by a show/hide event target
+        uint32_t evCount = node->mDependentEvents.Length();
+        for (uint32_t idx = 0; idx < evCount; idx++) {
+          AccMutationEvent* ev = node->mDependentEvents[idx];
+          if (ev->GetAccessible() == parent) {
+#ifdef A11Y_LOG
+            if (logging::IsEnabledAll(logging::eEventTree |
+                                      logging::eVerbose)) {
+              logging::MsgBegin("EVENTS_TREE",
+                "Rejecting node since contained by show/hide target");
+              logging::AccessibleInfo("Container", aContainer);
+              logging::MsgEnd();
+            }
+#endif
+            return nullptr;
+          }
+        }
+
         return node->FindOrInsert(aContainer);
       }
 
       parent = parent->Parent();
       MOZ_ASSERT(parent, "Wrong tree");
     }
 
     // If the given container contains a current node
--- a/accessible/tests/mochitest/events/test_coalescence.html
+++ b/accessible/tests/mochitest/events/test_coalescence.html
@@ -441,16 +441,57 @@
         testIsDefunct(this.b);
       }
 
       this.getID = function test5_getID() {
         return "remove a child, remove a parent sibling, remove the parent";
       }
     }
 
+    /**
+     * Insert accessibles with a child node moved by aria-owns
+     * Markup:
+     * <div id="t6_fc">
+     *   <div id="t6_owns"></div>
+     * </div>
+     * <div id="t6_sc" aria-owns="t6_owns"></div>
+     */
+    function test6()
+    {
+      this.parent = getNode("t6");
+      this.fc = document.createElement("div");
+      this.fc.setAttribute("id", "t6_fc");
+      this.owns = document.createElement("div");
+      this.owns.setAttribute("id", "t6_owns");
+      this.sc = document.createElement("div");
+      this.sc.setAttribute("id", "t6_sc");
+
+      this.eventSeq = [
+        new invokerChecker(EVENT_SHOW, this.fc),
+        new invokerChecker(EVENT_SHOW, this.sc),
+        new invokerChecker(EVENT_REORDER, this.parent),
+        new unexpectedInvokerChecker(EVENT_REORDER, this.fc),
+        new unexpectedInvokerChecker(EVENT_REORDER, this.sc),
+        new unexpectedInvokerChecker(EVENT_HIDE, this.owns),
+        new unexpectedInvokerChecker(EVENT_SHOW, this.owns)
+      ];
+
+      this.invoke = function test6_invoke()
+      {
+        getNode("t6").appendChild(this.fc);
+        getNode("t6_fc").appendChild(this.owns);
+        getNode("t6").appendChild(this.sc);
+        getNode("t6_sc").setAttribute("aria-owns", "t6_owns");
+      };
+
+      this.getID = function test6_getID() {
+        return "Insert accessibles with a child node moved by aria-owns";
+      };
+    }
+
     ////////////////////////////////////////////////////////////////////////////
     // Do tests.
 
     //gA11yEventDumpToConsole = true; // debug stuff
     //enableLogging("tree,eventTree,verbose");
 
     var gQueue = null;
     function doTests()
@@ -472,16 +513,17 @@
       gQueue.push(new showParentNChild("select10", "option10", true));
       gQueue.push(new showParentNAddChild("select11", false));
       gQueue.push(new showParentNAddChild("select12", true));
 
       gQueue.push(new removeGrandChildrenNHideParent("t1_child1", "t1_child2", "t1_parent"));
       gQueue.push(new test3());
       gQueue.push(new test4());
       gQueue.push(new test5());
+      gQueue.push(new test6());
 
       gQueue.invoke(); // Will call SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTests);
   </script>
 </head>
@@ -562,10 +604,13 @@
   </div>
 
   <div id="t5">
     <div role="button" id="t5_b">btn</div>
     <div role="listbox" id="t5_lb">
       <div role="option" id="t5_o">opt</div>
     </div>
   </div>
+
+  <div id="t6">
+  </div>
 </body>
 </html>