зеркало из https://github.com/mozilla/gecko-dev.git
Bug 473128: add test for bug 422590, r=mano
This commit is contained in:
Родитель
b51dda55aa
Коммит
e67157cb19
|
@ -3205,6 +3205,8 @@ function OpenBrowserWindow()
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a reference to the window in which the toolbar
|
||||||
|
// customization document is loaded.
|
||||||
function BrowserCustomizeToolbar()
|
function BrowserCustomizeToolbar()
|
||||||
{
|
{
|
||||||
// Disable the toolbar context menu items
|
// Disable the toolbar context menu items
|
||||||
|
@ -3237,8 +3239,10 @@ function BrowserCustomizeToolbar()
|
||||||
var sheetWidth = sheetFrame.style.width.match(/([0-9]+)px/)[1];
|
var sheetWidth = sheetFrame.style.width.match(/([0-9]+)px/)[1];
|
||||||
document.getElementById("customizeToolbarSheetPopup")
|
document.getElementById("customizeToolbarSheetPopup")
|
||||||
.openPopup(gNavToolbox, "after_start", (window.innerWidth - sheetWidth) / 2, 0);
|
.openPopup(gNavToolbox, "after_start", (window.innerWidth - sheetWidth) / 2, 0);
|
||||||
|
|
||||||
|
return sheetFrame.contentWindow;
|
||||||
#else
|
#else
|
||||||
window.openDialog(customizeURL,
|
return window.openDialog(customizeURL,
|
||||||
"CustomizeToolbar",
|
"CustomizeToolbar",
|
||||||
"chrome,titlebar,toolbar,resizable,dependent",
|
"chrome,titlebar,toolbar,resizable,dependent",
|
||||||
gNavToolbox);
|
gNavToolbox);
|
||||||
|
|
|
@ -85,6 +85,7 @@ _BROWSER_FILES = browser_bug321000.js \
|
||||||
browser_bug416661.js \
|
browser_bug416661.js \
|
||||||
browser_bug386835.js \
|
browser_bug386835.js \
|
||||||
bug386835.html \
|
bug386835.html \
|
||||||
|
browser_bug422590.js \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
function test() {
|
||||||
|
waitForExplicitFinish();
|
||||||
|
|
||||||
|
// test the main (normal) browser window
|
||||||
|
testCustomize(window, testChromeless);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testChromeless() {
|
||||||
|
// test a chromeless window
|
||||||
|
var newWin = openDialog("chrome://browser/content/", "_blank",
|
||||||
|
"chrome,dialog=no,toolbar=no", "about:blank");
|
||||||
|
ok(newWin, "got new window");
|
||||||
|
|
||||||
|
function runWindowTest() {
|
||||||
|
// Check that the search bar is hidden
|
||||||
|
var searchBar = newWin.BrowserSearch.searchBar;
|
||||||
|
ok(searchBar, "got search bar");
|
||||||
|
|
||||||
|
var searchBarBO = searchBar.boxObject;
|
||||||
|
is(searchBarBO.width, 0, "search bar hidden");
|
||||||
|
is(searchBarBO.height, 0, "search bar hidden");
|
||||||
|
|
||||||
|
function finalize() {
|
||||||
|
newWin.removeEventListener("load", runWindowTest, false);
|
||||||
|
newWin.close();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
testCustomize(newWin, finalize);
|
||||||
|
}
|
||||||
|
|
||||||
|
newWin.addEventListener("load", runWindowTest, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testCustomize(aWindow, aCallback) {
|
||||||
|
var fileMenu = aWindow.document.getElementById("file-menu");
|
||||||
|
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");
|
||||||
|
|
||||||
|
// Set a callback on the window's toolbox
|
||||||
|
var nt = aWindow.getNavToolbox();
|
||||||
|
var oldHandler = nt.customizeInitialized;
|
||||||
|
nt.customizeInitialized = ctInit;
|
||||||
|
function ctInit() {
|
||||||
|
// Restore customizeInitialized handler
|
||||||
|
nt.customizeInitialized = oldHandler;
|
||||||
|
|
||||||
|
// Close toolbar customization
|
||||||
|
closeToolbarCustomization(aWindow, ctEl);
|
||||||
|
|
||||||
|
// 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"), "false",
|
||||||
|
"file menu is enabled after toolbar customization");
|
||||||
|
|
||||||
|
if (aCallback)
|
||||||
|
aCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeToolbarCustomization(aWindow, aCTWindow) {
|
||||||
|
var osString = Components.classes["@mozilla.org/xre/app-info;1"].
|
||||||
|
getService(Components.interfaces.nsIXULRuntime).OS;
|
||||||
|
|
||||||
|
// 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 (osString != "Darwin")
|
||||||
|
aCTWindow.close();
|
||||||
|
}
|
|
@ -64,6 +64,8 @@ function InitWithToolbox(aToolbox)
|
||||||
gToolbox.addEventListener("drop", onToolbarDrop, false);
|
gToolbox.addEventListener("drop", onToolbarDrop, false);
|
||||||
|
|
||||||
initDialog();
|
initDialog();
|
||||||
|
|
||||||
|
notifyParentInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishToolbarCustomization()
|
function finishToolbarCustomization()
|
||||||
|
@ -127,6 +129,16 @@ function notifyParentComplete()
|
||||||
gToolbox.customizeDone(gToolboxChanged);
|
gToolbox.customizeDone(gToolboxChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoke a callback on the toolbox to notify it that the dialog is fully
|
||||||
|
* initialized.
|
||||||
|
*/
|
||||||
|
function notifyParentInitialized()
|
||||||
|
{
|
||||||
|
if ("customizeInitialized" in gToolbox)
|
||||||
|
gToolbox.customizeInitialized();
|
||||||
|
}
|
||||||
|
|
||||||
function toolboxChanged()
|
function toolboxChanged()
|
||||||
{
|
{
|
||||||
gToolboxChanged = true;
|
gToolboxChanged = true;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче