Bug 1667449 - Hide fission.sessionHistoryInParent pref getter behind a function r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D91462
This commit is contained in:
Olli Pettay 2020-09-28 12:01:12 +00:00
parent 06bea3d5db
commit 97778cf44a
50 changed files with 169 additions and 212 deletions

View File

@ -8,9 +8,6 @@
var EXPORTED_SYMBOLS = ["AboutReaderParent"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
ChromeUtils.defineModuleGetter(
this,
@ -23,13 +20,6 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/ReaderMode.jsm"
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"sessionHistoryInParent",
"fission.sessionHistoryInParent",
false
);
const gStringBundle = Services.strings.createBundle(
"chrome://global/locale/aboutReader.properties"
);
@ -262,7 +252,7 @@ class AboutReaderParent extends JSWindowActorParent {
}
hasReaderModeEntryAtOffset(url, offset) {
if (sessionHistoryInParent) {
if (Services.appinfo.sessionHistoryInParent) {
let browsingContext = this.browsingContext;
if (browsingContext.childSessionHistory.canGo(offset)) {
let shistory = browsingContext.sessionHistory;

View File

@ -29,12 +29,6 @@
"UrlbarProviderOpenTabs",
"resource:///modules/UrlbarProviderOpenTabs.jsm"
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"sessionHistoryInParent",
"fission.sessionHistoryInParent",
false
);
Services.obs.addObserver(this, "contextual-identity-updated");
@ -1984,7 +1978,7 @@
// Ensure that SessionStore has flushed any session history state from the
// content process before we this browser's remoteness.
if (!this.sessionHistoryInParent) {
if (!Services.appinfo.sessionHistoryInParent) {
b.prepareToChangeRemoteness = () =>
SessionStore.prepareToChangeRemoteness(b);
}

View File

@ -20,7 +20,7 @@ add_task(async function test() {
});
async function promiseGetIndex(browser) {
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
return SpecialPowers.spawn(browser, [], function() {
let shistory =
docShell.browsingContext.childSessionHistory.legacySHistory;

View File

@ -10,7 +10,7 @@ const gExpectedHistory = {
};
async function get_remote_history(browser) {
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
let sessionHistory = browser.browsingContext?.sessionHistory;
if (!sessionHistory) {
return null;

View File

@ -532,10 +532,7 @@ class ContentSessionStore {
this.handlers = [new EventListener(this), this.messageQueue];
this._shistoryInParent = Services.prefs.getBoolPref(
"fission.sessionHistoryInParent",
false
);
this._shistoryInParent = Services.appinfo.sessionHistoryInParent;
if (this._shistoryInParent) {
this.mm.sendAsyncMessage("SessionStore:addSHistoryListener");
} else {

View File

@ -900,10 +900,7 @@ var SessionStoreInternal = {
);
Services.prefs.addObserver("privacy.resistFingerprinting", this);
this._shistoryInParent = Services.prefs.getBoolPref(
"fission.sessionHistoryInParent",
false
);
this._shistoryInParent = Services.appinfo.sessionHistoryInParent;
},
/**

View File

@ -38,7 +38,7 @@ var state = {
add_task(async function test() {
let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
await promiseTabState(tab, state);
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
function compareEntries(i, j, history) {
let e1 = history.getEntryAtIndex(i);

View File

@ -35,7 +35,7 @@ function restoreClosedTabWithValue(rval) {
function promiseNewLocationAndHistoryEntryReplaced(tab, snippet) {
let browser = tab.linkedBrowser;
if (Services.prefs.getBoolPref("fission.sessionHistoryInParent", false)) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
SpecialPowers.spawn(browser, [snippet], async function(codeSnippet) {
// Need to define 'webNavigation' for 'codeSnippet'
// eslint-disable-next-line no-unused-vars

View File

@ -38,7 +38,7 @@ add_task(async function test_add_interesting_window() {
content.location = newPage;
});
if (Services.prefs.getBoolPref("fission.sessionHistoryInParent", false)) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
let tab = newWin.gBrowser.selectedTab;
await promiseOnHistoryReplaceEntry(tab);
} else {

View File

@ -25,7 +25,7 @@ add_task(async function check_history_not_persisted() {
browser = tab.linkedBrowser;
await promiseTabState(tab, state);
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await SpecialPowers.spawn(browser, [], function() {
let sessionHistory =
docShell.browsingContext.childSessionHistory.legacySHistory;
@ -51,7 +51,7 @@ add_task(async function check_history_not_persisted() {
// Load a new URL into the tab, it should replace the about:blank history entry
BrowserTestUtils.loadURI(browser, "about:robots");
await promiseBrowserLoaded(browser);
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await SpecialPowers.spawn(browser, [], function() {
let sessionHistory =
docShell.browsingContext.childSessionHistory.legacySHistory;
@ -99,7 +99,7 @@ add_task(async function check_history_default_persisted() {
tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
browser = tab.linkedBrowser;
await promiseTabState(tab, state);
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await SpecialPowers.spawn(browser, [], function() {
let sessionHistory =
docShell.browsingContext.childSessionHistory.legacySHistory;
@ -125,7 +125,7 @@ add_task(async function check_history_default_persisted() {
// Load a new URL into the tab, it should replace the about:blank history entry
BrowserTestUtils.loadURI(browser, "about:robots");
await promiseBrowserLoaded(browser);
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await SpecialPowers.spawn(browser, [], function() {
let sessionHistory =
docShell.browsingContext.childSessionHistory.legacySHistory;

View File

@ -660,7 +660,7 @@ function setPropertyOfFormField(browserContext, selector, propName, newValue) {
}
function promiseOnHistoryReplaceEntryInChild(browser) {
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
return new Promise(resolve => {
let sessionHistory = browser.browsingContext?.sessionHistory;
if (sessionHistory) {

View File

@ -46,6 +46,7 @@
#include "mozilla/StaticPrefs_page_load.h"
#include "mozilla/StaticPtr.h"
#include "nsIURIFixup.h"
#include "nsIXULRuntime.h"
#include "nsDocShell.h"
#include "nsFocusManager.h"
@ -414,7 +415,7 @@ void BrowsingContext::CreateFromIPC(BrowsingContext::IPCInitializer&& aInit,
context->mCreatedDynamically = aInit.mCreatedDynamically;
if (context->GetHasSessionHistory()) {
context->CreateChildSHistory();
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
context->GetChildSessionHistory()->SetIndexAndLength(
aInit.mSessionHistoryIndex, aInit.mSessionHistoryCount, nsID());
}
@ -2084,8 +2085,7 @@ BrowsingContext::IPCInitializer BrowsingContext::GetIPCInitializer() {
init.mUseRemoteSubframes = mUseRemoteSubframes;
init.mCreatedDynamically = mCreatedDynamically;
init.mOriginAttributes = mOriginAttributes;
if (mChildSessionHistory &&
StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mChildSessionHistory && mozilla::SessionHistoryInParent()) {
init.mSessionHistoryIndex = mChildSessionHistory->Index();
init.mSessionHistoryCount = mChildSessionHistory->Count();
}
@ -2583,7 +2583,7 @@ void BrowsingContext::InitSessionHistory() {
}
ChildSHistory* BrowsingContext::GetChildSessionHistory() {
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
// For now we're checking that the session history object for the child
// process is available before returning the ChildSHistory object, because
// it is the actual implementation that ChildSHistory forwards to. This can
@ -2641,8 +2641,7 @@ bool BrowsingContext::CanSet(FieldIndex<IDX_PendingInitialization>,
void BrowsingContext::SessionHistoryChanged(int32_t aIndexDelta,
int32_t aLengthDelta) {
if (XRE_IsParentProcess() ||
StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (XRE_IsParentProcess() || mozilla::SessionHistoryInParent()) {
// This method is used to test index and length for the session history
// in child process only.
return;

View File

@ -163,6 +163,7 @@
#include "nsIWindowWatcher.h"
#include "nsIWritablePropertyBag2.h"
#include "nsIX509Cert.h"
#include "nsIXULRuntime.h"
#include "nsCommandManager.h"
#include "nsPIDOMWindow.h"
@ -830,7 +831,7 @@ nsresult nsDocShell::LoadURI(nsDocShellLoadState* aLoadState,
MOZ_LOG(gSHLog, LogLevel::Debug,
("nsDocShell[%p]: loading from session history", this));
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
return LoadHistoryEntry(aLoadState->SHEntry(), aLoadState->LoadType());
}
@ -925,7 +926,7 @@ bool nsDocShell::MaybeHandleSubframeHistory(
parentDS->GetLoadType(&parentLoadType);
if (!aContinueHandlingSubframeHistory) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
if (nsDocShell::Cast(parentDS.get())->IsLoadingFromSessionHistory() &&
!GetCreatedDynamically()) {
if (XRE_IsContentProcess()) {
@ -1146,7 +1147,7 @@ void nsDocShell::FirePageHideNotificationInternal(
MOZ_LOG(
gSHLog, LogLevel::Debug,
("nsDocShell %p unloading, remove dynamic subframe entries", this));
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
if (mActiveEntry) {
mBrowsingContext->RemoveDynEntriesFromActiveSessionHistoryEntry();
}
@ -1404,7 +1405,7 @@ bool nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
bool isRoot = mBrowsingContext->IsTop();
bool isSubFrame = false; // Is this a subframe navigation?
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
if (mLoadingEntry) {
isSubFrame = mLoadingEntry->mInfo.IsSubFrame();
MOZ_LOG(gSHLog, LogLevel::Debug,
@ -2720,7 +2721,7 @@ void nsDocShell::StoreWindowNameToSHEntries() {
mOSHE, [&](nsISHEntry* aEntry) { aEntry->SetName(name); });
}
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
if (XRE_IsParentProcess()) {
SessionHistoryEntry* entry =
mBrowsingContext->Canonical()->GetActiveSessionHistoryEntry();
@ -3051,7 +3052,7 @@ nsresult nsDocShell::AddChildSHEntry(nsISHEntry* aCloneRef,
nsISHEntry* aNewEntry,
int32_t aChildOffset, uint32_t aLoadType,
bool aCloneChildren) {
MOZ_ASSERT(!StaticPrefs::fission_sessionHistoryInParent_AtStartup());
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
nsresult rv = NS_OK;
if (mLSHE && aLoadType != LOAD_PUSHSTATE) {
@ -3079,7 +3080,7 @@ nsresult nsDocShell::AddChildSHEntry(nsISHEntry* aCloneRef,
nsresult nsDocShell::AddChildSHEntryToParent(nsISHEntry* aNewEntry,
int32_t aChildOffset,
bool aCloneChildren) {
MOZ_ASSERT(!StaticPrefs::fission_sessionHistoryInParent_AtStartup());
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
/* You will get here when you are in a subframe and
* a new url has been loaded on you.
* The mOSHE in this subframe will be the previous url's
@ -3240,7 +3241,7 @@ nsDocShell::GetDeviceSizeIsPageSize(bool* aValue) {
}
void nsDocShell::ClearFrameHistory(nsISHEntry* aEntry) {
MOZ_ASSERT(!StaticPrefs::fission_sessionHistoryInParent_AtStartup());
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
if (!rootSH || !aEntry) {
return;
@ -3982,7 +3983,7 @@ nsresult nsDocShell::LoadErrorPage(nsIURI* aErrorURI, nsIURI* aFailedURI,
// identifier, the error page won't persist.
mLSHE->AbandonBFCacheEntry();
}
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
// Commit the loading entry for the real load here, Embed will not commit
// the loading entry for the error page. History will then contain an entry
// for the real load, and the error page won't persist if we try loading
@ -4018,7 +4019,7 @@ nsDocShell::Reload(uint32_t aReloadFlags) {
// Send notifications to the HistoryListener if any, about the impending
// reload
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
MOZ_LOG(gSHLog, LogLevel::Debug, ("nsDocShell %p Reload", this));
bool forceReload = IsForceReloadType(loadType);
if (!XRE_IsParentProcess()) {
@ -4284,7 +4285,7 @@ nsDocShell::LoadPageAsViewSource(nsIDocShell* aOtherDocShell,
RefPtr<nsDocShellLoadState> loadState;
uint32_t cacheKey;
auto* otherDocShell = nsDocShell::Cast(aOtherDocShell);
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
loadState = new nsDocShellLoadState(newURI);
if (!otherDocShell->FillLoadStateFromCurrentEntry(*loadState)) {
return NS_ERROR_INVALID_POINTER;
@ -4342,7 +4343,7 @@ nsDocShell::GetCurrentDescriptor(nsISupports** aPageDescriptor) {
already_AddRefed<nsIInputStream> nsDocShell::GetPostDataFromCurrentEntry()
const {
nsCOMPtr<nsIInputStream> postData;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
if (mActiveEntry) {
postData = mActiveEntry->GetPostData();
} else if (mLoadingEntry) {
@ -4360,7 +4361,7 @@ already_AddRefed<nsIInputStream> nsDocShell::GetPostDataFromCurrentEntry()
}
Maybe<uint32_t> nsDocShell::GetCacheKeyFromCurrentEntry() const {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
if (mActiveEntry) {
return Some(mActiveEntry->GetCacheKey());
}
@ -5683,8 +5684,7 @@ nsresult nsDocShell::Embed(nsIContentViewer* aContentViewer,
NS_ENSURE_SUCCESS(rv, rv);
// XXX What if SetupNewViewer fails?
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup() ? !!mLoadingEntry
: !!mLSHE) {
if (mozilla::SessionHistoryInParent() ? !!mLoadingEntry : !!mLSHE) {
// Set history.state
SetDocCurrentStateObj(mLSHE,
mLoadingEntry ? &mLoadingEntry->mInfo : nullptr);
@ -5699,8 +5699,7 @@ nsresult nsDocShell::Embed(nsIContentViewer* aContentViewer,
SetHistoryEntryAndUpdateBC(Nothing(), Some<nsISHEntry*>(mLSHE));
}
if (!aIsTransientAboutBlank &&
StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!aIsTransientAboutBlank && mozilla::SessionHistoryInParent()) {
MOZ_LOG(gSHLog, LogLevel::Debug, ("document %p Embed", this));
MoveLoadingToActiveEntry(mLoadType != LOAD_ERROR_PAGE);
}
@ -7003,7 +7002,7 @@ nsresult nsDocShell::CaptureState() {
if (MOZ_UNLIKELY(MOZ_LOG_TEST(gPageCacheLog, LogLevel::Debug))) {
nsAutoCString spec;
nsCOMPtr<nsIURI> uri;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
uri = mActiveEntry->GetURI();
} else {
uri = mOSHE->GetURI();
@ -7325,7 +7324,7 @@ nsresult nsDocShell::RestoreFromHistory() {
RefPtr<ChildSHistory> rootSH = GetRootSessionHistory();
if (rootSH) {
mPreviousEntryIndex = rootSH->Index();
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
rootSH->LegacySHistory()->UpdateIndex();
}
mLoadedEntryIndex = rootSH->Index();
@ -7854,8 +7853,7 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
// Be sure to have a correct mLSHE, it may have been cleared by
// EndPageLoad. See bug 302115.
ChildSHistory* shistory = GetSessionHistory();
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup() && shistory &&
!mLSHE) {
if (!mozilla::SessionHistoryInParent() && shistory && !mLSHE) {
int32_t idx = shistory->LegacySHistory()->GetRequestedIndex();
if (idx == -1) {
idx = shistory->Index();
@ -8195,7 +8193,7 @@ void nsDocShell::SetDocCurrentStateObj(nsISHEntry* aShEntry,
NS_ENSURE_TRUE_VOID(document);
nsCOMPtr<nsIStructuredCloneContainer> scContainer;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
// If aInfo is null, just set the document's state object to null.
if (aInfo) {
scContainer = aInfo->GetStateData();
@ -8623,7 +8621,7 @@ bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
}
}
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
if (mActiveEntry && aLoadState->LoadIsFromSessionHistory()) {
aState.mHistoryNavBetweenSameDoc = mActiveEntry->SharesDocumentWith(
aLoadState->GetLoadingSessionHistoryInfo()->mInfo);
@ -8643,7 +8641,7 @@ bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
#ifdef DEBUG
if (aState.mHistoryNavBetweenSameDoc) {
nsCOMPtr<nsIInputStream> currentPostData;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
currentPostData = mActiveEntry->GetPostData();
} else {
currentPostData = mOSHE->GetPostData();
@ -8667,7 +8665,7 @@ bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
// The restriction that the SHEntries in (a) must be different ensures
// that history.go(0) and the like trigger full refreshes, rather than
// same document navigations.
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
bool doSameDocumentNavigation =
(aState.mHistoryNavBetweenSameDoc && mOSHE != aLoadState->SHEntry()) ||
(!aLoadState->SHEntry() && !aLoadState->PostDataStream() &&
@ -8744,9 +8742,8 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
nsCOMPtr<nsIPrincipal> newURITriggeringPrincipal, newURIPrincipalToInherit,
newURIPartitionedPrincipalToInherit;
nsCOMPtr<nsIContentSecurityPolicy> newCsp;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup() ? !!mActiveEntry
: !!mOSHE) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent() ? !!mActiveEntry : !!mOSHE) {
if (mozilla::SessionHistoryInParent()) {
newURITriggeringPrincipal = mActiveEntry->GetTriggeringPrincipal();
newURIPrincipalToInherit = mActiveEntry->GetPrincipalToInherit();
newURIPartitionedPrincipalToInherit =
@ -8781,9 +8778,8 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
uint32_t cacheKey = 0;
bool scrollRestorationIsManual = false;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup() ? !!mActiveEntry
: !!mOSHE) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent() ? !!mActiveEntry : !!mOSHE) {
if (mozilla::SessionHistoryInParent()) {
// FIXME Need to set scroll position on mActiveEntry.
scrollRestorationIsManual = mActiveEntry->GetScrollRestorationIsManual();
} else {
@ -8798,7 +8794,7 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
// above -- it filters out some LOAD_CMD_NORMAL cases that we
// wouldn't want here.
if (aLoadState->LoadType() & LOAD_CMD_NORMAL) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
postData = mActiveEntry->GetPostData();
cacheKey = mActiveEntry->GetCacheKey();
} else {
@ -8831,7 +8827,7 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
// If we're doing a history load, use its scroll restoration state.
if (aLoadState->LoadIsFromSessionHistory()) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
scrollRestorationIsManual = aLoadState->GetLoadingSessionHistoryInfo()
->mInfo.GetScrollRestorationIsManual();
} else {
@ -8862,8 +8858,7 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
SetCacheKeyOnHistoryEntry(mOSHE, cacheKey);
}
}
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup() &&
mLoadingEntry) {
if (mozilla::SessionHistoryInParent() && mLoadingEntry) {
MOZ_LOG(
gSHLog, LogLevel::Debug,
("Moving the loading entry to the active entry on nsDocShell %p to %s",
@ -8933,13 +8928,12 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
nscoord bx = 0;
nscoord by = 0;
bool needsScrollPosUpdate = false;
if ((StaticPrefs::fission_sessionHistoryInParent_AtStartup() ? !!mActiveEntry
: !!mOSHE) &&
if ((mozilla::SessionHistoryInParent() ? !!mActiveEntry : !!mOSHE) &&
(aLoadState->LoadType() == LOAD_HISTORY ||
aLoadState->LoadType() == LOAD_RELOAD_NORMAL) &&
!scrollRestorationIsManual) {
needsScrollPosUpdate = true;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
mActiveEntry->GetScrollPosition(&bx, &by);
} else {
mOSHE->GetScrollPosition(&bx, &by);
@ -9257,7 +9251,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
SetHistoryEntryAndUpdateBC(Some<nsISHEntry*>(aLoadState->SHEntry()),
Nothing());
if (aLoadState->LoadIsFromSessionHistory() &&
!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
!mozilla::SessionHistoryInParent()) {
// We're making history navigation or a reload. Make sure our history ID
// points to the same ID as SHEntry's docshell ID.
nsID historyID = {};
@ -9283,7 +9277,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
if (shistory) {
shistory->RemovePendingHistoryNavigations();
}
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
// It's possible that the previous viewer of mContentViewer is the
// viewer that will end up in aLoadState->SHEntry() when it gets closed.
// If that's the case, we need to go ahead and force it into its shentry
@ -10085,7 +10079,7 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
uint32_t cacheKey = 0;
if (aCacheKey) {
cacheKey = *aCacheKey;
} else if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
} else if (mozilla::SessionHistoryInParent()) {
if (mLoadingEntry) {
cacheKey = mLoadingEntry->mInfo.GetCacheKey();
} else if (mActiveEntry) { // for reload cases
@ -10656,8 +10650,7 @@ bool nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
* Hopefully I don't have to do that.
*/
if (equalUri &&
(StaticPrefs::fission_sessionHistoryInParent_AtStartup() ? !!mActiveEntry
: !!mOSHE) &&
(mozilla::SessionHistoryInParent() ? !!mActiveEntry : !!mOSHE) &&
(mLoadType == LOAD_NORMAL || mLoadType == LOAD_LINK ||
mLoadType == LOAD_STOP_CONTENT) &&
!inputStream) {
@ -10691,14 +10684,14 @@ bool nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
SetCacheKeyOnHistoryEntry(mLSHE ? mLSHE : mOSHE, cacheKey);
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
// Since we're force-reloading, clear all the sub frame history.
ClearFrameHistory(mLSHE);
ClearFrameHistory(mOSHE);
}
}
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
// Clear subframe history on refresh.
// XXX: history.go(0) won't go this path as aLoadType is LOAD_HISTORY in
// this case. One should re-validate after bug 1331865 fixed.
@ -10748,11 +10741,11 @@ bool nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
// If this was a history load or a refresh, or it was a history load but
// later changed to LOAD_NORMAL_REPLACE due to redirection, update the index
// in session history.
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup() && rootSH &&
if (!mozilla::SessionHistoryInParent() && rootSH &&
((mLoadType & (LOAD_CMD_HISTORY | LOAD_CMD_RELOAD)) ||
mLoadType == LOAD_NORMAL_REPLACE)) {
mPreviousEntryIndex = rootSH->Index();
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
rootSH->LegacySHistory()->UpdateIndex();
}
mLoadedEntryIndex = rootSH->Index();
@ -10998,7 +10991,7 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
aNewURI->EqualsExceptRef(aCurrentURI, &sameExceptHashes);
bool uriWasModified;
if (sameExceptHashes) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
uriWasModified = mActiveEntry && mActiveEntry->GetURIWasModified();
} else {
uriWasModified = oldOSHE && oldOSHE->GetURIWasModified();
@ -11023,7 +11016,7 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
nsPoint scrollPos = GetCurScrollPos();
bool scrollRestorationIsManual;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
// FIXME Need to save the current scroll position on mActiveEntry.
scrollRestorationIsManual = mActiveEntry->GetScrollRestorationIsManual();
} else {
@ -11035,7 +11028,7 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
nsCOMPtr<nsIContentSecurityPolicy> csp = aDocument->GetCsp();
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
MOZ_LOG(gSHLog, LogLevel::Debug,
("nsDocShell %p UpdateActiveEntry (not replacing)", this));
nsString title(mActiveEntry->GetTitle());
@ -11075,7 +11068,7 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
// we'll just set mOSHE here.
mOSHE = newSHEntry;
}
} else if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
} else if (mozilla::SessionHistoryInParent()) {
MOZ_LOG(gSHLog, LogLevel::Debug,
("nsDocShell %p UpdateActiveEntry (replacing)", this));
// Setting the resultPrincipalURI to nullptr is fine here: it will cause
@ -11111,7 +11104,7 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
newSHEntry->SetLoadReplace(false);
}
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
// Step 2.4 and 3: Modify new/original session history entry and clear its
// POST data, if there is any.
newSHEntry->SetStateData(aData);
@ -11178,7 +11171,7 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
NS_IMETHODIMP
nsDocShell::GetCurrentScrollRestorationIsManual(bool* aIsManual) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
*aIsManual = mActiveEntry && mActiveEntry->GetScrollRestorationIsManual();
return NS_OK;
}
@ -11286,8 +11279,7 @@ nsresult nsDocShell::AddToSessionHistory(
nsISHEntry** aNewEntry) {
MOZ_ASSERT(aURI, "uri is null");
MOZ_ASSERT(!aChannel || !aTriggeringPrincipal, "Shouldn't have both set");
MOZ_DIAGNOSTIC_ASSERT(
!StaticPrefs::fission_sessionHistoryInParent_AtStartup());
MOZ_DIAGNOSTIC_ASSERT(!mozilla::SessionHistoryInParent());
#if defined(DEBUG)
if (MOZ_LOG_TEST(gDocShellLog, LogLevel::Debug)) {
@ -11505,7 +11497,7 @@ void nsDocShell::UpdateActiveEntry(
nsIContentSecurityPolicy* aCsp, const nsAString& aTitle,
const Maybe<bool>& aScrollRestorationIsManual,
nsIStructuredCloneContainer* aData, bool aURIWasModified) {
MOZ_ASSERT(StaticPrefs::fission_sessionHistoryInParent_AtStartup());
MOZ_ASSERT(mozilla::SessionHistoryInParent());
MOZ_ASSERT(aURI, "uri is null");
MOZ_ASSERT(mLoadType == LOAD_PUSHSTATE,
"This code only deals with pushState");
@ -11651,10 +11643,9 @@ NS_IMETHODIMP
nsDocShell::PersistLayoutHistoryState() {
nsresult rv = NS_OK;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup() ? !!mActiveEntry
: !!mOSHE) {
if (mozilla::SessionHistoryInParent() ? !!mActiveEntry : !!mOSHE) {
bool scrollRestorationIsManual;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
scrollRestorationIsManual = mActiveEntry->GetScrollRestorationIsManual();
} else {
scrollRestorationIsManual = mOSHE->GetScrollRestorationIsManual();
@ -12102,7 +12093,7 @@ nsDocShell::GetIsExecutingOnLoadHandler(bool* aResult) {
NS_IMETHODIMP
nsDocShell::GetLayoutHistoryState(nsILayoutHistoryState** aLayoutHistoryState) {
nsCOMPtr<nsILayoutHistoryState> state;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
if (mActiveEntry) {
state = mActiveEntry->GetLayoutHistoryState();
}
@ -12801,7 +12792,7 @@ nsDocShell::ResumeRedirectedLoad(uint64_t aIdentifier, int32_t aHistoryIndex) {
// If we're performing a history load, locate the correct history entry,
// and set the relevant bits on our loadState.
if (aHistoryIndex >= 0 && self->GetSessionHistory() &&
!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
!mozilla::SessionHistoryInParent()) {
nsCOMPtr<nsISHistory> legacySHistory =
self->GetSessionHistory()->LegacySHistory();
@ -13194,7 +13185,7 @@ void nsDocShell::SetLoadingSessionHistoryInfo(
}
void nsDocShell::MoveLoadingToActiveEntry(bool aCommit) {
MOZ_ASSERT(StaticPrefs::fission_sessionHistoryInParent_AtStartup());
MOZ_ASSERT(mozilla::SessionHistoryInParent());
MOZ_LOG(gSHLog, LogLevel::Debug,
("nsDocShell %p MoveLoadingToActiveEntry", this));

View File

@ -9,7 +9,7 @@
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "mozilla/StaticPrefs_fission.h"
#include "nsIXULRuntime.h"
#include "nsComponentManagerUtils.h"
#include "nsSHEntry.h"
#include "nsSHistory.h"
@ -33,7 +33,7 @@ void ChildSHistory::SetIsInProcess(bool aIsInProcess) {
return;
}
if (mHistory || StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mHistory || mozilla::SessionHistoryInParent()) {
return;
}
@ -41,15 +41,14 @@ void ChildSHistory::SetIsInProcess(bool aIsInProcess) {
}
int32_t ChildSHistory::Count() {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup() ||
mAsyncHistoryLength) {
if (mozilla::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_AtStartup());
MOZ_ASSERT(!mozilla::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));
@ -60,15 +59,14 @@ int32_t ChildSHistory::Count() {
}
int32_t ChildSHistory::Index() {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup() ||
mAsyncHistoryLength) {
if (mozilla::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_AtStartup());
MOZ_ASSERT(!mozilla::SessionHistoryInParent());
int32_t realIndex;
mHistory->GetIndex(&realIndex);
// XXX The assertion may be too strong here, but it fires only
@ -108,7 +106,7 @@ void ChildSHistory::SetIndexAndLength(uint32_t aIndex, uint32_t aLength,
}
void ChildSHistory::Reload(uint32_t aReloadFlags, ErrorResult& aRv) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
if (XRE_IsParentProcess()) {
nsISHistory* shistory =
mBrowsingContext->Canonical()->GetSessionHistory();
@ -152,7 +150,7 @@ void ChildSHistory::Go(int32_t aOffset, bool aRequireUserInteraction,
}
// See Bug 1650095.
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
break;
}
@ -190,7 +188,7 @@ void ChildSHistory::AsyncGo(int32_t aOffset, bool aRequireUserInteraction,
}
void ChildSHistory::GotoIndex(int32_t aIndex, ErrorResult& aRv) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
nsCOMPtr<nsISHistory> shistory = mHistory;
mBrowsingContext->HistoryGo(aIndex, [shistory](int32_t&& aRequestedIndex) {
// FIXME Should probably only do this for non-fission.
@ -208,13 +206,13 @@ void ChildSHistory::RemovePendingHistoryNavigations() {
}
void ChildSHistory::EvictLocalContentViewers() {
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
mHistory->EvictAllContentViewers();
}
}
nsISHistory* ChildSHistory::GetLegacySHistory(ErrorResult& aError) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
aError.ThrowTypeError(
"legacySHistory is not available with session history in the parent.");
return nullptr;
@ -251,7 +249,7 @@ nsISupports* ChildSHistory::GetParentObject() const {
}
void ChildSHistory::SetAsyncHistoryLength(bool aEnable, ErrorResult& aRv) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup() || !mHistory) {
if (mozilla::SessionHistoryInParent() || !mHistory) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}

View File

@ -21,6 +21,7 @@
#include "nsISHEntry.h"
#include "nsISHistoryListener.h"
#include "nsIURI.h"
#include "nsIXULRuntime.h"
#include "nsNetUtil.h"
#include "nsSHEntry.h"
#include "SessionHistoryEntry.h"
@ -34,7 +35,6 @@
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "mozilla/StaticPrefs_fission.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/dom/CanonicalBrowsingContext.h"
#include "nsIWebNavigation.h"
@ -335,7 +335,7 @@ uint32_t nsSHistory::CalcMaxTotalViewers() {
// static
void nsSHistory::UpdatePrefs() {
Preferences::GetInt(PREF_SHISTORY_SIZE, &gHistoryMaxSize);
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
sHistoryMaxTotalViewers = 0;
return;
}
@ -436,8 +436,7 @@ nsresult nsSHistory::WalkHistoryEntries(nsISHEntry* aRootEntry,
// If the SH pref is on and we are in the parent process, update
// canonical BC directly
bool foundChild = false;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup() &&
XRE_IsParentProcess()) {
if (mozilla::SessionHistoryInParent() && XRE_IsParentProcess()) {
if (child->Canonical()->HasHistoryEntry(childEntry)) {
childBC = child;
foundChild = true;
@ -687,7 +686,7 @@ nsresult nsSHistory::SetChildHistoryEntry(nsISHEntry* aEntry,
void nsSHistory::HandleEntriesToSwapInDocShell(
mozilla::dom::BrowsingContext* aBC, nsISHEntry* aOldEntry,
nsISHEntry* aNewEntry) {
bool shPref = StaticPrefs::fission_sessionHistoryInParent_AtStartup();
bool shPref = mozilla::SessionHistoryInParent();
if (aBC->IsInProcess() || !shPref) {
nsDocShell* docshell = static_cast<nsDocShell*>(aBC->GetDocShell());
if (docshell) {
@ -1831,7 +1830,7 @@ void nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry,
// a same-document navigation (see nsDocShell::IsSameDocumentNavigation), so
// record that here in the LoadingSessionHistoryEntry.
bool loadingFromActiveEntry;
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
loadingFromActiveEntry =
aFrameBC->Canonical()->GetActiveSessionHistoryEntry() == aFrameEntry;
} else {
@ -1842,7 +1841,7 @@ void nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry,
loadState->SetLoadIsFromSessionHistory(mRequestedIndex, Length(),
loadingFromActiveEntry);
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
nsCOMPtr<SessionHistoryEntry> she = do_QueryInterface(aFrameEntry);
aFrameBC->Canonical()->AddLoadingSessionHistoryEntry(
loadState->GetLoadingSessionHistoryInfo()->mLoadId, she);
@ -1867,8 +1866,7 @@ void nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry,
NS_IMETHODIMP
nsSHistory::CreateEntry(nsISHEntry** aEntry) {
nsCOMPtr<nsISHEntry> entry;
if (XRE_IsParentProcess() &&
StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (XRE_IsParentProcess() && mozilla::SessionHistoryInParent()) {
entry = new SessionHistoryEntry();
} else {
entry = new nsSHEntry();

View File

@ -11,7 +11,7 @@ add_task(async function test() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "https://example.com/" },
async function(browser) {
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await SpecialPowers.spawn(browser, [], async function() {
let history = this.content.docShell.QueryInterface(
Ci.nsIWebNavigation

View File

@ -8,7 +8,7 @@ let getActor = browser => {
};
add_task(async function runTests() {
if (!Services.prefs.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await setupAsync();
let browser = gBrowser.selectedBrowser;
// Now that we're set up, initialize our frame script.

View File

@ -14,7 +14,7 @@ add_task(async function test() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "http://example.com" },
async function(browser) {
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await SpecialPowers.spawn(browser, [], async function() {
let cw = content;
let oldTitle = cw.document.title;

View File

@ -15,7 +15,7 @@ add_task(async function test() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:blank" },
async function(browser) {
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await ContentTask.spawn(browser, URL, async function(URL) {
let history = docShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory;

View File

@ -35,7 +35,7 @@
}
// Work around bug 467960
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
let history = gBrowser.browsingContext.sessionHistory;
history.purgeHistory(history.count);
} else {

View File

@ -37,7 +37,7 @@
function finish() {
gBrowser.removeEventListener("pageshow", eventListener, true);
// Work around bug 467960
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
var history = gBrowser.browsingContext.sessionHistory;
history.purgeHistory(history.count);
} else {

View File

@ -59,7 +59,7 @@
function doTest() {
let history;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
history = gBrowser.browsingContext.sessionHistory;
} else {
history = gBrowser.webNavigation.sessionHistory.legacySHistory;

View File

@ -90,7 +90,7 @@
var docshell = TestWindow.getWindow().docShell;
let shistory;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
shistory = docshell.browsingContext.sessionHistory;
} else {
shistory = docshell.sessionHistory.legacySHistory;

View File

@ -35,7 +35,7 @@
}
// Work around bug 467960
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
let history = gBrowser.browsingContext.sessionHistory;
history.purgeHistory(history.count);
} else {

View File

@ -449,7 +449,7 @@ function pageEventListener(event) {
function finish() {
// Work around bug 467960.
let history;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
history = TestWindow.getBrowser().browsingContext?.sessionHistory;
} else {
history = TestWindow.getBrowser().webNavigation.sessionHistory

View File

@ -30,7 +30,7 @@
}
async function runTests() {
await runTest(!SpecialPowers.getBoolPref("fission.sessionHistoryInParent"));
await runTest(!SpecialPowers.Services.appinfo.sessionHistoryInParent);
SimpleTest.finish();
}
</script>

View File

@ -14,7 +14,7 @@ add_task(async function() {
browser
) {
// At this point, we haven't set gHistoryMaxSize to 0, and it is still 50 (default value).
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
let sh = browser.browsingContext.sessionHistory;
is(
sh.count,
@ -63,7 +63,7 @@ add_task(async function() {
browser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
await promise;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
let sh = browser.browsingContext.sessionHistory;
is(sh.count, 0, "We should not save any entries in session history");
is(sh.index, -1);

View File

@ -15,7 +15,7 @@ add_task(async function() {
browser
) {
let testDone = {};
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
// 2. Add a promise that will be resolved when the 'content viewer evicted' event goes off
testDone.promise = SpecialPowers.spawn(browser, [], async function() {
return new Promise(resolve => {

View File

@ -17,7 +17,7 @@
opener.info("file_bug1300461_back.html");
opener.is(shistory.count, 2, "check history length");
opener.is(shistory.index, 1, "check history index");
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
opener.is(shistory.legacySHistory.requestedIndex, -1, "check requestedIndex");
} else {
let index = await opener.getSHRequestedIndex();

View File

@ -12,7 +12,7 @@
.docShell
.QueryInterface(SpecialPowers.Ci.nsIWebNavigation)
.sessionHistory;
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
shistory.legacySHistory.evictAllContentViewers();
} else {
opener.evictAllContentViewers();

View File

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1375833
let webNav, shistory;
let frameDocShellId;
let chromeScript = null;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
chromeScript = SpecialPowers.loadChromeScript(() => {
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
@ -77,7 +77,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1375833
ok(newFrameDocShellId, "sanity check for docshell ID");
is(newFrameDocShellId, frameDocShellId, "check docshell ID remains after reload");
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
let entry = shistory.legacySHistory.getEntryAtIndex(shistory.index);
let frameEntry = entry.GetChildAt(0);
is(String(frameEntry.docshellID), frameDocShellId, "check newly added shentry uses the same docshell ID");

View File

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=
<script type="application/javascript">
let chromeScript = null;
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
chromeScript = SpecialPowers.loadChromeScript(() => {
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");

View File

@ -36,11 +36,11 @@
#include "mozilla/dom/ParentProcessMessageManager.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/dom/TimeoutManager.h"
#include "mozilla/StaticPrefs_fission.h"
#include "xpcpublic.h"
#include "nsObserverService.h"
#include "nsFocusManager.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIXULRuntime.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -251,8 +251,7 @@ void MarkDocShell(nsIDocShellTreeItem* aNode, bool aCleanupJS) {
nsISHistory* legacyHistory =
history ? history->GetLegacySHistory(ignore) : nullptr;
if (legacyHistory) {
MOZ_DIAGNOSTIC_ASSERT(
!StaticPrefs::fission_sessionHistoryInParent_AtStartup());
MOZ_DIAGNOSTIC_ASSERT(!mozilla::SessionHistoryInParent());
int32_t historyCount = history->Count();
for (int32_t i = 0; i < historyCount; ++i) {
nsCOMPtr<nsISHEntry> shEntry;

View File

@ -50,8 +50,8 @@
#include "ReferrerInfo.h"
#include "nsIOpenWindowInfo.h"
#include "nsISHistory.h"
#include "nsIURI.h"
#include "nsIXULRuntime.h"
#include "nsNetUtil.h"
#include "nsGkAtoms.h"
@ -1881,7 +1881,7 @@ void nsFrameLoader::StartDestroy(bool aForProcessSwitch) {
RefPtr<ChildSHistory> childSHistory =
browsingContext->Top()->GetChildSessionHistory();
if (childSHistory) {
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
browsingContext->RemoveFromSessionHistory();
} else {
AutoTArray<nsID, 16> ids({browsingContext->GetHistoryID()});

View File

@ -167,7 +167,7 @@
#include "mozilla/dom/CustomEvent.h"
#include "nsIScreenManager.h"
#include "nsIClassifiedChannel.h"
#include "nsIXULRuntime.h"
#include "xpcprivate.h"
#ifdef NS_PRINTING
@ -6316,7 +6316,7 @@ bool nsGlobalWindowOuter::IsOnlyTopLevelDocumentInSHistory() {
// Disabled since IsFrame() is buggy in Fission
// MOZ_ASSERT(mBrowsingContext->IsTop());
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
return mBrowsingContext->GetIsSingleToplevelInHistory();
}

View File

@ -135,6 +135,7 @@
#include "nsViewportInfo.h"
#include "nsWebBrowser.h"
#include "nsWindowWatcher.h"
#include "nsIXULRuntime.h"
#ifdef XP_WIN
# include "mozilla/plugins/PluginWidgetChild.h"
@ -3449,7 +3450,7 @@ nsresult BrowserChild::CanCancelContentJS(
// If we have session history in the parent we've already performed
// the checks following, so we can return early.
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
*aCanCancel = true;
return NS_OK;
}

View File

@ -122,6 +122,7 @@
#include "SessionStoreFunctions.h"
#include "mozilla/dom/CrashReport.h"
#include "nsISecureBrowserUI.h"
#include "nsIXULRuntime.h"
#ifdef XP_WIN
# include "mozilla/plugins/PluginWidgetParent.h"
@ -3519,7 +3520,7 @@ bool BrowserParent::CanCancelContentJS(
nsIURI* aNavigationURI) const {
// Pre-checking if we can cancel content js in the parent is only
// supported when session history in the parent is enabled.
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (!mozilla::SessionHistoryInParent()) {
// If session history in the parent isn't enabled, this check will
// be fully done in BrowserChild::CanCancelContentJS
return true;

View File

@ -28,7 +28,7 @@ var checkResult = async function(isRemote, browserKey, uri) {
"browser.permanentKey should be correct"
);
if (SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
let sessionHistory =
gBrowser.selectedBrowser.browsingContext.sessionHistory;
let entry = sessionHistory.getEntryAtIndex(sessionHistory.count - 1);

View File

@ -91,7 +91,7 @@
#include "nsIPromptCollection.h"
#include "nsIPromptService.h"
#include "imgIContainer.h" // image animation mode constants
#include "nsIXULRuntime.h"
#include "nsSandboxFlags.h"
#include "mozilla/DocLoadingTimelineMarker.h"
@ -2066,7 +2066,7 @@ nsDocumentViewer::Show(void) {
treeItem->GetInProcessSameTypeRootTreeItem(getter_AddRefs(root));
nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(root);
RefPtr<ChildSHistory> history = webNav->GetSessionHistory();
if (!StaticPrefs::fission_sessionHistoryInParent_AtStartup() && history) {
if (!mozilla::SessionHistoryInParent() && history) {
int32_t prevIndex, loadedIndex;
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(treeItem);
docShell->GetPreviousEntryIndex(&prevIndex);

View File

@ -3591,6 +3591,7 @@
type: bool
value: false
mirror: once
do_not_use_directly: true
# Allow renaming of process names to the origin on nightly
# Setting this pref creates a privacy leak, but helps greatly with

View File

@ -40,6 +40,7 @@
#include "nsIStreamConverterService.h"
#include "nsIViewSourceChannel.h"
#include "nsImportModule.h"
#include "nsIXULRuntime.h"
#include "nsMimeTypes.h"
#include "nsQueryObject.h"
#include "nsRedirectHistoryEntry.h"
@ -626,8 +627,7 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
mSrcdocData = aLoadState->SrcdocData();
mBaseURI = aLoadState->BaseURI();
mOriginalUriString = aLoadState->GetOriginalURIString();
if (documentContext &&
StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (documentContext && mozilla::SessionHistoryInParent()) {
// It's hard to know at this point whether session history will be enabled
// in the browsing context, so we always create an entry for a load here.
mLoadingSessionHistoryInfo =

View File

@ -13,6 +13,7 @@
#include "nsDocShell.h"
#include "nsIObserverService.h"
#include "nsIClassifiedChannel.h"
#include "nsIXULRuntime.h"
extern mozilla::LazyLogModule gDocumentChannelLog;
#define LOG(fmt) MOZ_LOG(gDocumentChannelLog, mozilla::LogLevel::Verbose, fmt)
@ -69,8 +70,7 @@ ParentProcessDocumentChannel::RedirectToRealChannel(
mStreamFilterEndpoints = std::move(aStreamFilterEndpoints);
if (mDocumentLoadListener->IsDocumentLoad() &&
StaticPrefs::fission_sessionHistoryInParent_AtStartup() &&
GetDocShell()) {
mozilla::SessionHistoryInParent() && GetDocShell()) {
GetDocShell()->SetLoadingSessionHistoryInfo(
*mDocumentLoadListener->GetLoadingSessionHistoryInfo());
}

View File

@ -82,7 +82,7 @@ var ReaderMode = {
let url = win.document.location.href;
let readerURL = "about:reader?url=" + encodeURIComponent(url);
if (!this.sessionHistoryInParent) {
if (!Services.appinfo.sessionHistoryInParent) {
let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
let sh = webNav.sessionHistory;
if (webNav.canGoForward) {
@ -108,7 +108,7 @@ var ReaderMode = {
let originalURL = ReaderMode.getOriginalUrl(url);
let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
if (!this.sessionHistoryInParent) {
if (!Services.appinfo.sessionHistoryInParent) {
let sh = webNav.sessionHistory;
if (webNav.canGoBack) {
let prevEntry = sh.legacySHistory.getEntryAtIndex(sh.index - 1);
@ -681,10 +681,3 @@ XPCOMUtils.defineLazyPreferenceGetter(
"reader.parse-node-limit",
0
);
XPCOMUtils.defineLazyPreferenceGetter(
ReaderMode,
"sessionHistoryInParent",
"fission.sessionHistoryInParent",
false
);

View File

@ -13,16 +13,6 @@ ChromeUtils.defineModuleGetter(
"PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm"
);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"SESSION_HISTORY_IN_PARENT",
"fission.sessionHistoryInParent",
false
);
class RemoteWebNavigation {
constructor(aBrowser) {
@ -49,14 +39,14 @@ class RemoteWebNavigation {
}
get canGoBack() {
if (SESSION_HISTORY_IN_PARENT) {
if (Services.appinfo.sessionHistoryInParent) {
return this._browser.browsingContext.sessionHistory?.index > 0;
}
return this._canGoBack;
}
get canGoForward() {
if (SESSION_HISTORY_IN_PARENT) {
if (Services.appinfo.sessionHistoryInParent) {
let sessionHistory = this._browser.browsingContext.sessionHistory;
return sessionHistory?.index < sessionHistory?.count - 1;
}

View File

@ -48,7 +48,7 @@ add_task(async function test_referrer() {
// Tests that remote access to webnavigation.sessionHistory works.
add_task(async function test_history() {
async function checkHistoryIndex(browser, n) {
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
return SpecialPowers.spawn(browser, [n], function(n) {
let history =
docShell.browsingContext.childSessionHistory.legacySHistory;
@ -71,7 +71,7 @@ add_task(async function test_history() {
browser.webNavigation.loadURI(DUMMY2, LOAD_URI_OPTIONS);
await waitForLoad(DUMMY2);
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await SpecialPowers.spawn(browser, [[DUMMY1, DUMMY2]], function([
dummy1,
dummy2,
@ -117,7 +117,7 @@ add_task(async function test_history() {
// Tests that load flags are passed through to the content process.
add_task(async function test_flags() {
async function checkHistory(browser, { count, index }) {
if (!SpecialPowers.getBoolPref("fission.sessionHistoryInParent")) {
if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
return SpecialPowers.spawn(browser, [[DUMMY2, count, index]], function([
dummy2,
count,

View File

@ -9,7 +9,6 @@
#include "mozilla/dom/SessionStoreUtilsBinding.h"
#include "mozilla/dom/StorageEvent.h"
#include "mozilla/dom/BrowserChild.h"
#include "mozilla/StaticPrefs_fission.h"
#include "nsGenericHTMLElement.h"
#include "nsDocShell.h"
#include "nsIAppWindow.h"
@ -20,6 +19,7 @@
#include "nsITimer.h"
#include "nsIWebProgress.h"
#include "nsIXPConnect.h"
#include "nsIXULRuntime.h"
#include "nsPresContext.h"
#include "nsPrintfCString.h"
#include "SessionStoreFunctions.h"
@ -117,13 +117,12 @@ void ContentSessionStore::ResetStorageChanges() {
}
void ContentSessionStore::SetSHistoryChanged() {
mSHistoryChanged = StaticPrefs::fission_sessionHistoryInParent_AtStartup();
mSHistoryChanged = mozilla::SessionHistoryInParent();
}
// Request "collect sessionHistory" from the parent process
void ContentSessionStore::SetSHistoryFromParentChanged() {
mSHistoryChangedFromParent =
StaticPrefs::fission_sessionHistoryInParent_AtStartup();
mSHistoryChangedFromParent = mozilla::SessionHistoryInParent();
}
void ContentSessionStore::OnDocumentStart() {
@ -137,7 +136,7 @@ void ContentSessionStore::OnDocumentStart() {
SetFullStorageNeeded();
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
mSHistoryChanged = true;
}
}
@ -146,7 +145,7 @@ void ContentSessionStore::OnDocumentEnd() {
mScrollChanged = WITH_CHANGE;
SetFullStorageNeeded();
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
mSHistoryChanged = true;
}
}
@ -227,7 +226,7 @@ nsresult TabListener::Init() {
eventTarget->AddSystemEventListener(u"mozvisualscroll"_ns, this, false);
eventTarget->AddSystemEventListener(u"input"_ns, this, false);
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
eventTarget->AddSystemEventListener(u"DOMTitleChanged"_ns, this, false);
}
@ -817,7 +816,7 @@ void TabListener::RemoveListeners() {
eventTarget->RemoveSystemEventListener(u"mozvisualscroll"_ns, this,
false);
eventTarget->RemoveSystemEventListener(u"input"_ns, this, false);
if (StaticPrefs::fission_sessionHistoryInParent_AtStartup()) {
if (mozilla::SessionHistoryInParent()) {
eventTarget->RemoveSystemEventListener(u"DOMTitleChanged"_ns, this,
false);
}

View File

@ -43,12 +43,6 @@
);
let lazyPrefs = {};
XPCOMUtils.defineLazyPreferenceGetter(
lazyPrefs,
"sessionHistoryInParent",
"fission.sessionHistoryInParent",
false
);
XPCOMUtils.defineLazyPreferenceGetter(
lazyPrefs,
"unloadTimeoutMs",
@ -1183,7 +1177,7 @@
if (
this.isRemoteBrowser &&
this.messageManager &&
!lazyPrefs.sessionHistoryInParent
!Services.appinfo.sessionHistoryInParent
) {
this._remoteWebNavigation._canGoBack = aCanGoBack;
this._remoteWebNavigation._canGoForward = aCanGoForward;
@ -1231,13 +1225,13 @@
}
purgeSessionHistory() {
if (this.isRemoteBrowser && !lazyPrefs.sessionHistoryInParent) {
if (this.isRemoteBrowser && !Services.appinfo.sessionHistoryInParent) {
this._remoteWebNavigation._canGoBack = false;
this._remoteWebNavigation._canGoForward = false;
}
try {
if (lazyPrefs.sessionHistoryInParent) {
if (Services.appinfo.sessionHistoryInParent) {
let sessionHistory = this.browsingContext?.sessionHistory;
if (!sessionHistory) {
return;
@ -1974,7 +1968,7 @@
// history, and performing the `resumeRedirectedLoad`, in order to get
// sesssion state set up correctly.
// FIXME: This probably needs to be hookable by GeckoView.
if (!lazyPrefs.sessionHistoryInParent) {
if (!Services.appinfo.sessionHistoryInParent) {
let tabbrowser = this.getTabBrowser();
if (tabbrowser) {
tabbrowser.finishBrowserRemotenessChange(this, redirectLoadSwitchId);

View File

@ -71,12 +71,6 @@ XPCOMUtils.defineLazyServiceGetter(
"@mozilla.org/uriloader/external-protocol-service;1",
"nsIExternalProtocolService"
);
XPCOMUtils.defineLazyPreferenceGetter(
this,
"sessionHistoryInParent",
"fission.sessionHistoryInParent",
false
);
function getAboutModule(aURL) {
// Needs to match NS_GetAboutModuleName
@ -1004,7 +998,7 @@ var E10SUtils = {
}
// Allow history load if loaded in this process before.
if (!sessionHistoryInParent) {
if (!Services.appinfo.sessionHistoryInParent) {
let requestedIndex = sessionHistory.legacySHistory.requestedIndex;
if (requestedIndex >= 0) {
this.log().debug("Checking history case\n");
@ -1050,7 +1044,7 @@ var E10SUtils = {
csp: aCsp ? this.serializeCSP(aCsp) : null,
};
// Retarget the load to the correct process
if (sessionHistoryInParent) {
if (Services.appinfo.sessionHistoryInParent) {
let sessionHistory = aDocShell.QueryInterface(Ci.nsIWebNavigation)
.sessionHistory;
actor.sendAsyncMessage("Browser:LoadURI", {

View File

@ -534,6 +534,12 @@ bool FissionAutostart() {
return sFissionAutostart;
}
bool SessionHistoryInParent() {
// Fission check will be enabled later.
return /*FissionAutostart() ||*/
StaticPrefs::fission_sessionHistoryInParent_AtStartup_DoNotUseDirectly();
}
} // namespace mozilla
/**
@ -867,6 +873,12 @@ nsXULAppInfo::GetFissionExperimentStatus(ExperimentStatus* aResult) {
return NS_OK;
}
NS_IMETHODIMP
nsXULAppInfo::GetSessionHistoryInParent(bool* aResult) {
*aResult = SessionHistoryInParent();
return NS_OK;
}
NS_IMETHODIMP
nsXULAppInfo::GetBrowserTabsRemoteAutostart(bool* aResult) {
*aResult = BrowserTabsRemoteAutostart();

View File

@ -22,6 +22,10 @@ uint32_t GetMaxWebProcessCount();
// environment variable MOZ_FORCE_ENABLE_FISSION, used by mach run to
// enable fission regardless of pref settings.
bool FissionAutostart();
// Returns true if fission.sessionHistoryInParent is true
// (and will return true also when FissionAutostart() is true).
bool SessionHistoryInParent();
}
%}
@ -82,6 +86,11 @@ interface nsIXULRuntime : nsISupports
*/
readonly attribute nsIXULRuntime_ExperimentStatus fissionExperimentStatus;
/**
* Whether session history is stored in the parent process.
*/
readonly attribute boolean sessionHistoryInParent;
/**
* Whether to write console errors to a log file. If a component
* encounters startup errors that might prevent the app from showing