зеркало из https://github.com/mozilla/gecko-dev.git
Back out b5f5d47ac123 (bug 1391280) for breaking when session store tries to restore sidebars (latent errors in webextension test browser/components/extensions/test/browser/test-oop-extensions/browser_ext_tabs_lazy.js ) on a CLOSED TREE
MozReview-Commit-ID: LO2dv6ALkfZ --HG-- extra : rebase_source : 4eab585a14d52bb84a39d67b65b4b52098dee4a9 extra : amend_source : 2dd6e64a005fd949ab1429190b46dbb6861c9898
This commit is contained in:
Родитель
4814ba9f4f
Коммит
5098cc9707
|
@ -30,9 +30,9 @@ var SidebarUI = {
|
|||
POSITION_START_PREF: "sidebar.position_start",
|
||||
DEFAULT_SIDEBAR_ID: "viewBookmarksSidebar",
|
||||
|
||||
get lastOpenedId() {
|
||||
return this._box.getAttribute("sidebarcommand");
|
||||
},
|
||||
// lastOpenedId is set in show() but unlike currentID it's not cleared out on hide
|
||||
// and isn't persisted across windows
|
||||
lastOpenedId: null,
|
||||
|
||||
_box: null,
|
||||
// The constructor of this label accesses the browser element due to the
|
||||
|
@ -64,19 +64,12 @@ var SidebarUI = {
|
|||
},
|
||||
|
||||
uninit() {
|
||||
// If this is the last browser window, persist various values that should be
|
||||
// remembered for after a restart / reopening a browser window.
|
||||
let enumerator = Services.wm.getEnumerator("navigator:browser");
|
||||
let enumerator = Services.wm.getEnumerator(null);
|
||||
enumerator.getNext();
|
||||
if (!enumerator.hasMoreElements()) {
|
||||
document.persist("sidebar-box", "sidebarcommand");
|
||||
|
||||
let xulStore = Cc["@mozilla.org/xul/xulstore;1"].getService(Ci.nsIXULStore);
|
||||
if (this._box.hasAttribute("checked")) {
|
||||
document.persist("sidebar-box", "checked");
|
||||
} else {
|
||||
xulStore.removeValue(document.documentURI, "sidebar-box", "checked");
|
||||
}
|
||||
|
||||
if (this._box.hasAttribute("positionend")) {
|
||||
document.persist("sidebar-box", "positionend");
|
||||
|
@ -187,19 +180,13 @@ var SidebarUI = {
|
|||
// no source UI or no _box means we also can't adopt the state.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set sidebar command even if hidden, so that we keep the same sidebar
|
||||
// even if it's currently closed.
|
||||
let commandID = sourceUI._box.getAttribute("sidebarcommand");
|
||||
if (commandID) {
|
||||
this._box.setAttribute("sidebarcommand", commandID);
|
||||
}
|
||||
|
||||
if (sourceUI._box.hidden) {
|
||||
// just hidden means we have adopted the hidden state.
|
||||
return true;
|
||||
}
|
||||
|
||||
let commandID = sourceUI._box.getAttribute("sidebarcommand");
|
||||
|
||||
// dynamically generated sidebars will fail this check, but we still
|
||||
// consider it adopted.
|
||||
if (!document.getElementById(commandID)) {
|
||||
|
@ -237,8 +224,7 @@ var SidebarUI = {
|
|||
|
||||
// If we're not adopting settings from a parent window, set them now.
|
||||
let commandID = this._box.getAttribute("sidebarcommand");
|
||||
let wasOpen = this._box.getAttribute("checked");
|
||||
if (!commandID || !wasOpen) {
|
||||
if (!commandID) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -284,9 +270,10 @@ var SidebarUI = {
|
|||
|
||||
/**
|
||||
* The ID of the current sidebar (ie, the ID of the broadcaster being used).
|
||||
* This can be set even if the sidebar is hidden.
|
||||
*/
|
||||
get currentID() {
|
||||
return this.isOpen ? this.lastOpenedId : "";
|
||||
return this._box.getAttribute("sidebarcommand");
|
||||
},
|
||||
|
||||
get title() {
|
||||
|
@ -316,9 +303,9 @@ var SidebarUI = {
|
|||
* @return {Promise}
|
||||
*/
|
||||
toggle(commandID = this.lastOpenedId, triggerNode) {
|
||||
// First priority for a default value is this.lastOpenedId. If we still
|
||||
// don't have a command ID, or the command doesn't exist anymore,
|
||||
// then fallback to a default sidebar.
|
||||
// First priority for a default value is this.lastOpenedId which is set during show()
|
||||
// and not reset in hide(), unlike currentID. If show() hasn't been called or the command
|
||||
// doesn't exist anymore, then fallback to a default sidebar.
|
||||
if (!commandID || !this.getBroadcasterById(commandID)) {
|
||||
commandID = this.DEFAULT_SIDEBAR_ID;
|
||||
}
|
||||
|
@ -383,6 +370,7 @@ var SidebarUI = {
|
|||
|
||||
this._box.setAttribute("checked", "true");
|
||||
this._box.setAttribute("sidebarcommand", sidebarBroadcaster.id);
|
||||
this.lastOpenedId = sidebarBroadcaster.id;
|
||||
|
||||
let title = sidebarBroadcaster.getAttribute("sidebartitle") ||
|
||||
sidebarBroadcaster.getAttribute("label");
|
||||
|
@ -458,6 +446,7 @@ var SidebarUI = {
|
|||
this.browser.docShell.createAboutBlankContentViewer(null);
|
||||
|
||||
sidebarBroadcaster.removeAttribute("checked");
|
||||
this._box.setAttribute("sidebarcommand", "");
|
||||
this._box.removeAttribute("checked");
|
||||
this._box.hidden = this._splitter.hidden = true;
|
||||
|
||||
|
|
|
@ -13,19 +13,19 @@ registerCleanupFunction(async function() {
|
|||
}
|
||||
});
|
||||
|
||||
var showSidebar = async function(win = window) {
|
||||
let button = win.document.getElementById("sidebar-button");
|
||||
let sidebarFocusedPromise = BrowserTestUtils.waitForEvent(win.document, "SidebarFocused");
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, win);
|
||||
var showSidebar = async function() {
|
||||
let button = document.getElementById("sidebar-button");
|
||||
let sidebarFocusedPromise = BrowserTestUtils.waitForEvent(document, "SidebarFocused");
|
||||
EventUtils.synthesizeMouseAtCenter(button, {});
|
||||
await sidebarFocusedPromise;
|
||||
ok(win.SidebarUI.isOpen, "Sidebar is opened");
|
||||
ok(SidebarUI.isOpen, "Sidebar is opened");
|
||||
ok(button.hasAttribute("checked"), "Toolbar button is checked");
|
||||
};
|
||||
|
||||
var hideSidebar = async function(win = window) {
|
||||
let button = win.document.getElementById("sidebar-button");
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, win);
|
||||
ok(!win.SidebarUI.isOpen, "Sidebar is closed");
|
||||
var hideSidebar = async function() {
|
||||
let button = document.getElementById("sidebar-button");
|
||||
EventUtils.synthesizeMouseAtCenter(button, {});
|
||||
ok(!SidebarUI.isOpen, "Sidebar is closed");
|
||||
ok(!button.hasAttribute("checked"), "Toolbar button isn't checked");
|
||||
};
|
||||
|
||||
|
@ -40,12 +40,4 @@ add_task(async function() {
|
|||
await hideSidebar();
|
||||
await showSidebar();
|
||||
is(SidebarUI.currentID, "viewHistorySidebar", "Selected sidebar remembered");
|
||||
|
||||
await hideSidebar();
|
||||
let otherWin = await BrowserTestUtils.openNewBrowserWindow({opener: window});
|
||||
await showSidebar(otherWin);
|
||||
is(otherWin.SidebarUI.currentID, "viewHistorySidebar", "Selected sidebar remembered across windows");
|
||||
await hideSidebar(otherWin);
|
||||
|
||||
await BrowserTestUtils.closeWindow(otherWin);
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче