Bug 1728605 - Part 1: Add assertions to various non-SHIP codepaths, r=smaug

These codepaths will never be taken with SHIP enabled, and this patch adds a
couple assertions to keep track of that information for when we rip out SHIP.

Differential Revision: https://phabricator.services.mozilla.com/D124210
This commit is contained in:
Nika Layzell 2021-09-02 14:15:03 +00:00
Родитель 46162554f6
Коммит b123cca8a7
3 изменённых файлов: 24 добавлений и 9 удалений

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

@ -6681,6 +6681,8 @@ bool nsDocShell::CanSavePresentation(uint32_t aLoadType,
return false; // no entry to save into
}
MOZ_ASSERT(!mozilla::SessionHistoryInParent(),
"mOSHE cannot be non-null with SHIP");
nsCOMPtr<nsIContentViewer> viewer = mOSHE->GetContentViewer();
if (viewer) {
NS_WARNING("mOSHE already has a content viewer!");
@ -6838,6 +6840,7 @@ void nsDocShell::ReportBFCacheComboTelemetry(uint16_t aCombo) {
};
void nsDocShell::ReattachEditorToWindow(nsISHEntry* aSHEntry) {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
MOZ_ASSERT(!mIsBeingDestroyed);
NS_ASSERTION(!mEditorData,
@ -6895,6 +6898,8 @@ void nsDocShell::DetachEditorFromWindow() {
}
nsresult nsDocShell::CaptureState() {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
if (!mOSHE || mOSHE == mLSHE) {
// No entry to save into, or we're replacing the existing entry.
return NS_ERROR_FAILURE;
@ -6909,12 +6914,7 @@ nsresult nsDocShell::CaptureState() {
if (MOZ_UNLIKELY(MOZ_LOG_TEST(gPageCacheLog, LogLevel::Debug))) {
nsAutoCString spec;
nsCOMPtr<nsIURI> uri;
if (mozilla::SessionHistoryInParent()) {
uri = mActiveEntry->GetURI();
} else {
uri = mOSHE->GetURI();
}
nsCOMPtr<nsIURI> uri = mOSHE->GetURI();
if (uri) {
uri->GetSpec(spec);
}
@ -6950,6 +6950,8 @@ nsresult nsDocShell::CaptureState() {
NS_IMETHODIMP
nsDocShell::RestorePresentationEvent::Run() {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
if (mDocShell && NS_FAILED(mDocShell->RestoreFromHistory())) {
NS_WARNING("RestoreFromHistory failed");
}
@ -6958,6 +6960,8 @@ nsDocShell::RestorePresentationEvent::Run() {
NS_IMETHODIMP
nsDocShell::BeginRestore(nsIContentViewer* aContentViewer, bool aTop) {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
nsresult rv;
if (!aContentViewer) {
rv = EnsureContentViewer();
@ -7001,6 +7005,8 @@ nsDocShell::BeginRestore(nsIContentViewer* aContentViewer, bool aTop) {
}
nsresult nsDocShell::BeginRestoreChildren() {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
for (auto* childDocLoader : mChildList.ForwardRange()) {
nsCOMPtr<nsIDocShell> child = do_QueryObject(childDocLoader);
if (child) {
@ -7013,6 +7019,8 @@ nsresult nsDocShell::BeginRestoreChildren() {
NS_IMETHODIMP
nsDocShell::FinishRestore() {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
// First we call finishRestore() on our children. In the simulated load,
// all of the child frames finish loading before the main document.
@ -7052,6 +7060,7 @@ nsDocShell::GetRestoringDocument(bool* aRestoring) {
nsresult nsDocShell::RestorePresentation(nsISHEntry* aSHEntry,
bool* aRestoring) {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
MOZ_ASSERT(!mIsBeingDestroyed);
NS_ASSERTION(mLoadType & LOAD_CMD_HISTORY,
@ -7149,6 +7158,7 @@ bool nsDocShell::SandboxFlagsImplyCookies(const uint32_t& aSandboxFlags) {
}
nsresult nsDocShell::RestoreFromHistory() {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
MOZ_ASSERT(mRestorePresentationEvent.IsPending());
PresentationEventForgetter forgetter(mRestorePresentationEvent);
@ -7222,9 +7232,7 @@ nsresult nsDocShell::RestoreFromHistory() {
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
if (rootSH) {
mPreviousEntryIndex = rootSH->Index();
if (!mozilla::SessionHistoryInParent()) {
rootSH->LegacySHistory()->UpdateIndex();
}
rootSH->LegacySHistory()->UpdateIndex();
mLoadedEntryIndex = rootSH->Index();
MOZ_LOG(gPageCacheLog, LogLevel::Verbose,
("Previous index: %d, Loaded index: %d", mPreviousEntryIndex,

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

@ -1177,6 +1177,7 @@ class nsDocShell final : public nsDocLoader,
// Reference to the SHEntry for this docshell until the page is destroyed.
// Somebody give me better name
// Only used when SHIP is disabled.
nsCOMPtr<nsISHEntry> mOSHE;
// Reference to the SHEntry for this docshell until the page is loaded
@ -1185,6 +1186,7 @@ class nsDocShell final : public nsDocLoader,
// root history entries. That is, frames loaded during the parent page
// load don't generate history entries the way frame navigation after the
// parent has loaded does. (This isn't the only purpose of mLSHE.)
// Only used when SHIP is disabled.
nsCOMPtr<nsISHEntry> mLSHE;
// These are only set when fission.sessionHistoryInParent is set.
@ -1303,6 +1305,7 @@ class nsDocShell final : public nsDocLoader,
// Indicates to CreateContentViewer() that it is safe to cache the old
// presentation of the page, and to SetupNewViewer() that the old viewer
// should be passed a SHEntry to save itself into.
// Only used with SHIP disabled.
bool mSavingOldViewer : 1;
bool mInvisible : 1;

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

@ -7312,6 +7312,8 @@ void nsGlobalWindowOuter::EnsureSizeAndPositionUpToDate() {
}
already_AddRefed<nsISupports> nsGlobalWindowOuter::SaveWindowState() {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
if (!mContext || !GetWrapperPreserveColor()) {
// The window may be getting torn down; don't bother saving state.
return nullptr;
@ -7336,6 +7338,8 @@ already_AddRefed<nsISupports> nsGlobalWindowOuter::SaveWindowState() {
}
nsresult nsGlobalWindowOuter::RestoreWindowState(nsISupports* aState) {
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
if (!mContext || !GetWrapperPreserveColor()) {
// The window may be getting torn down; don't bother restoring state.
return NS_OK;