Bug 652802 - intermittent failures in mochitests/content/a11y/accessible/relations/test_tabbrowser.xul | Can't get accessible for [object XULElement], r=marcoz
authorAlexander Surkov <surkov.alexander@gmail.com>
Thu, 04 Aug 2011 18:54:22 +0900
changeset 73853 ecd7238895874364aa7fbaffef562ceb4ad094d9
parent 73852 d201bfd052b397f6213dbc2266664e024aae5ba9
child 73854 70416d5c538446cd5f1109b664221bef656d625b
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersmarcoz
bugs652802
milestone8.0a1
Bug 652802 - intermittent failures in mochitests/content/a11y/accessible/relations/test_tabbrowser.xul | Can't get accessible for [object XULElement], r=marcoz
accessible/tests/mochitest/relations/test_tabbrowser.xul
--- a/accessible/tests/mochitest/relations/test_tabbrowser.xul
+++ b/accessible/tests/mochitest/relations/test_tabbrowser.xul
@@ -19,16 +19,18 @@
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
 
   <script type="application/javascript"
           src="../common.js" />
   <script type="application/javascript"
           src="../role.js" />
   <script type="application/javascript"
           src="../relations.js" />
+  <script type="application/javascript"
+          src="../events.js" />
 
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript">
   <![CDATA[
     ////////////////////////////////////////////////////////////////////////////
     // Test
 
     const Ci = Components.interfaces;
@@ -44,29 +46,38 @@
     var gFindBar = {
       hidden: true
     };
 
     function doTest()
     {
       var tabBrowser = document.getElementById("tabbrowser");
 
-      var progressListener =
-      {
-        onStateChange: function onStateChange(aWebProgress,
-                                              aRequest,
-                                              aStateFlags,
-                                              aStatus)
-       {
-        if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP)
-          testRelations();
-       }
+      // Load documents into tabs and wait for reorder events caused by these
+      // documents load before we start the test.
+      var docURIs = ["about:", "about:mozilla"];
+
+      var handler = {
+        handleEvent: function handleEvent(aEvent) {
+          var target = aEvent.accessible;
+          if (target.role == ROLE_INTERNAL_FRAME &&
+              target.parent.parent == getAccessible(this.tabBrowser.mTabBox.tabpanels)) {
+            this.reorderCnt++;
+          }
+
+          if (this.reorderCnt == docURIs.length) {
+            unregisterA11yEventListener(EVENT_REORDER, this);
+            testAccTree();
+          }
+        },
+
+        tabBrowser: tabBrowser,
+        reorderCnt: 0
       };
-
-      tabBrowser.addProgressListener(progressListener);
+      registerA11yEventListener(EVENT_REORDER, handler);
 
       tabBrowser.loadTabs(["about:", "about:mozilla"], false, true);
     }
 
     function testRelations()
     {
       //////////////////////////////////////////////////////////////////////////
       // 'labelled by'/'label for' relations for xul:tab and xul:tabpanel