Bug 1754004 - Part 10: Clone PostData when writing into & reading from SessionHistoryInfo, r=smaug
Previously the SessionHistoryInfo would hold onto and hand out the original nsIInputStream objects which were provided by the nsDocShellLoadState and used to create the underlying channel. This could cause issues in edge cases, as input streams when serialized over IPC have their logical owner transferred to the IPC layer so that it can copy the data to the peer process. This patch changes the logic to instead clone the input stream to and from the history info. This means that the history info has its own instance of the stream type and interacting with it shouldn't interfere with other consumers of the post data stream. The behaviour for non-SHIP session history is not changed, as it doesn't serialize the relevant streams over IPC in the same way, and is on track to be removed. Differential Revision: https://phabricator.services.mozilla.com/D141047
This commit is contained in:
@@ -8800,19 +8800,6 @@ bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (aState.mHistoryNavBetweenSameDoc) {
|
||||
nsCOMPtr<nsIInputStream> currentPostData;
|
||||
if (mozilla::SessionHistoryInParent()) {
|
||||
currentPostData = mActiveEntry->GetPostData();
|
||||
} else {
|
||||
currentPostData = mOSHE->GetPostData();
|
||||
}
|
||||
NS_ASSERTION(currentPostData == aLoadState->PostDataStream(),
|
||||
"Different POST data for entries for the same page?");
|
||||
}
|
||||
#endif
|
||||
|
||||
// A same document navigation happens when we navigate between two SHEntries
|
||||
// for the same document. We do a same document navigation under two
|
||||
// circumstances. Either
|
||||
@@ -10041,6 +10028,10 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
|
||||
|
||||
// we really need to have a content type associated with this stream!!
|
||||
postChannel->SetUploadStream(aLoadState->PostDataStream(), ""_ns, -1);
|
||||
|
||||
// Ownership of the stream has transferred to the channel, clear our
|
||||
// reference.
|
||||
aLoadState->SetPostDataStream(nullptr);
|
||||
}
|
||||
|
||||
/* If there is a valid postdata *and* it is a History Load,
|
||||
|
||||
Reference in New Issue
Block a user