From 78649b88bb654e7a3ca428d17ada96bb792cbda1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BCnzli?= Date: Sat, 6 Sep 2008 05:42:39 +0200 Subject: [PATCH] Bug 342635 - wrong scroll behaviour after loading new page while session restoring. r=dietrich --- .../sessionstore/src/nsSessionStore.js | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/browser/components/sessionstore/src/nsSessionStore.js b/browser/components/sessionstore/src/nsSessionStore.js index b605797cfab..9c228159541 100644 --- a/browser/components/sessionstore/src/nsSessionStore.js +++ b/browser/components/sessionstore/src/nsSessionStore.js @@ -1785,18 +1785,23 @@ SessionStoreService.prototype = { } } - var content = aEvent.originalTarget.defaultView; - if (this.currentURI.spec == "about:config") { - // unwrap the document for about:config because otherwise the properties - // of the XBL bindings - as the textbox - aren't accessible (see bug 350718) - content = content.wrappedJSObject; + // don't restore text data and scrolling state if the user has navigated + // away before the loading completed (except for in-page navigation) + if (!this.__SS_restore_data.url || this.currentURI.spec.replace(/#.*/, "") == + this.__SS_restore_data.url.replace(/#.*/, "")) { + var content = aEvent.originalTarget.defaultView; + if (this.currentURI.spec == "about:config") { + // unwrap the document for about:config because otherwise the properties + // of the XBL bindings - as the textbox - aren't accessible (see bug 350718) + content = content.wrappedJSObject; + } + restoreTextDataAndScrolling(content, this.__SS_restore_data, ""); + + // notify the tabbrowser that this document has been completely restored + var event = this.ownerDocument.createEvent("Events"); + event.initEvent("SSTabRestored", true, false); + this.__SS_restore_tab.dispatchEvent(event); } - restoreTextDataAndScrolling(content, this.__SS_restore_data, ""); - - // notify the tabbrowser that this document has been completely restored - var event = this.ownerDocument.createEvent("Events"); - event.initEvent("SSTabRestored", true, false); - this.__SS_restore_tab.dispatchEvent(event); this.removeEventListener("load", this.__SS_restore, true); delete this.__SS_restore_data;