Backed out changeset b8753e7cb414 (bug 1660526) for session related asan failures CLOSED TREE

This commit is contained in:
Bogdan Tara 2020-08-22 09:01:40 +03:00
parent 3674242e30
commit 90b813cb8e
3 changed files with 27 additions and 20 deletions

View File

@ -271,14 +271,14 @@ interface nsISHistory: nsISupports
nsISHEntry createEntry(); nsISHEntry createEntry();
[noscript] void AddToRootSessionHistory(in bool aCloneChildren, in nsISHEntry aOSHE, [noscript] void AddToRootSessionHistory(in bool aCloneChildren, in nsISHEntry aOSHE,
in BrowsingContext aRootBC, in nsISHEntry aEntry, in BrowsingContext aBC, in nsISHEntry aEntry,
in unsigned long aLoadType, in unsigned long aLoadType,
in bool aShouldPersist, in bool aShouldPersist,
out MaybeInt32 aPreviousEntryIndex, out MaybeInt32 aPreviousEntryIndex,
out MaybeInt32 aLoadedEntryIndex); out MaybeInt32 aLoadedEntryIndex);
[noscript] void AddChildSHEntryHelper(in nsISHEntry aCloneRef, in nsISHEntry aNewEntry, [noscript] void AddChildSHEntryHelper(in nsISHEntry aCloneRef, in nsISHEntry aNewEntry,
in BrowsingContext aRootBC, in bool aCloneChildren); in BrowsingContext aBC, in bool aCloneChildren);
[noscript, notxpcom] boolean isEmptyOrHasEntriesForSingleTopLevelPage(); [noscript, notxpcom] boolean isEmptyOrHasEntriesForSingleTopLevelPage();
}; };

View File

@ -523,10 +523,21 @@ nsresult nsSHistory::CloneAndReplace(
NS_IMETHODIMP NS_IMETHODIMP
nsSHistory::AddChildSHEntryHelper(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry, nsSHistory::AddChildSHEntryHelper(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
BrowsingContext* aRootBC, BrowsingContext* aBC, bool aCloneChildren) {
bool aCloneChildren) { nsCOMPtr<nsISHEntry> child;
MOZ_ASSERT(aRootBC->IsTop()); nsresult rv = AddChildSHEntryHelper(aCloneRef, aNewEntry, aBC, aCloneChildren,
getter_AddRefs(child));
if (NS_SUCCEEDED(rv)) {
child->SetDocshellID(aBC->GetHistoryID());
}
return rv;
}
nsresult nsSHistory::AddChildSHEntryHelper(nsISHEntry* aCloneRef,
nsISHEntry* aNewEntry,
BrowsingContext* aBC,
bool aCloneChildren,
nsISHEntry** aNextEntry) {
/* You are currently in the rootDocShell. /* You are currently in the rootDocShell.
* You will get here when a subframe has a new url * You will get here when a subframe has a new url
* to load and you have walked up the tree all the * to load and you have walked up the tree all the
@ -534,7 +545,6 @@ nsSHistory::AddChildSHEntryHelper(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
* and replace the subframe where a new url was loaded with * and replace the subframe where a new url was loaded with
* a new entry. * a new entry.
*/ */
nsCOMPtr<nsISHEntry> child;
nsCOMPtr<nsISHEntry> currentHE; nsCOMPtr<nsISHEntry> currentHE;
int32_t index = mIndex; int32_t index = mIndex;
if (index < 0) { if (index < 0) {
@ -546,16 +556,12 @@ nsSHistory::AddChildSHEntryHelper(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
nsresult rv = NS_OK; nsresult rv = NS_OK;
uint32_t cloneID = aCloneRef->GetID(); uint32_t cloneID = aCloneRef->GetID();
rv = nsSHistory::CloneAndReplace(currentHE, aRootBC, cloneID, aNewEntry, rv = nsSHistory::CloneAndReplace(currentHE, aBC, cloneID, aNewEntry,
aCloneChildren, getter_AddRefs(child)); aCloneChildren, aNextEntry);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
rv = AddEntry(child, true); rv = AddEntry(*aNextEntry, true);
if (NS_SUCCEEDED(rv)) {
child->SetDocshellID(aRootBC->GetHistoryID());
}
} }
return rv; return rv;
} }
@ -627,13 +633,10 @@ void nsSHistory::HandleEntriesToSwapInDocShell(
NS_IMETHODIMP NS_IMETHODIMP
nsSHistory::AddToRootSessionHistory(bool aCloneChildren, nsISHEntry* aOSHE, nsSHistory::AddToRootSessionHistory(bool aCloneChildren, nsISHEntry* aOSHE,
BrowsingContext* aRootBC, BrowsingContext* aBC, nsISHEntry* aEntry,
nsISHEntry* aEntry, uint32_t aLoadType, uint32_t aLoadType, bool aShouldPersist,
bool aShouldPersist,
Maybe<int32_t>* aPreviousEntryIndex, Maybe<int32_t>* aPreviousEntryIndex,
Maybe<int32_t>* aLoadedEntryIndex) { Maybe<int32_t>* aLoadedEntryIndex) {
MOZ_ASSERT(aRootBC->IsTop());
nsresult rv = NS_OK; nsresult rv = NS_OK;
// If we need to clone our children onto the new session // If we need to clone our children onto the new session
@ -641,7 +644,7 @@ nsSHistory::AddToRootSessionHistory(bool aCloneChildren, nsISHEntry* aOSHE,
if (aCloneChildren && aOSHE) { if (aCloneChildren && aOSHE) {
uint32_t cloneID = aOSHE->GetID(); uint32_t cloneID = aOSHE->GetID();
nsCOMPtr<nsISHEntry> newEntry; nsCOMPtr<nsISHEntry> newEntry;
nsSHistory::CloneAndReplace(aOSHE, aRootBC, cloneID, aEntry, true, nsSHistory::CloneAndReplace(aOSHE, aBC, cloneID, aEntry, true,
getter_AddRefs(newEntry)); getter_AddRefs(newEntry));
NS_ASSERTION(aEntry == newEntry, NS_ASSERTION(aEntry == newEntry,
"The new session history should be in the new entry"); "The new session history should be in the new entry");
@ -676,7 +679,7 @@ nsSHistory::AddToRootSessionHistory(bool aCloneChildren, nsISHEntry* aOSHE,
aPreviousEntryIndex->value(), aLoadedEntryIndex->value())); aPreviousEntryIndex->value(), aLoadedEntryIndex->value()));
} }
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
aEntry->SetDocshellID(aRootBC->GetHistoryID()); aEntry->SetDocshellID(aBC->GetHistoryID());
} }
return rv; return rv;
} }

View File

@ -127,6 +127,10 @@ class nsSHistory : public mozilla::LinkedListElement<nsSHistory>,
WalkHistoryEntriesFunc aCallback, WalkHistoryEntriesFunc aCallback,
void* aData); void* aData);
nsresult AddChildSHEntryHelper(nsISHEntry* aCloneRef, nsISHEntry* aNewEntry,
mozilla::dom::BrowsingContext* aBC,
bool aCloneChildren, nsISHEntry** aNextEntry);
nsTArray<nsCOMPtr<nsISHEntry>>& Entries() { return mEntries; } nsTArray<nsCOMPtr<nsISHEntry>>& Entries() { return mEntries; }
void RemoveEntries(nsTArray<nsID>& aIDs, int32_t aStartIndex, void RemoveEntries(nsTArray<nsID>& aIDs, int32_t aStartIndex,