Bug 657219 - Intermittent timeout in browser/base/content/test/tabview/browser_tabview_undo_group.js r=ian

This commit is contained in:
Raymond Lee 2011-06-01 00:17:09 +08:00
parent fbfdf23f9b
commit b1340cf3ff
2 changed files with 20 additions and 20 deletions

View File

@ -7,10 +7,6 @@ var prefsBranch = Cc["@mozilla.org/preferences-service;1"].
function animateZoom() prefsBranch.getBoolPref("animate_zoom"); function animateZoom() prefsBranch.getBoolPref("animate_zoom");
function registerCleanupFunction() {
prefsBranch.setUserPref("animate_zoom", true);
}
function test() { function test() {
waitForExplicitFinish(); waitForExplicitFinish();
@ -18,6 +14,11 @@ function test() {
let win = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", let win = window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
"about:blank", charsetArg, null, null, true); "about:blank", charsetArg, null, null, true);
registerCleanupFunction(function() {
prefsBranch.setBoolPref("animate_zoom", true);
win.close();
});
ok(animateZoom(), "By default, we animate on zoom."); ok(animateZoom(), "By default, we animate on zoom.");
prefsBranch.setBoolPref("animate_zoom", false); prefsBranch.setBoolPref("animate_zoom", false);
ok(!animateZoom(), "animate_zoom = false"); ok(!animateZoom(), "animate_zoom = false");
@ -29,27 +30,24 @@ function test() {
let tabViewWindow = null; let tabViewWindow = null;
let transitioned = 0; let transitioned = 0;
let onShown = function() {
win.removeEventListener("tabviewshown", onShown, false);
ok(!transitioned, "There should be no transitions");
win.close();
finish();
};
let initCallback = function() { let initCallback = function() {
tabViewWindow = win.TabView._window; tabViewWindow = win.TabView._window;
function onTransitionEnd(event) { function onTransitionEnd(event) {
transitioned++; transitioned++;
tabViewWindow.Utils.log(transitioned); info(transitioned);
} }
tabViewWindow.document.addEventListener("transitionend", onTransitionEnd, false); 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.TabView._initFrame(initCallback);
} }
win.addEventListener("load", onLoad, false); win.addEventListener("load", onLoad, false);

View File

@ -31,7 +31,9 @@ function onTabViewWindowLoaded() {
is(groupItem.getChildren().length, 1, "The new group has a tab item"); is(groupItem.getChildren().length, 1, "The new group has a tab item");
// start the tests // start the tests
waitForFocus(function() {
testUndoGroup(contentWindow, groupItem); testUndoGroup(contentWindow, groupItem);
}, contentWindow);
}; };
window.addEventListener("tabviewhidden", onTabViewHidden, false); window.addEventListener("tabviewhidden", onTabViewHidden, false);
window.addEventListener("tabviewshown", onTabViewShown, false); window.addEventListener("tabviewshown", onTabViewShown, false);
@ -80,7 +82,7 @@ function testUndoGroup(contentWindow, groupItem) {
}); });
let closeButton = groupItem.container.getElementsByClassName("close"); 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); EventUtils.sendMouseEvent({ type: "click" }, closeButton[0], contentWindow);
} }
@ -129,6 +131,6 @@ function testCloseUndoGroup(contentWindow, groupItem) {
}); });
let closeButton = groupItem.container.getElementsByClassName("close"); 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); EventUtils.sendMouseEvent({ type: "click" }, closeButton[0], contentWindow);
} }