Bug 486791 - BrowserStartup() throws exception when sidebars are inserted by code. r=gavin

This commit is contained in:
Jorge Villalobos 2009-05-18 12:43:39 +02:00
parent d24ef01513
commit 9fc1f9ebcf

View File

@ -998,21 +998,30 @@ function BrowserStartup() {
// The opener can be the hidden window too, if we're coming from the state // The opener can be the hidden window too, if we're coming from the state
// where no windows are open, and the hidden window has no sidebar box. // where no windows are open, and the hidden window has no sidebar box.
if (openerSidebarBox && !openerSidebarBox.hidden) { if (openerSidebarBox && !openerSidebarBox.hidden) {
let sidebarBox = document.getElementById("sidebar-box");
let sidebarTitle = document.getElementById("sidebar-title");
sidebarTitle.setAttribute("value", window.opener.document.getElementById("sidebar-title").getAttribute("value"));
sidebarBox.setAttribute("width", openerSidebarBox.boxObject.width);
let sidebarCmd = openerSidebarBox.getAttribute("sidebarcommand"); let sidebarCmd = openerSidebarBox.getAttribute("sidebarcommand");
sidebarBox.setAttribute("sidebarcommand", sidebarCmd); let sidebarCmdElem = document.getElementById(sidebarCmd);
// Note: we're setting 'src' on sidebarBox, which is a <vbox>, not on the
// <browser id="sidebar">. This lets us delay the actual load until
// delayedStartup().
sidebarBox.setAttribute("src", window.opener.document.getElementById("sidebar").getAttribute("src"));
mustLoadSidebar = true;
sidebarBox.hidden = false; // dynamically generated sidebars will fail this check.
document.getElementById("sidebar-splitter").hidden = false; if (sidebarCmdElem) {
document.getElementById(sidebarCmd).setAttribute("checked", "true"); let sidebarBox = document.getElementById("sidebar-box");
let sidebarTitle = document.getElementById("sidebar-title");
sidebarTitle.setAttribute(
"value", window.opener.document.getElementById("sidebar-title").getAttribute("value"));
sidebarBox.setAttribute("width", openerSidebarBox.boxObject.width);
sidebarBox.setAttribute("sidebarcommand", sidebarCmd);
// Note: we're setting 'src' on sidebarBox, which is a <vbox>, not on
// the <browser id="sidebar">. This lets us delay the actual load until
// delayedStartup().
sidebarBox.setAttribute(
"src", window.opener.document.getElementById("sidebar").getAttribute("src"));
mustLoadSidebar = true;
sidebarBox.hidden = false;
document.getElementById("sidebar-splitter").hidden = false;
sidebarCmdElem.setAttribute("checked", "true");
}
} }
} }
else { else {
@ -1028,7 +1037,7 @@ function BrowserStartup() {
command.setAttribute("checked", "true"); command.setAttribute("checked", "true");
} }
else { else {
// Remove the |sidebarcommand| attribute, because the element it // Remove the |sidebarcommand| attribute, because the element it
// refers to no longer exists, so we should assume this sidebar // refers to no longer exists, so we should assume this sidebar
// panel has been uninstalled. (249883) // panel has been uninstalled. (249883)
box.removeAttribute("sidebarcommand"); box.removeAttribute("sidebarcommand");