Bug 606567 - Intermittent failure in browser/base/content/test/browser_bug585785.js | tab successfully removed. r=gavin a=...
authorDão Gottwald <dao@mozilla.com>
Tue, 26 Oct 2010 14:23:40 +0200
changeset 56497 5bb4c0ff5eac270b1fecd06f72f4a1246ff60d21
parent 56496 116ab7c785e12a1cca3211fb96d4b34fe36a6469
child 56498 2744ccd3dfe69d2f3224e52046556288651a7858
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersgavin
bugs606567, 585785
milestone2.0b8pre
Bug 606567 - Intermittent failure in browser/base/content/test/browser_bug585785.js | tab successfully removed. r=gavin a=...
browser/base/content/test/browser_bug585785.js
--- a/browser/base/content/test/browser_bug585785.js
+++ b/browser/base/content/test/browser_bug585785.js
@@ -1,31 +1,36 @@
 var tab;
-var performedTest = false;
 
 function test() {
   waitForExplicitFinish();
 
   tab = gBrowser.addTab();
   isnot(tab.getAttribute("fadein"), "true", "newly opened tab is yet to fade in");
 
-  // Remove the tab right before the opening animation's first frame
+  // Try to remove the tab right before the opening animation's first frame
   window.mozRequestAnimationFrame(checkAnimationState);
-  executeSoon(checkAnimationState);
 }
 
 function checkAnimationState() {
-  if (performedTest)
-    return;
-
   if (tab.getAttribute("fadein") != "true") {
     window.mozRequestAnimationFrame(checkAnimationState);
-    executeSoon(checkAnimationState);
     return;
   }
 
-  performedTest = true;
+  info(window.getComputedStyle(tab).maxWidth);
+  gBrowser.removeTab(tab, { animate: true });
+  if (!tab.parentNode) {
+    ok(true, "tab removed synchronously since the opening animation hasn't moved yet");
+    finish();
+    return;
+  }
 
-  info(window.getComputedStyle(tab).maxWidth);
-  gBrowser.removeTab(tab, {animate:true});
-  ok(!tab.parentNode, "tab successfully removed");
-  finish();
+  info("tab didn't close immediately, so the tab opening animation must have started moving");
+  info("waiting for the tab to close asynchronously");
+  tab.addEventListener("transitionend", function (event) {
+    if (event.propertyName == "max-width")
+      executeSoon(function () {
+        ok(!tab.parentNode, "tab removed asynchronously");
+        finish();
+      });
+  }, false);
 }