From b1340cf3ff55477a20d57ee12b5c16e2dd3f33a7 Mon Sep 17 00:00:00 2001 From: Raymond Lee Date: Wed, 1 Jun 2011 00:17:09 +0800 Subject: [PATCH] Bug 657219 - Intermittent timeout in browser/base/content/test/tabview/browser_tabview_undo_group.js r=ian --- .../browser_tabview_startup_transitions.js | 32 +++++++++---------- .../tabview/browser_tabview_undo_group.js | 8 +++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/browser/base/content/test/tabview/browser_tabview_startup_transitions.js b/browser/base/content/test/tabview/browser_tabview_startup_transitions.js index 8f0cb78959f..7bfd34fc042 100644 --- a/browser/base/content/test/tabview/browser_tabview_startup_transitions.js +++ b/browser/base/content/test/tabview/browser_tabview_startup_transitions.js @@ -7,17 +7,18 @@ var prefsBranch = Cc["@mozilla.org/preferences-service;1"]. function animateZoom() prefsBranch.getBoolPref("animate_zoom"); -function registerCleanupFunction() { - prefsBranch.setUserPref("animate_zoom", true); -} - function test() { waitForExplicitFinish(); let charsetArg = "charset=" + window.content.document.characterSet; let win = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", "about:blank", charsetArg, null, null, true); - + + registerCleanupFunction(function() { + prefsBranch.setBoolPref("animate_zoom", true); + win.close(); + }); + ok(animateZoom(), "By default, we animate on zoom."); prefsBranch.setBoolPref("animate_zoom", false); ok(!animateZoom(), "animate_zoom = false"); @@ -29,27 +30,24 @@ function test() { let tabViewWindow = null; let transitioned = 0; - let onShown = function() { - win.removeEventListener("tabviewshown", onShown, false); - - ok(!transitioned, "There should be no transitions"); - win.close(); - - finish(); - }; - let initCallback = function() { tabViewWindow = win.TabView._window; function onTransitionEnd(event) { transitioned++; - tabViewWindow.Utils.log(transitioned); + info(transitioned); } tabViewWindow.document.addEventListener("transitionend", onTransitionEnd, false); - win.TabView.show(); + showTabView(function() { + ok(!transitioned, "There should be no transitions"); + + tabViewWindow.document.removeEventListener( + "transitionend", onTransitionEnd, false); + + finish(); + }, win); }; - win.addEventListener("tabviewshown", onShown, false); win.TabView._initFrame(initCallback); } win.addEventListener("load", onLoad, false); diff --git a/browser/base/content/test/tabview/browser_tabview_undo_group.js b/browser/base/content/test/tabview/browser_tabview_undo_group.js index f52157a15d5..41d29e39e94 100644 --- a/browser/base/content/test/tabview/browser_tabview_undo_group.js +++ b/browser/base/content/test/tabview/browser_tabview_undo_group.js @@ -31,7 +31,9 @@ function onTabViewWindowLoaded() { is(groupItem.getChildren().length, 1, "The new group has a tab item"); // start the tests - testUndoGroup(contentWindow, groupItem); + waitForFocus(function() { + testUndoGroup(contentWindow, groupItem); + }, contentWindow); }; window.addEventListener("tabviewhidden", onTabViewHidden, false); window.addEventListener("tabviewshown", onTabViewShown, false); @@ -80,7 +82,7 @@ function testUndoGroup(contentWindow, groupItem) { }); let closeButton = groupItem.container.getElementsByClassName("close"); - ok(closeButton, "Group item close button exists"); + ok(closeButton[0], "Group item close button exists"); EventUtils.sendMouseEvent({ type: "click" }, closeButton[0], contentWindow); } @@ -129,6 +131,6 @@ function testCloseUndoGroup(contentWindow, groupItem) { }); let closeButton = groupItem.container.getElementsByClassName("close"); - ok(closeButton, "Group item close button exists"); + ok(closeButton[0], "Group item close button exists"); EventUtils.sendMouseEvent({ type: "click" }, closeButton[0], contentWindow); }