Bug 606567 - Intermittent failure in browser/base/content/test/browser_bug585785.js | tab successfully removed. r=gavin a=...
--- 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);
}