Bug 1026290: Delay mochitest-chrome redirect until after MozAfterPaint; r=jmaher
authorGeoff Brown <gbrown@mozilla.com>
Wed, 19 Nov 2014 15:43:28 -0700
changeset 216564 6d8adc89991c59a374092f02d220e52aa1effe12
parent 216563 5d895a54de81cfd46cc1b5986311333fbadaa7df
child 216565 e46da4d0299d557964d01276c5efb2b37fc2f596
push idunknown
push userunknown
push dateunknown
reviewersjmaher
bugs1026290
milestone36.0a1
Bug 1026290: Delay mochitest-chrome redirect until after MozAfterPaint; r=jmaher
testing/mochitest/redirect.html
--- a/testing/mochitest/redirect.html
+++ b/testing/mochitest/redirect.html
@@ -12,18 +12,29 @@
         detail: {
           "data": aURL + location.search,
           "type": "loadURI"
         }
       });
       document.dispatchEvent(event);
     }
 
+    function redirectToHarness()
+    {
+      redirect("chrome://mochikit/content/harness.xul");
+    }
+
     function onLoad() {
-      redirect("chrome://mochikit/content/harness.xul");
+      // Wait for MozAfterPaint, since the listener in browser-test.js is not
+      // added until then.
+      window.addEventListener("MozAfterPaint", function testOnMozAfterPaint() {
+        window.removeEventListener("MozAfterPaint", testOnMozAfterPaint);
+        setTimeout(redirectToHarness, 0);
+      });
+
     }
   </script>
 </head>
 
 <body onload="onLoad();">
 redirecting...
 </body>
 </html>