Bug 1648825 - Add nsISHEntry::hasUserActivation r=ckerschb,smaug

Differential Revision: https://phabricator.services.mozilla.com/D113818
This commit is contained in:
Niklas Goegge
2021-05-20 11:06:10 +00:00
parent 139e5d1650
commit 3d3d245333
6 changed files with 60 additions and 8 deletions

View File

@@ -11659,6 +11659,8 @@ nsresult nsDocShell::AddToSessionHistory(
bool expired = false; // by default the page is not expired
bool discardLayoutState = false;
nsCOMPtr<nsICacheInfoChannel> cacheChannel;
bool userActivation = false;
if (aChannel) {
cacheChannel = do_QueryInterface(aChannel);
@@ -11699,6 +11701,8 @@ nsresult nsDocShell::AddToSessionHistory(
loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
userActivation = loadInfo->GetHasValidUserGestureActivation();
// For now keep storing just the principal in the SHEntry.
if (!principalToInherit) {
if (loadInfo->GetLoadingSandboxed()) {
@@ -11767,7 +11771,7 @@ nsresult nsDocShell::AddToSessionHistory(
principalToInherit, partitionedPrincipalToInherit, csp,
HistoryID(), GetCreatedDynamically(), originalURI,
resultPrincipalURI, loadReplace, referrerInfo, srcdoc,
srcdocEntry, baseURI, saveLayoutState, expired);
srcdocEntry, baseURI, saveLayoutState, expired, userActivation);
if (mBrowsingContext->IsTop() && GetSessionHistory()) {
bool shouldPersist = ShouldAddToSessionHistory(aURI, aChannel);
@@ -11880,7 +11884,8 @@ nsresult nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType,
// in case.
nsCOMPtr<nsISHEntry> kungFuDeathGrip(aEntry);
loadState->SetHasValidUserGestureActivation(aUserActivation);
loadState->SetHasValidUserGestureActivation(
loadState->HasValidUserGestureActivation() || aUserActivation);
return LoadHistoryEntry(loadState, aLoadType, aEntry == mOSHE);
}
@@ -11889,7 +11894,8 @@ nsresult nsDocShell::LoadHistoryEntry(const LoadingSessionHistoryInfo& aEntry,
uint32_t aLoadType,
bool aUserActivation) {
RefPtr<nsDocShellLoadState> loadState = aEntry.CreateLoadInfo();
loadState->SetHasValidUserGestureActivation(aUserActivation);
loadState->SetHasValidUserGestureActivation(
loadState->HasValidUserGestureActivation() || aUserActivation);
return LoadHistoryEntry(loadState, aLoadType,
aEntry.mLoadingCurrentActiveEntry);