Bug 1668215 - Bail out loading if the SessionHistoryEntry for LoadingSessionHistoryInfo isn't available anymore, r=peterv

I haven't managed to reproduce the crash

Differential Revision: https://phabricator.services.mozilla.com/D92150
This commit is contained in:
Olli Pettay 2020-10-02 11:53:18 +00:00
parent 19eb2d240b
commit 5cb8d35726
2 changed files with 18 additions and 8 deletions

View File

@ -359,6 +359,9 @@ CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad(
MOZ_LOG(gSHLog, LogLevel::Verbose,
("SHEntry::GetByLoadId(%" PRIu64 ") -> %p",
existingLoadingInfo->mLoadId, entry.get()));
if (!entry) {
return nullptr;
}
} else {
entry = new SessionHistoryEntry(aLoadState, aChannel);
if (IsTop()) {

View File

@ -477,6 +477,21 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
return nullptr;
}
auto* documentContext = GetDocumentBrowsingContext();
if (documentContext && mozilla::SessionHistoryInParent()) {
// It's hard to know at this point whether session history will be enabled
// in the browsing context, so we always create an entry for a load here.
mLoadingSessionHistoryInfo =
documentContext->CreateLoadingSessionHistoryEntryForLoad(aLoadState,
mChannel);
if (!mLoadingSessionHistoryInfo) {
*aRv = NS_BINDING_ABORTED;
mParentChannelListener = nullptr;
mChannel = nullptr;
return nullptr;
}
}
nsCOMPtr<nsIURI> uriBeingLoaded;
Unused << NS_WARN_IF(
NS_FAILED(mChannel->GetURI(getter_AddRefs(uriBeingLoaded))));
@ -539,7 +554,6 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
// across any serviceworker related data between channels as needed.
AddClientChannelHelperInParent(mChannel, std::move(aInfo));
auto* documentContext = GetDocumentBrowsingContext();
if (documentContext && !documentContext->StartDocumentLoad(this)) {
LOG(("DocumentLoadListener::Open failed StartDocumentLoad [this=%p]",
this));
@ -627,13 +641,6 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
mSrcdocData = aLoadState->SrcdocData();
mBaseURI = aLoadState->BaseURI();
mOriginalUriString = aLoadState->GetOriginalURIString();
if (documentContext && mozilla::SessionHistoryInParent()) {
// It's hard to know at this point whether session history will be enabled
// in the browsing context, so we always create an entry for a load here.
mLoadingSessionHistoryInfo =
documentContext->CreateLoadingSessionHistoryEntryForLoad(aLoadState,
mChannel);
}
if (documentContext) {
mParentWindowContext = documentContext->GetParentWindowContext();
} else {