Skip to content

Commit

Permalink
Bug 1665710: don't update session history for about:blank transient p…
Browse files Browse the repository at this point in the history
…ages r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D90589
  • Loading branch information
Randell Jesup committed Sep 22, 2020
1 parent be4a145 commit 2956279
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions docshell/base/CanonicalBrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
using namespace mozilla::ipc;

extern mozilla::LazyLogModule gAutoplayPermissionLog;
extern mozilla::LazyLogModule gSHLog;

#define AUTOPLAY_LOG(msg, ...) \
MOZ_LOG(gAutoplayPermissionLog, LogLevel::Debug, (msg, ##__VA_ARGS__))
Expand Down Expand Up @@ -354,6 +355,9 @@ CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad(
aLoadState->GetLoadingSessionHistoryInfo();
if (existingLoadingInfo) {
entry = SessionHistoryEntry::GetByLoadId(existingLoadingInfo->mLoadId);
MOZ_LOG(gSHLog, LogLevel::Verbose,
("SHEntry::GetByLoadId(%" PRIu64 ") -> %p",
existingLoadingInfo->mLoadId, entry.get()));
} else {
entry = new SessionHistoryEntry(aLoadState, aChannel);
if (IsTop()) {
Expand Down
10 changes: 6 additions & 4 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static mozilla::LazyLogModule gDocShellAndDOMWindowLeakLogging(
#endif
static mozilla::LazyLogModule gDocShellLeakLog("nsDocShellLeak");
extern mozilla::LazyLogModule gPageCacheLog;
static mozilla::LazyLogModule gSHLog("SessionHistory");
mozilla::LazyLogModule gSHLog("SessionHistory");

const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties";
const char kAppstringsBundleURL[] =
Expand Down Expand Up @@ -5689,7 +5689,8 @@ nsresult nsDocShell::RefreshURIFromQueue() {
}

nsresult nsDocShell::Embed(nsIContentViewer* aContentViewer,
WindowGlobalChild* aWindowActor) {
WindowGlobalChild* aWindowActor,
bool aIsTransientAboutBlank) {
// Save the LayoutHistoryState of the previous document, before
// setting up new document
PersistLayoutHistoryState();
Expand All @@ -5714,7 +5715,8 @@ nsresult nsDocShell::Embed(nsIContentViewer* aContentViewer,
SetHistoryEntryAndUpdateBC(Nothing(), Some<nsISHEntry*>(mLSHE));
}

if (StaticPrefs::fission_sessionHistoryInParent()) {
if (!aIsTransientAboutBlank &&
StaticPrefs::fission_sessionHistoryInParent()) {
MOZ_LOG(gSHLog, LogLevel::Debug, ("document %p Embed", this));
MoveLoadingToActiveEntry(mLoadType != LOAD_ERROR_PAGE);
}
Expand Down Expand Up @@ -6764,7 +6766,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
// hook 'em up
if (viewer) {
viewer->SetContainer(this);
rv = Embed(viewer, aActor);
rv = Embed(viewer, aActor, true);
NS_ENSURE_SUCCESS(rv, rv);

SetCurrentURI(blankDoc->GetDocumentURI(), nullptr, true, 0);
Expand Down
3 changes: 2 additions & 1 deletion docshell/base/nsDocShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,8 @@ class nsDocShell final : public nsDocLoader,
nsresult EnsureCommandHandler();
nsresult RefreshURIFromQueue();
nsresult Embed(nsIContentViewer* aContentViewer,
mozilla::dom::WindowGlobalChild* aWindowActor = nullptr);
mozilla::dom::WindowGlobalChild* aWindowActor = nullptr,
bool aIsTransientAboutBlank = false);
nsPresContext* GetEldestPresContext();
nsresult CheckLoadingPermissions();
nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType);
Expand Down
6 changes: 6 additions & 0 deletions docshell/shistory/SessionHistoryEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "mozilla/dom/nsCSPContext.h"
#include "mozilla/ipc/IPDLParamTraits.h"

extern mozilla::LazyLogModule gSHLog;

namespace mozilla {
namespace dom {

Expand Down Expand Up @@ -264,6 +266,8 @@ LoadingSessionHistoryInfo::LoadingSessionHistoryInfo(
SessionHistoryEntry::sLoadIdToEntry =
new nsDataHashtable<nsUint64HashKey, SessionHistoryEntry*>();
}
MOZ_LOG(gSHLog, LogLevel::Verbose,
("SHEntry::AddLoadId(%" PRIu64 " - %p", mLoadId, aEntry));
SessionHistoryEntry::sLoadIdToEntry->Put(mLoadId, aEntry);
}

Expand Down Expand Up @@ -303,6 +307,8 @@ void SessionHistoryEntry::RemoveLoadId(uint64_t aLoadId) {
return;
}

MOZ_LOG(gSHLog, LogLevel::Verbose,
("SHEntry::RemoveLoadId(%" PRIu64 ")", aLoadId));
sLoadIdToEntry->Remove(aLoadId);
}

Expand Down

0 comments on commit 2956279

Please sign in to comment.