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 sidebarCmd = openerSidebarBox.getAttribute("sidebarcommand");
let sidebarCmdElem = document.getElementById(sidebarCmd);
// dynamically generated sidebars will fail this check.
if (sidebarCmdElem) {
let sidebarBox = document.getElementById("sidebar-box"); let sidebarBox = document.getElementById("sidebar-box");
let sidebarTitle = document.getElementById("sidebar-title"); let sidebarTitle = document.getElementById("sidebar-title");
sidebarTitle.setAttribute("value", window.opener.document.getElementById("sidebar-title").getAttribute("value"));
sidebarTitle.setAttribute(
"value", window.opener.document.getElementById("sidebar-title").getAttribute("value"));
sidebarBox.setAttribute("width", openerSidebarBox.boxObject.width); sidebarBox.setAttribute("width", openerSidebarBox.boxObject.width);
let sidebarCmd = openerSidebarBox.getAttribute("sidebarcommand");
sidebarBox.setAttribute("sidebarcommand", sidebarCmd); sidebarBox.setAttribute("sidebarcommand", sidebarCmd);
// Note: we're setting 'src' on sidebarBox, which is a <vbox>, not on the // Note: we're setting 'src' on sidebarBox, which is a <vbox>, not on
// <browser id="sidebar">. This lets us delay the actual load until // the <browser id="sidebar">. This lets us delay the actual load until
// delayedStartup(). // delayedStartup().
sidebarBox.setAttribute("src", window.opener.document.getElementById("sidebar").getAttribute("src")); sidebarBox.setAttribute(
"src", window.opener.document.getElementById("sidebar").getAttribute("src"));
mustLoadSidebar = true; mustLoadSidebar = true;
sidebarBox.hidden = false; sidebarBox.hidden = false;
document.getElementById("sidebar-splitter").hidden = false; document.getElementById("sidebar-splitter").hidden = false;
document.getElementById(sidebarCmd).setAttribute("checked", "true"); sidebarCmdElem.setAttribute("checked", "true");
}
} }
} }
else { else {