bug 883708 - don't assert when parent of reorder event is shown later r=surkov
authorTrevor Saunders <trev.saunders@gmail.com>
Thu, 12 Dec 2013 15:08:29 -0500
changeset 161196 85830cef2651e16a6df119918248e0f7843a1ec5
parent 161195 ab6a4c0bb0825409af8114fd82acde13a30cf135
child 161197 35c6a9cd23b030b149e5bbd8ba6fbba9b67984f4
child 161261 94d22ab0b17f1033726e7f7aee63c16de46dbb5e
push id25870
push usercbook@mozilla.com
push dateThu, 19 Dec 2013 09:28:59 +0000
treeherdermozilla-central@35c6a9cd23b0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs883708
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 883708 - don't assert when parent of reorder event is shown later r=surkov
accessible/src/base/EventQueue.cpp
accessible/tests/mochitest/treeupdate/a11y.ini
accessible/tests/mochitest/treeupdate/test_bug883708.xhtml
--- a/accessible/src/base/EventQueue.cpp
+++ b/accessible/src/base/EventQueue.cpp
@@ -221,30 +221,31 @@ EventQueue::CoalesceReorderEvents(AccEve
         thisEvent->mEventRule = AccEvent::eDoNotEmit;
       }
 
       return;
     }
 
     // If tailEvent contains thisEvent
     // then
-    //   if show of tailEvent contains a grand parent of thisEvent
-    //   then assert
-    //   else if hide of tailEvent contains a grand parent of thisEvent
+    //   if show or hide of tailEvent contains a grand parent of thisEvent
     //   then ignore thisEvent and its show and hide events
     //   otherwise ignore thisEvent but not its show and hide events
     Accessible* thisParent = thisEvent->mAccessible;
     while (thisParent && thisParent != mDocument) {
       if (thisParent->Parent() == aTailEvent->mAccessible) {
         AccReorderEvent* tailReorder = downcast_accEvent(aTailEvent);
         uint32_t eventType = tailReorder->IsShowHideEventTarget(thisParent);
 
-        if (eventType == nsIAccessibleEvent::EVENT_SHOW) {
-           NS_ERROR("Accessible tree was created after it was modified! Huh?");
-        } else if (eventType == nsIAccessibleEvent::EVENT_HIDE) {
+        // Sometimes InvalidateChildren() and
+        // DocAccessible::CacheChildrenInSubtree() can conspire to reparent an
+        // accessible in this case no need for mutation events.  Se bug 883708
+        // for details.
+        if (eventType == nsIAccessibleEvent::EVENT_SHOW ||
+            eventType == nsIAccessibleEvent::EVENT_HIDE) {
           AccReorderEvent* thisReorder = downcast_accEvent(thisEvent);
           thisReorder->DoNotEmitAll();
         } else {
           thisEvent->mEventRule = AccEvent::eDoNotEmit;
         }
 
         return;
       }
--- a/accessible/tests/mochitest/treeupdate/a11y.ini
+++ b/accessible/tests/mochitest/treeupdate/a11y.ini
@@ -1,12 +1,13 @@
 [DEFAULT]
 
 [test_ariadialog.html]
 [test_bug852150.xhtml]
+[test_bug883708.xhtml]
 [test_bug895082.html]
 [test_canvas.html]
 [test_colorpicker.xul]
 [test_contextmenu.xul]
 [test_cssoverflow.html]
 [test_deck.xul]
 [test_doc.html]
 [test_gencontent.html]
new file mode 100644
--- /dev/null
+++ b/accessible/tests/mochitest/treeupdate/test_bug883708.xhtml
@@ -0,0 +1,33 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+<script>
+
+function boom()
+{
+  var newSpan = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
+  c.insertBefore(newSpan, d);
+  a.style.visibility = "visible";
+  ok(true, "test didn't crash or assert");
+  SimpleTest.finish();
+}
+
+</script>
+</head>
+
+<body onload="boom();">
+  <a target="_blank"
+     title="test reparenting accessible subtree when inaccessible element becomes accessible"
+     href="https://bugzilla.mozilla.org/show_bug.cgi?id=883708">
+    Mozilla Bug 883708
+  </a>
+
+  <p id="display"></p>
+  <div id="content" style="display: none"></div>
+  <pre id="test">
+  </pre>
+
+<div style="visibility: collapse;" id="a"><div style="float: right; visibility: visible;"><div id="c"><td id="d"></td></div></div></div></body>
+</html>