Bug 760083 - Clean up and consolidate toolbar customization tests. r=ttaubert

This commit is contained in:
Dão Gottwald
2012-06-06 13:01:19 +02:00
parent c551d6e96f
commit ec86d066a8
8 changed files with 104 additions and 132 deletions

View File

@@ -10,7 +10,7 @@ function testChromeless() {
"chrome,dialog=no,toolbar=no", "about:blank");
ok(newWin, "got new window");
function runWindowTest() {
whenDelayedStartupFinished(newWin, function () {
// Check that the search bar is hidden
var searchBar = newWin.BrowserSearch.searchBar;
ok(searchBar, "got search bar");
@@ -19,15 +19,11 @@ function testChromeless() {
is(searchBarBO.width, 0, "search bar hidden");
is(searchBarBO.height, 0, "search bar hidden");
function finalize() {
newWin.removeEventListener("load", runWindowTest, false);
testCustomize(newWin, function () {
newWin.close();
finish();
}
testCustomize(newWin, finalize);
}
newWin.addEventListener("load", runWindowTest, false);
});
});
}
function testCustomize(aWindow, aCallback) {
@@ -35,24 +31,16 @@ function testCustomize(aWindow, aCallback) {
ok(fileMenu, "got file menu");
is(fileMenu.disabled, false, "file menu initially enabled");
// Launch toolbar customization
// ctEl is either iframe that contains the customize sheet, or the dialog
var ctEl = aWindow.BrowserCustomizeToolbar();
is(fileMenu.disabled, true,
"file menu is disabled during toolbar customization");
aWindow.gNavToolbox.addEventListener("beforecustomization", function () {
aWindow.gNavToolbox.removeEventListener("beforecustomization", arguments.callee, false);
executeSoon(ctInit);
}, false);
function ctInit() {
// Close toolbar customization
closeToolbarCustomization(aWindow, ctEl);
openToolbarCustomizationUI(function () {
// Can't use the property, since the binding may have since been removed
// if the element is hidden (see bug 422590)
is(fileMenu.getAttribute("disabled"), "true",
"file menu is disabled during toolbar customization");
closeToolbarCustomizationUI(onClose, aWindow);
}, aWindow);
function onClose() {
is(fileMenu.getAttribute("disabled"), "false",
"file menu is enabled after toolbar customization");
@@ -60,13 +48,3 @@ function testCustomize(aWindow, aCallback) {
aCallback();
}
}
function closeToolbarCustomization(aWindow, aCTWindow) {
// Force the cleanup code to be run now instead of onunload.
// This also hides the sheet on Mac.
aCTWindow.finishToolbarCustomization();
// On windows and linux, need to explicitly close the window.
if (!gCustomizeSheet)
aCTWindow.close();
}