diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 8b207a1bbba..7c7457aca41 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -3002,6 +3002,17 @@ nsDocShell::LoadErrorPage(nsIURI *aURI, const PRUnichar *aURL, mURIResultedInDocument = PR_TRUE; OnNewURI(aURI, nsnull, mLoadType, PR_TRUE, PR_FALSE); } + // Be sure to have a correct mLSHE, it may have been cleared by + // EndPageLoad. See bug 302115. + if (mSessionHistory && !mLSHE) { + PRInt32 idx; + mSessionHistory->GetRequestedIndex(&idx); + nsCOMPtr entry; + mSessionHistory->GetEntryAtIndex(idx, PR_FALSE, + getter_AddRefs(entry)); + mLSHE = do_QueryInterface(entry); + + } nsCAutoString url; nsCAutoString charset; diff --git a/mozilla/docshell/shistory/public/nsISHistory.idl b/mozilla/docshell/shistory/public/nsISHistory.idl index c67fba0df03..7ce3dd5704f 100644 --- a/mozilla/docshell/shistory/public/nsISHistory.idl +++ b/mozilla/docshell/shistory/public/nsISHistory.idl @@ -62,7 +62,7 @@ interface nsISimpleEnumerator; #define NS_SHISTORY_CONTRACTID "@mozilla.org/browser/shistory;1" %} -[scriptable, uuid(7294FE9B-14D8-11D5-9882-00C04FA02F40)] +[scriptable, uuid(9883609F-CDD8-4d83-9B55-868FF08AD433)] interface nsISHistory: nsISupports { /** @@ -78,6 +78,12 @@ interface nsISHistory: nsISupports */ readonly attribute long index; + /** + * A readonly property of the interface that returns + * the index of the last document that started to load. + */ + readonly attribute long requestedIndex; + /** * A read/write property of the interface, used to Get/Set * the maximum number of toplevel documents, session history diff --git a/mozilla/docshell/shistory/src/nsSHistory.cpp b/mozilla/docshell/shistory/src/nsSHistory.cpp index 2a53f62e6c9..d14699dc5bd 100644 --- a/mozilla/docshell/shistory/src/nsSHistory.cpp +++ b/mozilla/docshell/shistory/src/nsSHistory.cpp @@ -343,11 +343,20 @@ nsSHistory::GetCount(PRInt32 * aResult) NS_IMETHODIMP nsSHistory::GetIndex(PRInt32 * aResult) { - NS_ENSURE_ARG_POINTER(aResult); + NS_PRECONDITION(aResult, "null out param?"); *aResult = mIndex; return NS_OK; } +/* Get the requestedIndex */ +NS_IMETHODIMP +nsSHistory::GetRequestedIndex(PRInt32 * aResult) +{ + NS_PRECONDITION(aResult, "null out param?"); + *aResult = mRequestedIndex; + return NS_OK; +} + NS_IMETHODIMP nsSHistory::GetEntryAtIndex(PRInt32 aIndex, PRBool aModifyIndex, nsISHEntry** aResult) {