mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 971626 - [Australis] Restore Defaults should collapse Title Bar. r=Gijs
This commit is contained in:
parent
509f166438
commit
19ada84adb
@ -1360,6 +1360,9 @@ pref("network.disable.ipc.security", true);
|
|||||||
// CustomizableUI debug logging.
|
// CustomizableUI debug logging.
|
||||||
pref("browser.uiCustomization.debug", false);
|
pref("browser.uiCustomization.debug", false);
|
||||||
|
|
||||||
|
// CustomizableUI state of the browser's user interface
|
||||||
|
pref("browser.uiCustomization.state", "");
|
||||||
|
|
||||||
// The URL where remote content that composes the UI for Firefox Accounts should
|
// The URL where remote content that composes the UI for Firefox Accounts should
|
||||||
// be fetched. Must use HTTPS.
|
// be fetched. Must use HTTPS.
|
||||||
pref("identity.fxaccounts.remote.uri", "https://accounts.firefox.com/?service=sync&context=fx_desktop_v1");
|
pref("identity.fxaccounts.remote.uri", "https://accounts.firefox.com/?service=sync&context=fx_desktop_v1");
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<menupopup id="customization-toolbar-menu" onpopupshowing="onViewToolbarsPopupShowing(event)"/>
|
<menupopup id="customization-toolbar-menu" onpopupshowing="onViewToolbarsPopupShowing(event)"/>
|
||||||
</button>
|
</button>
|
||||||
<spacer flex="1"/>
|
<spacer flex="1"/>
|
||||||
<button id="customization-undo-reset"
|
<button id="customization-undo-reset-button"
|
||||||
class="customizationmode-button"
|
class="customizationmode-button"
|
||||||
hidden="true"
|
hidden="true"
|
||||||
oncommand="gCustomizeMode.undoReset();"
|
oncommand="gCustomizeMode.undoReset();"
|
||||||
|
@ -36,6 +36,7 @@ const kSpecialWidgetPfx = "customizableui-special-";
|
|||||||
const kPrefCustomizationState = "browser.uiCustomization.state";
|
const kPrefCustomizationState = "browser.uiCustomization.state";
|
||||||
const kPrefCustomizationAutoAdd = "browser.uiCustomization.autoAdd";
|
const kPrefCustomizationAutoAdd = "browser.uiCustomization.autoAdd";
|
||||||
const kPrefCustomizationDebug = "browser.uiCustomization.debug";
|
const kPrefCustomizationDebug = "browser.uiCustomization.debug";
|
||||||
|
const kPrefDrawInTitlebar = "browser.tabs.drawInTitlebar";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The keys are the handlers that are fired when the event type (the value)
|
* The keys are the handlers that are fired when the event type (the value)
|
||||||
@ -128,7 +129,10 @@ let gGroupWrapperCache = new Map();
|
|||||||
let gSingleWrapperCache = new WeakMap();
|
let gSingleWrapperCache = new WeakMap();
|
||||||
let gListeners = new Set();
|
let gListeners = new Set();
|
||||||
|
|
||||||
let gUIStateBeforeReset = null;
|
let gUIStateBeforeReset = {
|
||||||
|
uiCustomizationState: null,
|
||||||
|
drawInTitlebar: null,
|
||||||
|
};
|
||||||
|
|
||||||
let gModuleName = "[CustomizableUI]";
|
let gModuleName = "[CustomizableUI]";
|
||||||
#include logging.js
|
#include logging.js
|
||||||
@ -697,7 +701,7 @@ let CustomizableUIInternal = {
|
|||||||
this.insertNode(aWidgetId, aArea, aPosition, true);
|
this.insertNode(aWidgetId, aArea, aPosition, true);
|
||||||
|
|
||||||
if (!gResetting) {
|
if (!gResetting) {
|
||||||
gUIStateBeforeReset = null;
|
this._clearPreviousUIState();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -756,19 +760,19 @@ let CustomizableUIInternal = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!gResetting) {
|
if (!gResetting) {
|
||||||
gUIStateBeforeReset = null;
|
this._clearPreviousUIState();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onWidgetMoved: function(aWidgetId, aArea, aOldPosition, aNewPosition) {
|
onWidgetMoved: function(aWidgetId, aArea, aOldPosition, aNewPosition) {
|
||||||
this.insertNode(aWidgetId, aArea, aNewPosition);
|
this.insertNode(aWidgetId, aArea, aNewPosition);
|
||||||
if (!gResetting) {
|
if (!gResetting) {
|
||||||
gUIStateBeforeReset = null;
|
this._clearPreviousUIState();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onCustomizeEnd: function(aWindow) {
|
onCustomizeEnd: function(aWindow) {
|
||||||
gUIStateBeforeReset = null;
|
this._clearPreviousUIState();
|
||||||
},
|
},
|
||||||
|
|
||||||
registerBuildArea: function(aArea, aNode) {
|
registerBuildArea: function(aArea, aNode) {
|
||||||
@ -2076,10 +2080,12 @@ let CustomizableUIInternal = {
|
|||||||
|
|
||||||
_resetUIState: function() {
|
_resetUIState: function() {
|
||||||
try {
|
try {
|
||||||
gUIStateBeforeReset = Services.prefs.getCharPref(kPrefCustomizationState);
|
gUIStateBeforeReset.drawInTitlebar = Services.prefs.getBoolPref(kPrefDrawInTitlebar);
|
||||||
|
gUIStateBeforeReset.uiCustomizationState = Services.prefs.getCharPref(kPrefCustomizationState);
|
||||||
} catch(e) { }
|
} catch(e) { }
|
||||||
|
|
||||||
Services.prefs.clearUserPref(kPrefCustomizationState);
|
Services.prefs.clearUserPref(kPrefCustomizationState);
|
||||||
|
Services.prefs.clearUserPref(kPrefDrawInTitlebar);
|
||||||
LOG("State reset");
|
LOG("State reset");
|
||||||
|
|
||||||
// Reset placements to make restoring default placements possible.
|
// Reset placements to make restoring default placements possible.
|
||||||
@ -2114,17 +2120,31 @@ let CustomizableUIInternal = {
|
|||||||
* Undoes a previous reset, restoring the state of the UI to the state prior to the reset.
|
* Undoes a previous reset, restoring the state of the UI to the state prior to the reset.
|
||||||
*/
|
*/
|
||||||
undoReset: function() {
|
undoReset: function() {
|
||||||
if (!gUIStateBeforeReset) {
|
if (gUIStateBeforeReset.uiCustomizationState == null ||
|
||||||
|
gUIStateBeforeReset.drawInTitlebar == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Services.prefs.setCharPref(kPrefCustomizationState, gUIStateBeforeReset);
|
let uiCustomizationState = gUIStateBeforeReset.uiCustomizationState;
|
||||||
|
let drawInTitlebar = gUIStateBeforeReset.drawInTitlebar;
|
||||||
|
|
||||||
|
// Need to clear the previous state before setting the prefs
|
||||||
|
// because pref observers may check if there is a previous UI state.
|
||||||
|
this._clearPreviousUIState();
|
||||||
|
|
||||||
|
Services.prefs.setCharPref(kPrefCustomizationState, uiCustomizationState);
|
||||||
|
Services.prefs.setBoolPref(kPrefDrawInTitlebar, drawInTitlebar);
|
||||||
this.loadSavedState();
|
this.loadSavedState();
|
||||||
for (let areaId of Object.keys(gSavedState.placements)) {
|
for (let areaId of Object.keys(gSavedState.placements)) {
|
||||||
let placements = gSavedState.placements[areaId];
|
let placements = gSavedState.placements[areaId];
|
||||||
gPlacements.set(areaId, placements);
|
gPlacements.set(areaId, placements);
|
||||||
}
|
}
|
||||||
this._rebuildRegisteredAreas();
|
this._rebuildRegisteredAreas();
|
||||||
gUIStateBeforeReset = null;
|
},
|
||||||
|
|
||||||
|
_clearPreviousUIState: function() {
|
||||||
|
Object.getOwnPropertyNames(gUIStateBeforeReset).forEach((prop) => {
|
||||||
|
gUIStateBeforeReset[prop] = null;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2271,6 +2291,11 @@ let CustomizableUIInternal = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Services.prefs.prefHasUserValue(kPrefDrawInTitlebar)) {
|
||||||
|
LOG(kPrefDrawInTitlebar + " pref is non-default");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2894,7 +2919,8 @@ this.CustomizableUI = {
|
|||||||
* Restore Defaults can be performed.
|
* Restore Defaults can be performed.
|
||||||
*/
|
*/
|
||||||
get canUndoReset() {
|
get canUndoReset() {
|
||||||
return !!gUIStateBeforeReset;
|
return gUIStateBeforeReset.uiCustomizationState != null ||
|
||||||
|
gUIStateBeforeReset.drawInTitlebar != null;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -999,8 +999,8 @@ CustomizeMode.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_updateUndoResetButton: function() {
|
_updateUndoResetButton: function() {
|
||||||
let undoReset = this.document.getElementById("customization-undo-reset");
|
let undoResetButton = this.document.getElementById("customization-undo-reset-button");
|
||||||
undoReset.hidden = !CustomizableUI.canUndoReset;
|
undoResetButton.hidden = !CustomizableUI.canUndoReset;
|
||||||
},
|
},
|
||||||
|
|
||||||
handleEvent: function(aEvent) {
|
handleEvent: function(aEvent) {
|
||||||
@ -1052,7 +1052,9 @@ CustomizeMode.prototype = {
|
|||||||
observe: function(aSubject, aTopic, aData) {
|
observe: function(aSubject, aTopic, aData) {
|
||||||
switch (aTopic) {
|
switch (aTopic) {
|
||||||
case "nsPref:changed":
|
case "nsPref:changed":
|
||||||
|
this._updateResetButton();
|
||||||
this._updateTitlebarButton();
|
this._updateTitlebarButton();
|
||||||
|
this._updateUndoResetButton();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -11,18 +11,18 @@ add_task(function() {
|
|||||||
yield startCustomizing();
|
yield startCustomizing();
|
||||||
ok(!CustomizableUI.inDefaultState, "Not in default state to begin with");
|
ok(!CustomizableUI.inDefaultState, "Not in default state to begin with");
|
||||||
is(CustomizableUI.getPlacementOfWidget(homeButtonId), null, "Home button is in palette");
|
is(CustomizableUI.getPlacementOfWidget(homeButtonId), null, "Home button is in palette");
|
||||||
let undoReset = document.getElementById("customization-undo-reset");
|
let undoResetButton = document.getElementById("customization-undo-reset-button");
|
||||||
is(undoReset.hidden, true, "The undo button is hidden before reset");
|
is(undoResetButton.hidden, true, "The undo button is hidden before reset");
|
||||||
|
|
||||||
yield gCustomizeMode.reset();
|
yield gCustomizeMode.reset();
|
||||||
|
|
||||||
ok(CustomizableUI.inDefaultState, "In default state after reset");
|
ok(CustomizableUI.inDefaultState, "In default state after reset");
|
||||||
is(undoReset.hidden, false, "The undo button is visible after reset");
|
is(undoResetButton.hidden, false, "The undo button is visible after reset");
|
||||||
|
|
||||||
undoReset.click();
|
undoResetButton.click();
|
||||||
yield waitForCondition(function() !gCustomizeMode.resetting);
|
yield waitForCondition(function() !gCustomizeMode.resetting);
|
||||||
ok(!CustomizableUI.inDefaultState, "Not in default state after reset-undo");
|
ok(!CustomizableUI.inDefaultState, "Not in default state after reset-undo");
|
||||||
is(undoReset.hidden, true, "The undo button is hidden after clicking on the undo button");
|
is(undoResetButton.hidden, true, "The undo button is hidden after clicking on the undo button");
|
||||||
is(CustomizableUI.getPlacementOfWidget(homeButtonId), null, "Home button is in palette");
|
is(CustomizableUI.getPlacementOfWidget(homeButtonId), null, "Home button is in palette");
|
||||||
|
|
||||||
yield gCustomizeMode.reset();
|
yield gCustomizeMode.reset();
|
||||||
@ -34,29 +34,71 @@ add_task(function() {
|
|||||||
CustomizableUI.removeWidgetFromArea(homeButtonId);
|
CustomizableUI.removeWidgetFromArea(homeButtonId);
|
||||||
ok(!CustomizableUI.inDefaultState, "Not in default state to begin with");
|
ok(!CustomizableUI.inDefaultState, "Not in default state to begin with");
|
||||||
is(CustomizableUI.getPlacementOfWidget(homeButtonId), null, "Home button is in palette");
|
is(CustomizableUI.getPlacementOfWidget(homeButtonId), null, "Home button is in palette");
|
||||||
let undoReset = document.getElementById("customization-undo-reset");
|
let undoResetButton = document.getElementById("customization-undo-reset-button");
|
||||||
is(undoReset.hidden, true, "The undo button is hidden before reset");
|
is(undoResetButton.hidden, true, "The undo button is hidden before reset");
|
||||||
|
|
||||||
yield gCustomizeMode.reset();
|
yield gCustomizeMode.reset();
|
||||||
|
|
||||||
ok(CustomizableUI.inDefaultState, "In default state after reset");
|
ok(CustomizableUI.inDefaultState, "In default state after reset");
|
||||||
is(undoReset.hidden, false, "The undo button is visible after reset");
|
is(undoResetButton.hidden, false, "The undo button is visible after reset");
|
||||||
|
|
||||||
CustomizableUI.addWidgetToArea(homeButtonId, CustomizableUI.AREA_PANEL);
|
CustomizableUI.addWidgetToArea(homeButtonId, CustomizableUI.AREA_PANEL);
|
||||||
is(undoReset.hidden, true, "The undo button is hidden after another change");
|
is(undoResetButton.hidden, true, "The undo button is hidden after another change");
|
||||||
});
|
});
|
||||||
|
|
||||||
// "Restore defaults", exiting customize, and re-entering shouldn't show the Undo button
|
// "Restore defaults", exiting customize, and re-entering shouldn't show the Undo button
|
||||||
add_task(function() {
|
add_task(function() {
|
||||||
let undoReset = document.getElementById("customization-undo-reset");
|
let undoResetButton = document.getElementById("customization-undo-reset-button");
|
||||||
is(undoReset.hidden, true, "The undo button is hidden before a reset");
|
is(undoResetButton.hidden, true, "The undo button is hidden before a reset");
|
||||||
ok(!CustomizableUI.inDefaultState, "The browser should not be in default state");
|
ok(!CustomizableUI.inDefaultState, "The browser should not be in default state");
|
||||||
yield gCustomizeMode.reset();
|
yield gCustomizeMode.reset();
|
||||||
|
|
||||||
is(undoReset.hidden, false, "The undo button is hidden after a reset");
|
is(undoResetButton.hidden, false, "The undo button is visible after a reset");
|
||||||
yield endCustomizing();
|
yield endCustomizing();
|
||||||
yield startCustomizing();
|
yield startCustomizing();
|
||||||
is(undoReset.hidden, true, "The undo reset button should be hidden after entering customization mode");
|
is(undoResetButton.hidden, true, "The undo reset button should be hidden after entering customization mode");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Bug 971626 - Restore Defaults should collapse the Title Bar
|
||||||
|
add_task(function() {
|
||||||
|
if (Services.appinfo.OS != "WINNT" &&
|
||||||
|
Services.appinfo.OS != "Darwin") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let prefName = "browser.tabs.drawInTitlebar";
|
||||||
|
let defaultValue = Services.prefs.getBoolPref(prefName);
|
||||||
|
let restoreDefaultsButton = document.getElementById("customization-reset-button");
|
||||||
|
let titleBarButton = document.getElementById("customization-titlebar-visibility-button");
|
||||||
|
let undoResetButton = document.getElementById("customization-undo-reset-button");
|
||||||
|
ok(CustomizableUI.inDefaultState, "Should be in default state at start of test");
|
||||||
|
ok(restoreDefaultsButton.disabled, "Restore defaults button should be disabled when in default state");
|
||||||
|
is(titleBarButton.hasAttribute("checked"), !defaultValue, "Title bar button should reflect pref value");
|
||||||
|
is(undoResetButton.hidden, true, "Undo reset button should be hidden at start of test");
|
||||||
|
|
||||||
|
Services.prefs.setBoolPref(prefName, !defaultValue);
|
||||||
|
ok(!restoreDefaultsButton.disabled, "Restore defaults button should be enabled when pref changed");
|
||||||
|
is(titleBarButton.hasAttribute("checked"), defaultValue, "Title bar button should reflect changed pref value");
|
||||||
|
ok(!CustomizableUI.inDefaultState, "With titlebar flipped, no longer default");
|
||||||
|
is(undoResetButton.hidden, true, "Undo reset button should be hidden after pref change");
|
||||||
|
|
||||||
|
yield gCustomizeMode.reset();
|
||||||
|
ok(restoreDefaultsButton.disabled, "Restore defaults button should be disabled after reset");
|
||||||
|
is(titleBarButton.hasAttribute("checked"), !defaultValue, "Title bar button should reflect default value after reset");
|
||||||
|
is(Services.prefs.getBoolPref(prefName), defaultValue, "Reset should reset drawInTitlebar");
|
||||||
|
ok(CustomizableUI.inDefaultState, "In default state after titlebar reset");
|
||||||
|
is(undoResetButton.hidden, false, "Undo reset button should be visible after reset");
|
||||||
|
ok(!undoResetButton.disabled, "Undo reset button should be enabled after reset");
|
||||||
|
|
||||||
|
yield gCustomizeMode.undoReset();
|
||||||
|
ok(!restoreDefaultsButton.disabled, "Restore defaults button should be enabled after undo-reset");
|
||||||
|
is(titleBarButton.hasAttribute("checked"), defaultValue, "Title bar button should reflect undo-reset value");
|
||||||
|
ok(!CustomizableUI.inDefaultState, "No longer in default state after undo");
|
||||||
|
is(Services.prefs.getBoolPref(prefName), !defaultValue, "Undo-reset goes back to previous pref value");
|
||||||
|
is(undoResetButton.hidden, true, "Undo reset button should be hidden after undo-reset clicked");
|
||||||
|
|
||||||
|
Services.prefs.clearUserPref(prefName);
|
||||||
|
ok(CustomizableUI.inDefaultState, "In default state after pref cleared");
|
||||||
|
is(undoResetButton.hidden, true, "Undo reset button should be hidden at end of test");
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function asyncCleanup() {
|
add_task(function asyncCleanup() {
|
||||||
|
Loading…
Reference in New Issue
Block a user