зеркало из https://github.com/mozilla/gecko-dev.git
Bug 985815 - propagate collapsed state to other windows, add test. r=jaws
This commit is contained in:
Родитель
971c409e96
Коммит
3f513a5bc6
|
@ -4300,12 +4300,11 @@ function onViewToolbarsPopupShowing(aEvent, aInsertPoint) {
|
|||
|
||||
function onViewToolbarCommand(aEvent) {
|
||||
var toolbarId = aEvent.originalTarget.getAttribute("toolbarId");
|
||||
var toolbar = document.getElementById(toolbarId);
|
||||
var isVisible = aEvent.originalTarget.getAttribute("checked") == "true";
|
||||
setToolbarVisibility(toolbar, isVisible);
|
||||
CustomizableUI.setToolbarVisibility(toolbarId, isVisible);
|
||||
}
|
||||
|
||||
function setToolbarVisibility(toolbar, isVisible) {
|
||||
function setToolbarVisibility(toolbar, isVisible, persist=true) {
|
||||
let hidingAttribute;
|
||||
if (toolbar.getAttribute("type") == "menubar") {
|
||||
hidingAttribute = "autohide";
|
||||
|
@ -4317,7 +4316,10 @@ function setToolbarVisibility(toolbar, isVisible) {
|
|||
}
|
||||
|
||||
toolbar.setAttribute(hidingAttribute, !isVisible);
|
||||
document.persist(toolbar.id, hidingAttribute);
|
||||
if (persist) {
|
||||
document.persist(toolbar.id, hidingAttribute);
|
||||
}
|
||||
|
||||
let eventParams = {
|
||||
detail: {
|
||||
visible: isVisible
|
||||
|
|
|
@ -2170,6 +2170,7 @@ let CustomizableUIInternal = {
|
|||
_rebuildRegisteredAreas: function() {
|
||||
for (let [areaId, areaNodes] of gBuildAreas) {
|
||||
let placements = gPlacements.get(areaId);
|
||||
let isFirstChangedToolbar = true;
|
||||
for (let areaNode of areaNodes) {
|
||||
this.buildArea(areaId, placements, areaNode);
|
||||
|
||||
|
@ -2178,9 +2179,10 @@ let CustomizableUIInternal = {
|
|||
let defaultCollapsed = area.get("defaultCollapsed");
|
||||
let win = areaNode.ownerDocument.defaultView;
|
||||
if (defaultCollapsed !== null) {
|
||||
win.setToolbarVisibility(areaNode, !defaultCollapsed);
|
||||
win.setToolbarVisibility(areaNode, !defaultCollapsed, isFirstChangedToolbar);
|
||||
}
|
||||
}
|
||||
isFirstChangedToolbar = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2377,7 +2379,25 @@ let CustomizableUIInternal = {
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
setToolbarVisibility: function(aToolbarId, aIsVisible) {
|
||||
let area = gAreas.get(aToolbarId);
|
||||
if (area.get("type") != CustomizableUI.TYPE_TOOLBAR) {
|
||||
return;
|
||||
}
|
||||
let areaNodes = gBuildAreas.get(aToolbarId);
|
||||
if (!areaNodes) {
|
||||
return;
|
||||
}
|
||||
// We only persist the attribute the first time.
|
||||
let isFirstChangedToolbar = true;
|
||||
for (let areaNode of areaNodes) {
|
||||
let window = areaNode.ownerDocument.defaultView;
|
||||
window.setToolbarVisibility(areaNode, aIsVisible, isFirstChangedToolbar);
|
||||
isFirstChangedToolbar = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
Object.freeze(CustomizableUIInternal);
|
||||
|
||||
|
@ -3095,6 +3115,16 @@ this.CustomizableUI = {
|
|||
get inDefaultState() {
|
||||
return CustomizableUIInternal.inDefaultState;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set a toolbar's visibility state in all windows.
|
||||
* @param aToolbarId the toolbar whose visibility should be adjusted
|
||||
* @param aIsVisible whether the toolbar should be visible
|
||||
*/
|
||||
setToolbarVisibility: function(aToolbarId, aIsVisible) {
|
||||
CustomizableUIInternal.setToolbarVisibility(aToolbarId, aIsVisible);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a localized property off a (widget?) object.
|
||||
*
|
||||
|
|
|
@ -88,5 +88,6 @@ skip-if = os == "linux"
|
|||
[browser_978084_dragEnd_after_move.js]
|
||||
[browser_980155_add_overflow_toolbar.js]
|
||||
[browser_981418-widget-onbeforecreated-handler.js]
|
||||
[browser_985815_propagate_setToolbarVisibility.js]
|
||||
[browser_981305_separator_insertion.js]
|
||||
[browser_panel_toggle.js]
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/* 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";
|
||||
|
||||
add_task(function() {
|
||||
ok(CustomizableUI.inDefaultState, "Should start in default state.");
|
||||
this.otherWin = yield openAndLoadWindow({private: true}, true);
|
||||
yield startCustomizing(this.otherWin);
|
||||
let resetButton = this.otherWin.document.getElementById("customization-reset-button");
|
||||
ok(resetButton.disabled, "Reset button should be disabled");
|
||||
|
||||
if (typeof CustomizableUI.setToolbarVisibility == "function") {
|
||||
CustomizableUI.setToolbarVisibility("PersonalToolbar", true);
|
||||
} else {
|
||||
setToolbarVisibility(document.getElementById("PersonalToolbar"), true);
|
||||
}
|
||||
|
||||
let otherPersonalToolbar = this.otherWin.document.getElementById("PersonalToolbar");
|
||||
let personalToolbar = document.getElementById("PersonalToolbar");
|
||||
ok(!otherPersonalToolbar.collapsed, "Toolbar should be uncollapsed in private window");
|
||||
ok(!personalToolbar.collapsed, "Toolbar should be uncollapsed in normal window");
|
||||
ok(!resetButton.disabled, "Reset button should be enabled");
|
||||
|
||||
yield this.otherWin.gCustomizeMode.reset();
|
||||
|
||||
ok(otherPersonalToolbar.collapsed, "Toolbar should be collapsed in private window");
|
||||
ok(personalToolbar.collapsed, "Toolbar should be collapsed in normal window");
|
||||
ok(resetButton.disabled, "Reset button should be disabled");
|
||||
|
||||
yield endCustomizing(this.otherWin);
|
||||
|
||||
yield promiseWindowClosed(this.otherWin);
|
||||
});
|
||||
|
||||
|
||||
add_task(function asyncCleanup() {
|
||||
if (this.otherWin && !this.otherWin.closed) {
|
||||
yield promiseWindowClosed(this.otherWin);
|
||||
}
|
||||
if (!CustomizableUI.inDefaultState) {
|
||||
CustomizableUI.reset();
|
||||
}
|
||||
});
|
Загрузка…
Ссылка в новой задаче