зеркало из 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",
|
POSITION_START_PREF: "sidebar.position_start",
|
||||||
DEFAULT_SIDEBAR_ID: "viewBookmarksSidebar",
|
DEFAULT_SIDEBAR_ID: "viewBookmarksSidebar",
|
||||||
|
|
||||||
get lastOpenedId() {
|
// lastOpenedId is set in show() but unlike currentID it's not cleared out on hide
|
||||||
return this._box.getAttribute("sidebarcommand");
|
// and isn't persisted across windows
|
||||||
},
|
lastOpenedId: null,
|
||||||
|
|
||||||
_box: null,
|
_box: null,
|
||||||
// The constructor of this label accesses the browser element due to the
|
// The constructor of this label accesses the browser element due to the
|
||||||
|
@ -64,19 +64,12 @@ var SidebarUI = {
|
||||||
},
|
},
|
||||||
|
|
||||||
uninit() {
|
uninit() {
|
||||||
// If this is the last browser window, persist various values that should be
|
let enumerator = Services.wm.getEnumerator(null);
|
||||||
// remembered for after a restart / reopening a browser window.
|
|
||||||
let enumerator = Services.wm.getEnumerator("navigator:browser");
|
|
||||||
enumerator.getNext();
|
enumerator.getNext();
|
||||||
if (!enumerator.hasMoreElements()) {
|
if (!enumerator.hasMoreElements()) {
|
||||||
document.persist("sidebar-box", "sidebarcommand");
|
document.persist("sidebar-box", "sidebarcommand");
|
||||||
|
|
||||||
let xulStore = Cc["@mozilla.org/xul/xulstore;1"].getService(Ci.nsIXULStore);
|
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")) {
|
if (this._box.hasAttribute("positionend")) {
|
||||||
document.persist("sidebar-box", "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.
|
// no source UI or no _box means we also can't adopt the state.
|
||||||
return false;
|
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) {
|
if (sourceUI._box.hidden) {
|
||||||
// just hidden means we have adopted the hidden state.
|
// just hidden means we have adopted the hidden state.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let commandID = sourceUI._box.getAttribute("sidebarcommand");
|
||||||
|
|
||||||
// dynamically generated sidebars will fail this check, but we still
|
// dynamically generated sidebars will fail this check, but we still
|
||||||
// consider it adopted.
|
// consider it adopted.
|
||||||
if (!document.getElementById(commandID)) {
|
if (!document.getElementById(commandID)) {
|
||||||
|
@ -237,8 +224,7 @@ var SidebarUI = {
|
||||||
|
|
||||||
// If we're not adopting settings from a parent window, set them now.
|
// If we're not adopting settings from a parent window, set them now.
|
||||||
let commandID = this._box.getAttribute("sidebarcommand");
|
let commandID = this._box.getAttribute("sidebarcommand");
|
||||||
let wasOpen = this._box.getAttribute("checked");
|
if (!commandID) {
|
||||||
if (!commandID || !wasOpen) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,9 +270,10 @@ var SidebarUI = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the current sidebar (ie, the ID of the broadcaster being used).
|
* 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() {
|
get currentID() {
|
||||||
return this.isOpen ? this.lastOpenedId : "";
|
return this._box.getAttribute("sidebarcommand");
|
||||||
},
|
},
|
||||||
|
|
||||||
get title() {
|
get title() {
|
||||||
|
@ -316,9 +303,9 @@ var SidebarUI = {
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
toggle(commandID = this.lastOpenedId, triggerNode) {
|
toggle(commandID = this.lastOpenedId, triggerNode) {
|
||||||
// First priority for a default value is this.lastOpenedId. If we still
|
// First priority for a default value is this.lastOpenedId which is set during show()
|
||||||
// don't have a command ID, or the command doesn't exist anymore,
|
// and not reset in hide(), unlike currentID. If show() hasn't been called or the command
|
||||||
// then fallback to a default sidebar.
|
// doesn't exist anymore, then fallback to a default sidebar.
|
||||||
if (!commandID || !this.getBroadcasterById(commandID)) {
|
if (!commandID || !this.getBroadcasterById(commandID)) {
|
||||||
commandID = this.DEFAULT_SIDEBAR_ID;
|
commandID = this.DEFAULT_SIDEBAR_ID;
|
||||||
}
|
}
|
||||||
|
@ -383,6 +370,7 @@ var SidebarUI = {
|
||||||
|
|
||||||
this._box.setAttribute("checked", "true");
|
this._box.setAttribute("checked", "true");
|
||||||
this._box.setAttribute("sidebarcommand", sidebarBroadcaster.id);
|
this._box.setAttribute("sidebarcommand", sidebarBroadcaster.id);
|
||||||
|
this.lastOpenedId = sidebarBroadcaster.id;
|
||||||
|
|
||||||
let title = sidebarBroadcaster.getAttribute("sidebartitle") ||
|
let title = sidebarBroadcaster.getAttribute("sidebartitle") ||
|
||||||
sidebarBroadcaster.getAttribute("label");
|
sidebarBroadcaster.getAttribute("label");
|
||||||
|
@ -458,6 +446,7 @@ var SidebarUI = {
|
||||||
this.browser.docShell.createAboutBlankContentViewer(null);
|
this.browser.docShell.createAboutBlankContentViewer(null);
|
||||||
|
|
||||||
sidebarBroadcaster.removeAttribute("checked");
|
sidebarBroadcaster.removeAttribute("checked");
|
||||||
|
this._box.setAttribute("sidebarcommand", "");
|
||||||
this._box.removeAttribute("checked");
|
this._box.removeAttribute("checked");
|
||||||
this._box.hidden = this._splitter.hidden = true;
|
this._box.hidden = this._splitter.hidden = true;
|
||||||
|
|
||||||
|
|
|
@ -13,19 +13,19 @@ registerCleanupFunction(async function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var showSidebar = async function(win = window) {
|
var showSidebar = async function() {
|
||||||
let button = win.document.getElementById("sidebar-button");
|
let button = document.getElementById("sidebar-button");
|
||||||
let sidebarFocusedPromise = BrowserTestUtils.waitForEvent(win.document, "SidebarFocused");
|
let sidebarFocusedPromise = BrowserTestUtils.waitForEvent(document, "SidebarFocused");
|
||||||
EventUtils.synthesizeMouseAtCenter(button, {}, win);
|
EventUtils.synthesizeMouseAtCenter(button, {});
|
||||||
await sidebarFocusedPromise;
|
await sidebarFocusedPromise;
|
||||||
ok(win.SidebarUI.isOpen, "Sidebar is opened");
|
ok(SidebarUI.isOpen, "Sidebar is opened");
|
||||||
ok(button.hasAttribute("checked"), "Toolbar button is checked");
|
ok(button.hasAttribute("checked"), "Toolbar button is checked");
|
||||||
};
|
};
|
||||||
|
|
||||||
var hideSidebar = async function(win = window) {
|
var hideSidebar = async function() {
|
||||||
let button = win.document.getElementById("sidebar-button");
|
let button = document.getElementById("sidebar-button");
|
||||||
EventUtils.synthesizeMouseAtCenter(button, {}, win);
|
EventUtils.synthesizeMouseAtCenter(button, {});
|
||||||
ok(!win.SidebarUI.isOpen, "Sidebar is closed");
|
ok(!SidebarUI.isOpen, "Sidebar is closed");
|
||||||
ok(!button.hasAttribute("checked"), "Toolbar button isn't checked");
|
ok(!button.hasAttribute("checked"), "Toolbar button isn't checked");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,12 +40,4 @@ add_task(async function() {
|
||||||
await hideSidebar();
|
await hideSidebar();
|
||||||
await showSidebar();
|
await showSidebar();
|
||||||
is(SidebarUI.currentID, "viewHistorySidebar", "Selected sidebar remembered");
|
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);
|
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче