summaryrefslogtreecommitdiffstats
path: root/docshell/base
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-08-06 09:58:35 +0000
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-08-06 09:58:35 +0000
commitc1013e9122456b342d65e4eb4c38a7281d8d83d2 (patch)
tree56826cd621a732af00432815a526357ed2bec80c /docshell/base
parent80e4577e3b10245164d6a2c2416772b2819a9f6a (diff)
downloadUXP-c1013e9122456b342d65e4eb4c38a7281d8d83d2.tar
UXP-c1013e9122456b342d65e4eb4c38a7281d8d83d2.tar.gz
UXP-c1013e9122456b342d65e4eb4c38a7281d8d83d2.tar.lz
UXP-c1013e9122456b342d65e4eb4c38a7281d8d83d2.tar.xz
UXP-c1013e9122456b342d65e4eb4c38a7281d8d83d2.zip
Issue #1118 Part 4: Allow UpdateURLAndHistory to work even if there's no
root session history. This can happen when someone does a document.open() on a document that has no session history.
Diffstat (limited to 'docshell/base')
-rw-r--r--docshell/base/nsDocShell.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index 2aea69847..ebaf07bcd 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -12137,7 +12137,9 @@ nsDocShell::UpdateURLAndHistory(nsIDocument* aDocument, nsIURI* aNewURI,
// indicating that we're doing a pushState rather than a replaceState, notify
// bfcache that we've added a page to the history so it can evict content
// viewers if appropriate. Otherwise call ReplaceEntry so that we notify
- // nsIHistoryListeners that an entry was replaced.
+ // nsIHistoryListeners that an entry was replaced. We may not have a root
+ // session history if this call is coming from a document.open() in a docshell
+ // subtree that disables session history.
nsCOMPtr<nsISHistory> rootSH;
GetRootSessionHistory(getter_AddRefs(rootSH));
NS_ENSURE_TRUE(rootSH, NS_ERROR_UNEXPECTED);
@@ -12147,19 +12149,21 @@ nsDocShell::UpdateURLAndHistory(nsIDocument* aDocument, nsIURI* aNewURI,
nsresult rv;
- if (!aReplace) {
- int32_t curIndex = -1;
- rv = rootSH->GetIndex(&curIndex);
- if (NS_SUCCEEDED(rv) && curIndex > -1) {
- internalSH->EvictOutOfRangeContentViewers(curIndex);
- }
- } else {
- nsCOMPtr<nsISHEntry> rootSHEntry = GetRootSHEntry(newSHEntry);
+ if (rootSH) {
+ if (!aReplace) {
+ int32_t curIndex = -1;
+ rv = rootSH->GetIndex(&curIndex);
+ if (NS_SUCCEEDED(rv) && curIndex > -1) {
+ internalSH->EvictOutOfRangeContentViewers(curIndex);
+ }
+ } else {
+ nsCOMPtr<nsISHEntry> rootSHEntry = GetRootSHEntry(newSHEntry);
- int32_t index = -1;
- rv = rootSH->GetIndexOfEntry(rootSHEntry, &index);
- if (NS_SUCCEEDED(rv) && index > -1) {
- internalSH->ReplaceEntry(index, rootSHEntry);
+ int32_t index = -1;
+ rv = rootSH->GetIndexOfEntry(rootSHEntry, &index);
+ if (NS_SUCCEEDED(rv) && index > -1) {
+ internalSH->ReplaceEntry(index, rootSHEntry);
+ }
}
}