Backed out 3 changesets (bug 1653123, bug 1602115) for perma failures on test_history_length_during_pageload.html. CLOSED TREE

Backed out changeset 6b3c0f542ef3 (bug 1653123)
Backed out changeset 951c0fd65a00 (bug 1602115)
Backed out changeset 258d0ebd9e34 (bug 1602115)
This commit is contained in:
Razvan Maries 2020-07-16 23:21:18 +03:00
Родитель f72690c246
Коммит 4ccaec8564
20 изменённых файлов: 30 добавлений и 340 удалений

Просмотреть файл

@ -2502,35 +2502,6 @@ bool BrowsingContext::CanSet(FieldIndex<IDX_BrowserId>, const uint32_t& aValue,
return GetBrowserId() == 0 && IsTop() && Children().IsEmpty();
}
void BrowsingContext::SessionHistoryChanged(int32_t aIndexDelta,
int32_t aLengthDelta) {
if (XRE_IsParentProcess() || StaticPrefs::fission_sessionHistoryInParent()) {
// This method is used to test index and length for the session history
// in child process only.
return;
}
if (!IsTop()) {
// Some tests have unexpected setup while Fission shistory is being
// implemented.
return;
}
RefPtr<ChildSHistory> shistory = GetChildSessionHistory();
if (!shistory || !shistory->AsyncHistoryLength()) {
return;
}
nsID changeID = shistory->AddPendingHistoryChange(aIndexDelta, aLengthDelta);
uint32_t index = shistory->Index();
uint32_t length = shistory->Count();
// Do artificial history update through parent process to test asynchronous
// history.length handling.
ContentChild::GetSingleton()->SendSessionHistoryUpdate(this, index, length,
changeID);
}
} // namespace dom
namespace ipc {

Просмотреть файл

@ -657,8 +657,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
bool CrossOriginIsolated();
void SessionHistoryChanged(int32_t aIndexDelta, int32_t aLengthDelta);
protected:
virtual ~BrowsingContext();
BrowsingContext(WindowContext* aParentWindow, BrowsingContextGroup* aGroup,

Просмотреть файл

@ -282,7 +282,7 @@ CanonicalBrowsingContext::CreateSessionHistoryEntryForLoad(
}
void CanonicalBrowsingContext::SessionHistoryCommit(
uint64_t aSessionHistoryEntryId, const nsID& aChangeID) {
uint64_t aSessionHistoryEntryId) {
for (size_t i = 0; i < mLoadingEntries.Length(); ++i) {
if (mLoadingEntries[i]->Info().Id() == aSessionHistoryEntryId) {
nsISHistory* shistory = GetSessionHistory();
@ -319,13 +319,9 @@ void CanonicalBrowsingContext::SessionHistoryCommit(
}
}
Group()->EachParent([&](ContentParent* aParent) {
nsISHistory* shistory = GetSessionHistory();
int32_t index = 0;
int32_t length = 0;
shistory->GetIndex(&index);
shistory->GetCount(&length);
Unused << aParent->SendHistoryCommitIndexAndLength(Top(), index, length,
aChangeID);
// FIXME Should we return the length to the one process that committed
// as an async return value? Or should this use synced fields?
Unused << aParent->SendHistoryCommitLength(Top(), shistory->GetCount());
});
return;
}

Просмотреть файл

@ -96,8 +96,7 @@ class CanonicalBrowsingContext final : public BrowsingContext {
nsISHistory* GetSessionHistory();
UniquePtr<SessionHistoryInfo> CreateSessionHistoryEntryForLoad(
nsDocShellLoadState* aLoadState, nsIChannel* aChannel);
void SessionHistoryCommit(uint64_t aSessionHistoryEntryId,
const nsID& aChangeID);
void SessionHistoryCommit(uint64_t aSessionHistoryEntryId);
// Calls the session history listeners' OnHistoryReload, storing the result in
// aCanReload. If aCanReload is set to true and we have an active or a loading

Просмотреть файл

@ -5367,22 +5367,17 @@ nsresult nsDocShell::Embed(nsIContentViewer* aContentViewer,
SetDocCurrentStateObj(mLSHE);
SetHistoryEntryAndUpdateBC(Nothing(), Some<nsISHEntry*>(mLSHE));
nsID changeID = {};
if (StaticPrefs::fission_sessionHistoryInParent()) {
mActiveEntry = nullptr;
mLoadingEntry.swap(mActiveEntry);
if (mActiveEntry) {
if (XRE_IsParentProcess()) {
mBrowsingContext->Canonical()->SessionHistoryCommit(
mActiveEntry->Id(), changeID);
mActiveEntry->Id());
} else {
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
if (rootSH) {
changeID = rootSH->AddPendingHistoryChange();
}
ContentChild* cc = ContentChild::GetSingleton();
mozilla::Unused << cc->SendHistoryCommit(
mBrowsingContext, mActiveEntry->Id(), changeID);
mozilla::Unused << cc->SendHistoryCommit(mBrowsingContext,
mActiveEntry->Id());
}
}
}

Просмотреть файл

@ -36,70 +36,18 @@ void ChildSHistory::SetIsInProcess(bool aIsInProcess) {
}
int32_t ChildSHistory::Count() {
if (StaticPrefs::fission_sessionHistoryInParent() || mAsyncHistoryLength) {
uint32_t length = mLength;
for (uint32_t i = 0; i < mPendingSHistoryChanges.Length(); ++i) {
length += mPendingSHistoryChanges[i].mLengthDelta;
}
if (mAsyncHistoryLength) {
MOZ_ASSERT(!StaticPrefs::fission_sessionHistoryInParent());
// XXX The assertion may be too strong here, but it fires only
// when the pref is enabled.
MOZ_ASSERT(mHistory->GetCount() == int32_t(length));
}
return length;
if (StaticPrefs::fission_sessionHistoryInParent()) {
return mLength;
}
return mHistory->GetCount();
}
int32_t ChildSHistory::Index() {
if (StaticPrefs::fission_sessionHistoryInParent() || mAsyncHistoryLength) {
uint32_t index = mIndex;
for (uint32_t i = 0; i < mPendingSHistoryChanges.Length(); ++i) {
index += mPendingSHistoryChanges[i].mIndexDelta;
}
if (mAsyncHistoryLength) {
MOZ_ASSERT(!StaticPrefs::fission_sessionHistoryInParent());
int32_t realIndex;
mHistory->GetIndex(&realIndex);
// XXX The assertion may be too strong here, but it fires only
// when the pref is enabled.
MOZ_ASSERT(realIndex == int32_t(index));
}
return index;
}
int32_t index;
mHistory->GetIndex(&index);
return index;
}
nsID ChildSHistory::AddPendingHistoryChange() {
int32_t indexDelta = 1;
int32_t lengthDelta = (Index() + indexDelta) - (Count() - 1);
return AddPendingHistoryChange(indexDelta, lengthDelta);
}
nsID ChildSHistory::AddPendingHistoryChange(int32_t aIndexDelta,
int32_t aLengthDelta) {
nsID changeID = {};
nsContentUtils::GenerateUUIDInPlace(changeID);
PendingSHistoryChange change = {changeID, aIndexDelta, aLengthDelta};
mPendingSHistoryChanges.AppendElement(change);
return changeID;
}
void ChildSHistory::SetIndexAndLength(uint32_t aIndex, uint32_t aLength,
const nsID& aChangeID) {
mIndex = aIndex;
mLength = aLength;
mPendingSHistoryChanges.RemoveElementsBy(
[aChangeID](const PendingSHistoryChange& aChange) {
return aChange.mChangeID == aChangeID;
});
}
void ChildSHistory::Reload(uint32_t aReloadFlags, ErrorResult& aRv) {
aRv = mHistory->Reload(aReloadFlags);
}
@ -200,26 +148,5 @@ nsISupports* ChildSHistory::GetParentObject() const {
return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
}
void ChildSHistory::SetAsyncHistoryLength(bool aEnable, ErrorResult& aRv) {
if (StaticPrefs::fission_sessionHistoryInParent() || !mHistory) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
if (mAsyncHistoryLength == aEnable) {
return;
}
mAsyncHistoryLength = aEnable;
if (mAsyncHistoryLength) {
mHistory->GetIndex(&mIndex);
mLength = mHistory->GetCount();
} else {
mIndex = -1;
mLength = 0;
mPendingSHistoryChanges.Clear();
}
}
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -24,7 +24,6 @@
#include "nsWrapperCache.h"
#include "nsThreadUtils.h"
#include "mozilla/LinkedList.h"
#include "nsID.h"
class nsISHEntry;
class nsISHistory;
@ -76,14 +75,7 @@ class ChildSHistory : public nsISupports, public nsWrapperCache {
nsISHistory* LegacySHistory();
void SetIndexAndLength(uint32_t aIndex, uint32_t aLength,
const nsID& aChangeId);
nsID AddPendingHistoryChange();
nsID AddPendingHistoryChange(int32_t aIndexDelta, int32_t aLengthDelta);
// AsyncHistoryLength is for testing.
void SetAsyncHistoryLength(bool aEnable, ErrorResult& aRv);
bool AsyncHistoryLength() { return mAsyncHistoryLength; }
void SetLength(uint32_t aLength) { mLength = aLength; }
private:
virtual ~ChildSHistory() = default;
@ -116,17 +108,7 @@ class ChildSHistory : public nsISupports, public nsWrapperCache {
RefPtr<BrowsingContext> mBrowsingContext;
nsCOMPtr<nsISHistory> mHistory;
mozilla::LinkedList<PendingAsyncHistoryNavigation> mPendingNavigations;
int32_t mIndex = -1;
int32_t mLength = 0;
struct PendingSHistoryChange {
nsID mChangeID;
int32_t mIndexDelta;
int32_t mLengthDelta;
};
AutoTArray<PendingSHistoryChange, 2> mPendingSHistoryChanges;
bool mAsyncHistoryLength = false;
uint32_t mLength = 0;
};
} // namespace dom

Просмотреть файл

@ -160,15 +160,14 @@ SessionHistoryEntry::SetIsSubFrame(bool aIsSubFrame) {
NS_IMETHODIMP
SessionHistoryEntry::GetHasUserInteraction(bool* aFlag) {
NS_WARNING("Not implemented in the parent process!");
*aFlag = true;
return NS_OK;
MOZ_CRASH("Not needed in the parent process?");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
SessionHistoryEntry::SetHasUserInteraction(bool aFlag) {
NS_WARNING("Not implemented in the parent process!");
return NS_OK;
MOZ_CRASH("Not needed in the parent process?");
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP

Просмотреть файл

@ -135,36 +135,6 @@ extern mozilla::LazyLogModule gPageCacheLog;
} \
PR_END_MACRO
class SHistoryChangeNotifier {
public:
explicit SHistoryChangeNotifier(nsSHistory* aHistory) {
// If we're already in an update, the outermost change notifier will
// update browsing context in the destructor.
if (!aHistory->HasOngoingUpdate()) {
aHistory->SetHasOngoingUpdate(true);
mSHistory = aHistory;
mInitialIndex = aHistory->Index();
mInitialLength = aHistory->Length();
}
}
~SHistoryChangeNotifier() {
if (mSHistory) {
MOZ_ASSERT(mSHistory->HasOngoingUpdate());
mSHistory->SetHasOngoingUpdate(false);
if (mSHistory->GetBrowsingContext()) {
mSHistory->GetBrowsingContext()->SessionHistoryChanged(
mSHistory->Index() - mInitialIndex,
mSHistory->Length() - mInitialLength);
}
}
}
RefPtr<nsSHistory> mSHistory;
int32_t mInitialIndex;
int32_t mInitialLength;
};
enum HistCmd { HIST_CMD_GOTOINDEX, HIST_CMD_RELOAD };
class nsSHistoryObserver final : public nsIObserver {
@ -232,7 +202,6 @@ void nsSHistory::EvictContentViewerForEntry(nsISHEntry* aEntry) {
nsSHistory::nsSHistory(BrowsingContext* aRootBC)
: mRootBC(aRootBC),
mHasOngoingUpdate(false),
mIsRemote(false),
mIndex(-1),
mRequestedIndex(-1),
@ -716,8 +685,6 @@ nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist) {
}
}
SHistoryChangeNotifier change(this);
nsCOMPtr<nsIURI> uri = aSHEntry->GetURI();
NOTIFY_LISTENERS(OnHistoryNewEntry, (uri, mIndex));
@ -840,8 +807,6 @@ nsSHistory::PurgeHistory(int32_t aNumEntries) {
return NS_ERROR_FAILURE;
}
SHistoryChangeNotifier change(this);
aNumEntries = std::min(aNumEntries, Length());
NOTIFY_LISTENERS(OnHistoryPurge, ());
@ -1407,8 +1372,6 @@ bool nsSHistory::RemoveDuplicate(int32_t aIndex, bool aKeepNext) {
return false;
}
SHistoryChangeNotifier change(this);
if (IsSameTree(root1, root2)) {
mEntries.RemoveElementAt(aIndex);
@ -1454,8 +1417,6 @@ nsSHistory::RemoveEntries(nsTArray<nsID>& aIDs, int32_t aStartIndex) {
void nsSHistory::RemoveEntries(nsTArray<nsID>& aIDs, int32_t aStartIndex,
bool* aDidRemove) {
SHistoryChangeNotifier change(this);
int32_t index = aStartIndex;
while (index >= 0 && RemoveChildEntries(this, --index, aIDs)) {
}
@ -1514,8 +1475,6 @@ void nsSHistory::RemoveDynEntriesForBFCacheEntry(nsIBFCacheEntry* aBFEntry) {
NS_IMETHODIMP
nsSHistory::UpdateIndex() {
SHistoryChangeNotifier change(this);
// Update the actual index with the right value.
if (mIndex != mRequestedIndex && mRequestedIndex != -1) {
mIndex = mRequestedIndex;

Просмотреть файл

@ -162,12 +162,6 @@ class nsSHistory : public mozilla::LinkedListElement<nsSHistory>,
int32_t* aOutEndIndex);
void NotifyListenersContentViewerEvicted(uint32_t aNumEvicted);
int32_t Length() { return int32_t(mEntries.Length()); }
int32_t Index() { return mIndex; }
mozilla::dom::BrowsingContext* GetBrowsingContext() { return mRootBC; }
bool HasOngoingUpdate() { return mHasOngoingUpdate; }
void SetHasOngoingUpdate(bool aVal) { mHasOngoingUpdate = aVal; }
protected:
virtual ~nsSHistory();
@ -231,8 +225,9 @@ class nsSHistory : public mozilla::LinkedListElement<nsSHistory>,
nsISHEntry* aNewEntry);
protected:
// Length of mEntries.
int32_t Length() { return int32_t(mEntries.Length()); }
bool mHasOngoingUpdate;
bool mIsRemote;
nsTArray<nsCOMPtr<nsISHEntry>> mEntries; // entries are never null
private:

Просмотреть файл

@ -1,17 +0,0 @@
<html>
<head>
<script>
function loadNextPage() {
if (location.search.includes("testAsyncLength=true")) {
var shell = SpecialPowers.wrap(window).docShell;
var shistory = SpecialPowers.do_QueryInterface(shell, "nsIWebNavigation").sessionHistory;
shistory.asyncHistoryLength = true;
}
opener.postMessage({ initialLength: history.length}, "*");
location.href = 'file_history_length_during_pageload_2.html';
}
</script>
</head>
<body onload="setTimeout(loadNextPage);">
</body>
</html>

Просмотреть файл

@ -1,20 +0,0 @@
<html>
<head>
<script>
opener.postMessage({ length: history.length}, "*");
function done() {
// Ensure history.length doesn't change after load event has fired.
opener.postMessage({ length: history.length}, "*");
var shell = SpecialPowers.wrap(window).docShell;
var shistory = SpecialPowers.do_QueryInterface(shell, "nsIWebNavigation").sessionHistory;
if (shistory.asyncHistoryLength) {
shistory.asyncHistoryLength = false;
}
}
</script>
</head>
<body onload="setTimeout(done);">
</body>
</html>

Просмотреть файл

@ -118,10 +118,6 @@ support-files = file_bug675587.html
[test_forceinheritprincipal_overrule_owner.html]
[test_framedhistoryframes.html]
support-files = file_framedhistoryframes.html
[test_history_length_during_pageload.html]
support-files =
file_history_length_during_pageload.html
file_history_length_during_pageload_2.html
[test_pushState_after_document_open.html]
[test_navigate_after_pagehide.html]
skip-if = debug # Bug 1648887

Просмотреть файл

@ -1,46 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test history.length during page load</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script>
SimpleTest.waitForExplicitFinish();
function runTest(testAsyncLength) {
return new Promise(function(resolve) {
var initialLength;
var messageCount = 0;
var win;
window.onmessage = function(event) {
if (event.data.initialLength) {
initialLength = event.data.initialLength;
} else {
is(event.data.length, initialLength + 1,
"history.length should increase by one when loading a new page");
}
if (++messageCount == 3) {
win.close();
resolve();
}
}
win = window.open("file_history_length_during_pageload.html?testAsyncLength=" + testAsyncLength);
});
}
async function runTests() {
await SpecialPowers.pushPrefEnv({set: [["fission.sessionHistoryInParent", false]]});
await runTest(true);
await SpecialPowers.pushPrefEnv({set: [["fission.sessionHistoryInParent", true]]});
await runTest(false);
SimpleTest.finish();
}
</script>
</head>
<body onload="runTests();">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>

Просмотреть файл

@ -4169,14 +4169,10 @@ mozilla::ipc::IPCResult ContentChild::RecvDisplayLoadError(
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvHistoryCommitIndexAndLength(
const MaybeDiscarded<BrowsingContext>& aContext, const uint32_t& aIndex,
const uint32_t& aLength, const nsID& aChangeID) {
mozilla::ipc::IPCResult ContentChild::RecvHistoryCommitLength(
const MaybeDiscarded<BrowsingContext>& aContext, uint32_t aLength) {
if (!aContext.IsNullOrDiscarded()) {
ChildSHistory* shistory = aContext.get()->GetChildSessionHistory();
if (shistory) {
shistory->SetIndexAndLength(aIndex, aLength, aChangeID);
}
aContext.get()->GetChildSessionHistory()->SetLength(aLength);
}
return IPC_OK();
}

Просмотреть файл

@ -808,9 +808,8 @@ class ContentChild final : public PContentChild,
ErrorResult& aRv) override;
mozilla::ipc::IProtocol* AsNativeActor() override { return this; }
mozilla::ipc::IPCResult RecvHistoryCommitIndexAndLength(
const MaybeDiscarded<BrowsingContext>& aContext, const uint32_t& aIndex,
const uint32_t& aLength, const nsID& aChangeID);
mozilla::ipc::IPCResult RecvHistoryCommitLength(
const MaybeDiscarded<BrowsingContext>& aContext, uint32_t aLength);
mozilla::ipc::IPCResult RecvFlushFOGData(FlushFOGDataResolver&& aResolver);

Просмотреть файл

@ -6804,10 +6804,9 @@ mozilla::ipc::IPCResult ContentParent::RecvNotifyOnHistoryReload(
mozilla::ipc::IPCResult ContentParent::RecvHistoryCommit(
const MaybeDiscarded<BrowsingContext>& aContext,
const uint64_t& aSessionHistoryEntryID, const nsID& aChangeID) {
uint64_t aSessionHistoryEntryID) {
if (!aContext.IsDiscarded()) {
aContext.get_canonical()->SessionHistoryCommit(aSessionHistoryEntryID,
aChangeID);
aContext.get_canonical()->SessionHistoryCommit(aSessionHistoryEntryID);
}
return IPC_OK();
@ -6830,24 +6829,6 @@ mozilla::ipc::IPCResult ContentParent::RecvHistoryGo(
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvSessionHistoryUpdate(
const MaybeDiscarded<BrowsingContext>& aContext, const int32_t& aIndex,
const int32_t& aLength, const nsID& aChangeID) {
if (aContext.IsNullOrDiscarded()) {
MOZ_LOG(
BrowsingContext::GetLog(), LogLevel::Debug,
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
CanonicalBrowsingContext* context = aContext.get_canonical();
context->Group()->EachParent([&](ContentParent* aParent) {
Unused << aParent->SendHistoryCommitIndexAndLength(aContext, aIndex,
aLength, aChangeID);
});
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvCommitWindowContextTransaction(
const MaybeDiscarded<WindowContext>& aContext,
WindowContext::BaseTransaction&& aTransaction, uint64_t aEpoch) {

Просмотреть файл

@ -1309,16 +1309,12 @@ class ContentParent final
mozilla::ipc::IPCResult RecvHistoryCommit(
const MaybeDiscarded<BrowsingContext>& aContext,
const uint64_t& aSessionHistoryEntryID, const nsID& aChangeID);
uint64_t aSessionHistoryEntryID);
mozilla::ipc::IPCResult RecvHistoryGo(
const MaybeDiscarded<BrowsingContext>& aContext, int32_t aOffset,
HistoryGoResolver&& aResolveRequestedIndex);
mozilla::ipc::IPCResult RecvSessionHistoryUpdate(
const MaybeDiscarded<BrowsingContext>& aContext, const int32_t& aIndex,
const int32_t& aLength, const nsID& aChangeID);
// Notify the ContentChild to enable the input event prioritization when
// initializing.
void MaybeEnableRemoteInputEventQueue();

Просмотреть файл

@ -909,17 +909,10 @@ child:
*/
async AbortOrientationPendingPromises(MaybeDiscardedBrowsingContext aContext);
async HistoryCommitIndexAndLength(MaybeDiscardedBrowsingContext aContext,
uint32_t aIndex, uint32_t aLength,
nsID aChangeID);
parent:
/**
* This is a temporary way to pass index and length through parent process.
* Used for testing.
*/
async SessionHistoryUpdate(MaybeDiscardedBrowsingContext aTopContext,
int32_t aIndex, int32_t aLength, nsID aChangeID);
async HistoryCommitLength(MaybeDiscardedBrowsingContext aContext,
uint32_t aLength);
parent:
async InitBackground(Endpoint<PBackgroundParent> aEndpoint);
async CreateGMPService();
@ -1642,8 +1635,7 @@ parent:
bool? reloadActiveEntry);
async HistoryCommit(MaybeDiscardedBrowsingContext aContext,
uint64_t aSessionHistoryEntryID,
nsID aChangeID);
uint64_t aSessionHistoryEntryID);
async HistoryGo(MaybeDiscardedBrowsingContext aContext,
int32_t aOffset) returns(int32_t requestedIndex);

Просмотреть файл

@ -36,12 +36,4 @@ interface ChildSHistory {
* process on ChildSHistory.
*/
readonly attribute nsISHistory legacySHistory;
/**
* asyncHistoryLength can be enabled to test Fission-like asynchronous
* history.length handling with non-Fission session history implementation.
* Throws if session history is running in the parent process.
*/
[SetterThrows]
attribute boolean asyncHistoryLength;
};