Bug 868612 - Fix mochitest test failures under browser/base/content/test. r=jaws,feedback=dao.

This commit is contained in:
Mike Conley 2013-05-17 15:29:05 -04:00
parent 36387ef5d2
commit 26f3af2e7f
9 changed files with 60 additions and 107 deletions

View File

@ -5,22 +5,22 @@
/**
* Customization handler prepares this browser window for entering and exiting
* customization mode by handling CustomizationStart and CustomizationEnd
* customization mode by handling customizationstarting and customizationending
* events.
*/
let CustomizationHandler = {
handleEvent: function(aEvent) {
switch(aEvent.type) {
case "CustomizationStart":
this._customizationStart();
case "customizationstarting":
this._customizationStarting();
break;
case "CustomizationEnd":
this._customizationEnd(aEvent.detail);
case "customizationending":
this._customizationEnding(aEvent.detail);
break;
}
},
_customizationStart: function() {
_customizationStarting: function() {
// Disable the toolbar context menu items
let menubar = document.getElementById("main-menubar");
for (let childNode of menubar.childNodes)
@ -41,7 +41,7 @@ let CustomizationHandler = {
TabsInTitlebar.allowedBy("customizing-toolbars", false);
},
_customizationEnd: function(aDetails) {
_customizationEnding: function(aDetails) {
// Update global UI elements that may have been added or removed
if (aDetails.changed) {
gURLBar = document.getElementById("urlbar");

View File

@ -1248,8 +1248,8 @@ var gBrowserInit = {
window.addEventListener("mousemove", MousePosTracker, false);
window.addEventListener("dragover", MousePosTracker, false);
window.addEventListener("CustomizationStart", CustomizationHandler, false);
window.addEventListener("CustomizationEnd", CustomizationHandler, false);
gNavToolbox.addEventListener("customizationstarting", CustomizationHandler);
gNavToolbox.addEventListener("customizationending", CustomizationHandler);
gCustomizeMode.init();

View File

@ -138,7 +138,6 @@ _BROWSER_FILES = \
browser_bug596687.js \
browser_bug597218.js \
browser_bug598923.js \
browser_bug599325.js \
browser_bug609700.js \
browser_bug623155.js \
browser_bug623893.js \
@ -167,7 +166,6 @@ _BROWSER_FILES = \
browser_bug832435.js \
browser_bug839103.js \
browser_canonizeURL.js \
browser_customize.js \
browser_findbarClose.js \
browser_homeDrop.js \
browser_keywordBookmarklets.js \

View File

@ -1,21 +0,0 @@
function test() {
waitForExplicitFinish();
let addonBar = document.getElementById("addon-bar");
ok(addonBar, "got addon bar");
ok(!isElementVisible(addonBar), "addon bar initially hidden");
openToolbarCustomizationUI(function () {
ok(isElementVisible(addonBar),
"add-on bar is visible during toolbar customization");
closeToolbarCustomizationUI(onClose);
});
function onClose() {
ok(!isElementVisible(addonBar),
"addon bar is hidden after toolbar customization");
finish();
}
}

View File

@ -1,24 +0,0 @@
function test() {
waitForExplicitFinish();
openToolbarCustomizationUI(customizationWindowLoaded);
}
function customizationWindowLoaded(win) {
let x = win.screenX;
let iconModeList = win.document.getElementById("modelist");
iconModeList.addEventListener("popupshown", function popupshown() {
iconModeList.removeEventListener("popupshown", popupshown, false);
executeSoon(function () {
is(win.screenX, x,
"toolbar customization window shouldn't move when the iconmode menulist is opened");
iconModeList.open = false;
closeToolbarCustomizationUI(finish);
});
}, false);
iconModeList.open = true;
}

View File

@ -37,49 +37,27 @@ function updateTabContextMenu(tab) {
menu.hidePopup();
}
function findToolbarCustomizationWindow(aBrowserWin) {
if (!aBrowserWin)
aBrowserWin = window;
let iframe = aBrowserWin.document.getElementById("customizeToolbarSheetIFrame");
let win = iframe && iframe.contentWindow;
if (win)
return win;
win = findChromeWindowByURI("chrome://global/content/customizeToolbar.xul");
if (win && win.opener == aBrowserWin)
return win;
throw Error("Failed to find the customization window");
}
function openToolbarCustomizationUI(aCallback, aBrowserWin) {
if (!aBrowserWin)
aBrowserWin = window;
aBrowserWin.document.getElementById("cmd_CustomizeToolbars").doCommand();
aBrowserWin.gCustomizeMode.enter();
aBrowserWin.gNavToolbox.addEventListener("beforecustomization", function UI_loaded() {
aBrowserWin.gNavToolbox.removeEventListener("beforecustomization", UI_loaded);
let win = findToolbarCustomizationWindow(aBrowserWin);
waitForFocus(function () {
aCallback(win);
}, win);
aBrowserWin.gNavToolbox.addEventListener("customizationready", function UI_loaded() {
aBrowserWin.gNavToolbox.removeEventListener("customizationready", UI_loaded);
executeSoon(function() {
aCallback(aBrowserWin)
});
});
}
function closeToolbarCustomizationUI(aCallback, aBrowserWin) {
let win = findToolbarCustomizationWindow(aBrowserWin);
win.addEventListener("unload", function unloaded() {
win.removeEventListener("unload", unloaded);
aBrowserWin.gNavToolbox.addEventListener("aftercustomization", function unloaded() {
aBrowserWin.gNavToolbox.removeEventListener("aftercustomization", unloaded);
executeSoon(aCallback);
});
let button = win.document.getElementById("donebutton");
button.focus();
button.doCommand();
aBrowserWin.gCustomizeMode.exit();
}
function waitForCondition(condition, nextTest, errorMsg) {

View File

@ -79,7 +79,7 @@ let gDefaultPlacements = new Map([
"stop-button",
"search-container",
"webrtc-status-button",
"bookmarks-menu-button-container",
"bookmarks-menu-button",
"downloads-button",
"home-button",
"social-toolbar-button",
@ -493,7 +493,7 @@ let CustomizableUIInternal = {
handleEvent: function(aEvent) {
switch (aEvent.type) {
case "unload": {
let window = aEvent.target;
let window = aEvent.currentTarget;
window.removeEventListener("unload", this);
this.unregisterBuildWindow(window);
break;

View File

@ -72,6 +72,8 @@ CustomizeMode.prototype = {
return;
}
this.dispatchToolboxEvent("beforecustomization");
let window = this.window;
let document = this.document;
@ -104,9 +106,7 @@ CustomizeMode.prototype = {
window.PanelUI.menuButton.disabled = true;
// Let everybody in this window know that we're about to customize.
let evt = document.createEvent("CustomEvent");
evt.initCustomEvent("CustomizationStart", true, true, window);
window.dispatchEvent(evt);
this.dispatchToolboxEvent("customizationstarting");
customizer.parentNode.selectedPanel = customizer;
@ -116,7 +116,6 @@ CustomizeMode.prototype = {
let panelHolder = document.getElementById("customization-panelHolder");
panelHolder.appendChild(window.PanelUI.mainView);
let self = this;
deck.addEventListener("transitionend", function customizeTransitionEnd() {
deck.removeEventListener("transitionend", customizeTransitionEnd);
@ -138,6 +137,7 @@ CustomizeMode.prototype = {
}
self.populatePalette();
self.dispatchToolboxEvent("customizationready");
});
this.visiblePalette.addEventListener("dragstart", this);
@ -181,7 +181,6 @@ CustomizeMode.prototype = {
tabViewDeck.removeEventListener("transitionend", onTransitionEnd);
documentElement.removeAttribute("customize-exiting");
});
documentElement.removeAttribute("customizing");
for (let target of this.areas) {
for (let toolbarItem of target.children) {
@ -206,11 +205,9 @@ CustomizeMode.prototype = {
// And drop all area references.
this.areas = [];
// Let everybody in this window know that we're finished customizing.
let evt = document.createEvent("CustomEvent");
evt.initCustomEvent("CustomizationEnd", true, true, {changed: this._changed});
window.dispatchEvent(evt);
// Let everybody in this window know that we're starting to
// exit customization mode.
this.dispatchToolboxEvent("customizationending");
window.PanelUI.replaceMainView(window.PanelUI.mainView);
let browser = document.getElementById("browser");
@ -227,20 +224,39 @@ CustomizeMode.prototype = {
// If there's history to this tab, just go back.
custBrowser.goBack();
} else {
let customizationTab = this.browser.selectedTab;
if (this.browser.browsers.length == 1) {
this.window.BrowserOpenTab();
// If we can't go back, we're removing the about:customization tab.
// We only do this if we're the top window for this window (so not
// a dialog window, for example).
if (this.window.getTopWin(true) == this.window) {
let customizationTab = this.browser.selectedTab;
if (this.browser.browsers.length == 1) {
this.window.BrowserOpenTab();
}
this.browser.removeTab(customizationTab);
}
this.browser.removeTab(customizationTab);
}
}
let deck = document.getElementById("tab-view-deck");
let self = this;
deck.addEventListener("transitionend", function customizeTransitionEnd() {
deck.removeEventListener("transitionend", customizeTransitionEnd);
self.dispatchToolboxEvent("aftercustomization");
});
documentElement.removeAttribute("customizing");
let customizer = document.getElementById("customization-container");
customizer.hidden = true;
this._changed = false;
},
dispatchToolboxEvent: function(aEventType, aDetails={}) {
let evt = this.document.createEvent("CustomEvent");
evt.initCustomEvent(aEventType, true, true, {changed: this._changed});
let result = this.window.gNavToolbox.dispatchEvent(evt);
},
populatePalette: function() {
let toolboxPalette = this.window.gNavToolbox.palette;
@ -429,15 +445,15 @@ CustomizeMode.prototype = {
},
onWidgetMoved: function(aWidgetId, aArea, aOldPosition, aNewPosition) {
this._changed = true;
this._onUIChange();
},
onWidgetAdded: function(aWidgetId, aArea, aPosition) {
this._changed = true;
this._onUIChange();
},
onWidgetRemoved: function(aWidgetId, aArea) {
this._changed = true;
this._onUIChange();
},
onWidgetCreated: function(aWidgetId) {
@ -446,6 +462,11 @@ CustomizeMode.prototype = {
onWidgetDestroyed: function(aWidgetId) {
},
_onUIChange: function() {
this._changed = true;
this.dispatchToolboxEvent("customizationchange");
},
handleEvent: function(aEvent) {
switch(aEvent.type) {
case "dragstart":

View File

@ -1628,8 +1628,9 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
color: -moz-menubartext;
}
#toolbar-menubar:not([autohide="true"]):not(:-moz-lwtheme):-moz-system-metric(menubar-drag),
#TabsToolbar[tabsontop=true]:not(:-moz-lwtheme):-moz-system-metric(menubar-drag) {
-moz-binding: url("chrome://global/content/bindings/toolbar.xml#toolbar-drag");
-moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar-drag");
}
#TabsToolbar[tabsontop=true]:not(:-moz-lwtheme) > #tabbrowser-tabs > .tabbrowser-tab:not([selected]) {