Bug 889120 - Australis' customize tab gets mixed up with other tab, r=jaws

--HG--
extra : rebase_source : 12ef7ad03ece347dccd1e193a24e4e74b7b20b82
This commit is contained in:
Gijs Kruitbosch 2014-01-10 15:54:48 +00:00
Родитель de74f1dd7d
Коммит 4ce8c9d4d6
14 изменённых файлов: 104 добавлений и 33 удалений

Просмотреть файл

@ -21,8 +21,7 @@ let CustomizationHandler = {
},
isCustomizing: function() {
return document.documentElement.hasAttribute("customizing") ||
document.documentElement.hasAttribute("customize-exiting");
return document.documentElement.hasAttribute("customizing");
},
_customizationStarting: function() {

Просмотреть файл

@ -3710,11 +3710,11 @@ var XULBrowserWindow = {
// Try not to instantiate gCustomizeMode as much as possible,
// so don't use CustomizeMode.jsm to check for URI or customizing.
let customizingURI = "about:customizing";
if (location == customizingURI &&
!CustomizationHandler.isCustomizing()) {
if (location == customizingURI) {
gCustomizeMode.enter();
} else if (location != customizingURI &&
CustomizationHandler.isCustomizing()) {
(CustomizationHandler.isEnteringCustomizeMode ||
CustomizationHandler.isCustomizing())) {
gCustomizeMode.exit();
}
}

Просмотреть файл

@ -73,8 +73,13 @@ CustomizeMode.prototype = {
return this.document.getElementById("PanelUI-contents");
},
get _handler() {
return this.window.CustomizationHandler;
},
toggle: function() {
if (this._transitioning) {
if (this._handler.isEnteringCustomizeMode || this._handler.isExitingCustomizeMode) {
this._wantToBeInCustomizeMode = !this._wantToBeInCustomizeMode;
return;
}
if (this._customizing) {
@ -85,10 +90,20 @@ CustomizeMode.prototype = {
},
enter: function() {
if (this._customizing || this._transitioning) {
this._wantToBeInCustomizeMode = true;
if (this._customizing || this._handler.isEnteringCustomizeMode) {
return;
}
// Exiting; want to re-enter once we've done that.
if (this._handler.isExitingCustomizeMode) {
LOG("Attempted to enter while we're in the middle of exiting. " +
"We'll exit after we've entered");
return;
}
// We don't need to switch to kAboutURI, or open a new tab at
// kAboutURI if we're already on it.
if (this.browser.selectedBrowser.currentURI.spec != kAboutURI) {
@ -99,6 +114,8 @@ CustomizeMode.prototype = {
let window = this.window;
let document = this.document;
this._handler.isEnteringCustomizeMode = true;
Task.spawn(function() {
// We shouldn't start customize mode until after browser-delayed-startup has finished:
if (!this.window.gBrowserInit.delayedStartupFinished) {
@ -201,19 +218,35 @@ CustomizeMode.prototype = {
// Show the palette now that the transition has finished.
this.visiblePalette.hidden = false;
this._handler.isEnteringCustomizeMode = false;
this.dispatchToolboxEvent("customizationready");
if (!this._wantToBeInCustomizeMode) {
this.exit();
}
}.bind(this)).then(null, function(e) {
ERROR(e);
// We should ensure this has been called, and calling it again doesn't hurt:
window.PanelUI.endBatchUpdate();
});
this._handler.isEnteringCustomizeMode = false;
}.bind(this));
},
exit: function() {
if (!this._customizing || this._transitioning) {
this._wantToBeInCustomizeMode = false;
if (!this._customizing || this._handler.isExitingCustomizeMode) {
return;
}
// Entering; want to exit once we've done that.
if (this._handler.isEnteringCustomizeMode) {
LOG("Attempted to exit while we're in the middle of entering. " +
"We'll exit after we've entered");
return;
}
this._handler.isExitingCustomizeMode = true;
CustomizableUI.removeListener(this);
this.document.removeEventListener("keypress", this);
@ -296,7 +329,13 @@ CustomizeMode.prototype = {
let custBrowser = this.browser.selectedBrowser;
if (custBrowser.canGoBack) {
// If there's history to this tab, just go back.
custBrowser.goBack();
// Note that this throws an exception if the previous document has a
// problematic URL (e.g. about:idontexist)
try {
custBrowser.goBack();
} catch (ex) {
ERROR(ex);
}
} else {
// 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
@ -321,13 +360,19 @@ CustomizeMode.prototype = {
this.window.PanelUI.endBatchUpdate();
this._changed = false;
this._transitioning = false;
this._handler.isExitingCustomizeMode = false;
this.dispatchToolboxEvent("aftercustomization");
CustomizableUI.notifyEndCustomizing(this.window);
if (this._wantToBeInCustomizeMode) {
this.enter();
}
}.bind(this)).then(null, function(e) {
ERROR(e);
// We should ensure this has been called, and calling it again doesn't hurt:
window.PanelUI.endBatchUpdate();
});
this._handler.isExitingCustomizeMode = false;
}.bind(this));
},
/**

Просмотреть файл

@ -19,6 +19,7 @@ skip-if = os == "mac"
[browser_886323_buildArea_removable_nodes.js]
[browser_887438_currentset_shim.js]
[browser_888817_currentset_updating.js]
[browser_889120_customize_tab_merging.js]
[browser_890140_orphaned_placeholders.js]
[browser_890262_destroyWidget_after_add_to_panel.js]
[browser_892955_isWidgetRemovable_for_removed_widgets.js]

Просмотреть файл

@ -110,7 +110,6 @@ function checkPalette(id, method) {
}
let otherWin;
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Moving widgets in two windows, one with customize mode and one without, should work.
add_task(function MoveWidgetsInTwoWindows() {
@ -139,6 +138,5 @@ add_task(function MoveWidgetsInTwoWindows() {
});
add_task(function asyncCleanup() {
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
});
});

Просмотреть файл

@ -4,8 +4,6 @@
"use strict";
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Dragging an item from the palette to another button in the panel should work.
add_task(function() {
yield startCustomizing();
@ -64,6 +62,5 @@ add_task(function() {
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
});

Просмотреть файл

@ -4,7 +4,6 @@
"use strict";
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
requestLongerTimeout(5);
// Dragging the zoom controls to be before the print button should not move any controls.
@ -462,6 +461,5 @@ add_task(function() {
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
});

Просмотреть файл

@ -0,0 +1,44 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const kTestToolbarId = "test-empty-drag";
// Attempting to switch quickly from one tab to another to see whether the state changes
// correctly.
add_task(function CheckBasicCustomizeMode() {
yield startCustomizing();
ok(CustomizationHandler.isCustomizing(), "We should be in customize mode");
yield endCustomizing();
ok(!CustomizationHandler.isCustomizing(), "We should not be in customize mode");
});
add_task(function CheckQuickCustomizeModeSwitch() {
let tab1 = gBrowser.addTab("about:newtab");
gBrowser.selectedTab = tab1;
let tab2 = gBrowser.addTab("about:customizing");
let tab3 = gBrowser.addTab("about:newtab");
gBrowser.selectedTab = tab2;
try {
yield waitForCondition(() => CustomizationHandler.isEnteringCustomizeMode);
} catch (ex) {
Cu.reportError(ex);
}
ok(CustomizationHandler.isEnteringCustomizeMode, "Should be entering customize mode");
gBrowser.selectedTab = tab3;
try {
yield waitForCondition(() => !CustomizationHandler.isEnteringCustomizeMode && !CustomizationHandler.isCustomizing());
} catch (ex) {
Cu.reportError(ex);
}
ok(!CustomizationHandler.isCustomizing(), "Should not be entering customize mode");
gBrowser.removeTab(tab1);
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab3);
});
add_task(function asyncCleanup() {
yield endCustomizing();
});

Просмотреть файл

@ -4,8 +4,6 @@
"use strict";
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// One orphaned item should have two placeholders next to it.
add_task(function() {
yield startCustomizing();
@ -158,7 +156,6 @@ add_task(function() {
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
});

Просмотреть файл

@ -7,8 +7,6 @@
let navbar;
let skippedItem;
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Attempting to drag a skipintoolbarset item should work.
add_task(function() {
navbar = document.getElementById("nav-bar");
@ -35,6 +33,5 @@ add_task(function() {
add_task(function asyncCleanup() {
yield endCustomizing();
skippedItem.remove();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
});

Просмотреть файл

@ -4,8 +4,6 @@
"use strict";
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Customize mode reset button should revert correctly
add_task(function() {
yield startCustomizing();
@ -23,6 +21,5 @@ add_task(function() {
});
add_task(function asyncCleanup() {
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
});

Просмотреть файл

@ -5,7 +5,6 @@
"use strict";
const kTestToolbarId = "test-empty-drag";
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Attempting to drag an item to an empty container should work.
add_task(function() {
@ -23,6 +22,5 @@ add_task(function() {
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
});

Просмотреть файл

@ -4,8 +4,6 @@
"use strict";
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
// Attempting to drag the menubar to the navbar shouldn't work.
add_task(function() {
yield startCustomizing();
@ -23,6 +21,5 @@ add_task(function() {
add_task(function asyncCleanup() {
yield endCustomizing();
Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck");
yield resetCustomization();
});

Просмотреть файл

@ -14,6 +14,9 @@ let ChromeUtils = {};
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js", ChromeUtils);
Services.prefs.setBoolPref("browser.uiCustomization.skipSourceNodeCheck", true);
registerCleanupFunction(() => Services.prefs.clearUserPref("browser.uiCustomization.skipSourceNodeCheck"));
let {synthesizeDragStart, synthesizeDrop} = ChromeUtils;
const kNSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";