diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-08-06 08:41:51 +0000 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-08-06 08:41:51 +0000 |
commit | f5c848aa9b73ccaebd42dacaccfe7f2568ede343 (patch) | |
tree | 791fa36a19560a3b57afad68d11bfbf1cd880347 /docshell/base | |
parent | 027fbae80a8a3905ee4e6f8c33a8ccdcba735587 (diff) | |
download | UXP-f5c848aa9b73ccaebd42dacaccfe7f2568ede343.tar UXP-f5c848aa9b73ccaebd42dacaccfe7f2568ede343.tar.gz UXP-f5c848aa9b73ccaebd42dacaccfe7f2568ede343.tar.lz UXP-f5c848aa9b73ccaebd42dacaccfe7f2568ede343.tar.xz UXP-f5c848aa9b73ccaebd42dacaccfe7f2568ede343.zip |
Issue #1118 Part 2: Allow UpdateURLAndHistory to work even if mOSHE is
null, if we're doing a replace.
We're going to end up hitting this if someone does a document.open()
before mOSHE has been set. We shouldn't need to worry about mLSHE,
because the document.open() will cancel the corresponding load.
Diffstat (limited to 'docshell/base')
-rw-r--r-- | docshell/base/nsDocShell.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index d4d86b83a..2aea69847 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -12054,7 +12054,7 @@ nsDocShell::UpdateURLAndHistory(nsIDocument* aDocument, nsIURI* aNewURI, // history. This will erase all SHEntries after the new entry and make this // entry the current one. This operation may modify mOSHE, which we need // later, so we keep a reference here. - NS_ENSURE_TRUE(mOSHE, NS_ERROR_FAILURE); + NS_ENSURE_TRUE(mOSHE || aReplace, NS_ERROR_FAILURE); nsCOMPtr<nsISHEntry> oldOSHE = mOSHE; mLoadType = LOAD_PUSHSTATE; @@ -12101,6 +12101,16 @@ nsDocShell::UpdateURLAndHistory(nsIDocument* aDocument, nsIURI* aNewURI, } else { // Step 3. newSHEntry = mOSHE; + + // Since we're not changing which page we have loaded, pass + if (!newSHEntry) { + nsresult rv = AddToSessionHistory( + aNewURI, nullptr, + aDocument->NodePrincipal(), // triggeringPrincipal + nullptr, true, getter_AddRefs(newSHEntry)); + NS_ENSURE_SUCCESS(rv, rv); + mOSHE = newSHEntry; + } newSHEntry->SetURI(aNewURI); newSHEntry->SetOriginalURI(aNewURI); newSHEntry->SetLoadReplace(false); @@ -12117,7 +12127,10 @@ nsDocShell::UpdateURLAndHistory(nsIDocument* aDocument, nsIURI* aNewURI, // set URIWasModified to true for the current SHEntry (bug 669671). bool sameExceptHashes = true, oldURIWasModified = false; aNewURI->EqualsExceptRef(aCurrentURI, &sameExceptHashes); - oldOSHE->GetURIWasModified(&oldURIWasModified); + // mOSHE might be null on replace. Only check if we're not replacing. + if (oldOSHE) { + oldOSHE->GetURIWasModified(&oldURIWasModified); + } newSHEntry->SetURIWasModified(!sameExceptHashes || oldURIWasModified); // Step E as described at the top of AddState: If aReplace is false, |