зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1917369 - Track user interaction state in docshell's active entry. r=dom-core,peterv
Differential Revision: https://phabricator.services.mozilla.com/D221389
This commit is contained in:
Родитель
150d59da52
Коммит
fbac3f82fa
|
@ -1225,6 +1225,14 @@ void CanonicalBrowsingContext::SetActiveSessionHistoryEntry(
|
|||
mActiveEntry->SharedInfo()->mCacheKey = aUpdatedCacheKey;
|
||||
}
|
||||
|
||||
if (oldActiveEntry) {
|
||||
// aInfo comes from the entry stored in the current document's docshell,
|
||||
// whose interaction state does not get updated. So we instead propagate
|
||||
// state from the previous canonical entry. See bug 1917369.
|
||||
mActiveEntry->SetHasUserInteraction(
|
||||
oldActiveEntry->GetHasUserInteraction());
|
||||
}
|
||||
|
||||
if (IsTop()) {
|
||||
Maybe<int32_t> previousEntryIndex, loadedEntryIndex;
|
||||
shistory->AddToRootSessionHistory(
|
||||
|
@ -1258,7 +1266,12 @@ void CanonicalBrowsingContext::ReplaceActiveSessionHistoryEntry(
|
|||
return;
|
||||
}
|
||||
|
||||
// aInfo comes from the entry stored in the current document's docshell, whose
|
||||
// interaction state does not get updated. So we instead propagate state from
|
||||
// the previous canonical entry. See bug 1917369.
|
||||
const bool hasUserInteraction = mActiveEntry->GetHasUserInteraction();
|
||||
mActiveEntry->SetInfo(aInfo);
|
||||
mActiveEntry->SetHasUserInteraction(hasUserInteraction);
|
||||
// Notify children of the update
|
||||
nsSHistory* shistory = static_cast<nsSHistory*>(GetSessionHistory());
|
||||
if (shistory) {
|
||||
|
|
|
@ -52,7 +52,6 @@ SessionHistoryInfo::SessionHistoryInfo(nsDocShellLoadState* aLoadState,
|
|||
: Some(aLoadState->SrcdocData())),
|
||||
mBaseURI(aLoadState->BaseURI()),
|
||||
mLoadReplace(aLoadState->LoadReplace()),
|
||||
mHasUserInteraction(aLoadState->HasValidUserGestureActivation()),
|
||||
mHasUserActivation(aLoadState->HasValidUserGestureActivation()),
|
||||
mSharedState(SharedState::Create(
|
||||
aLoadState->TriggeringPrincipal(), aLoadState->PrincipalToInherit(),
|
||||
|
|
|
@ -978,6 +978,10 @@ static void LogEntry(nsISHEntry* aEntry, int32_t aIndex, int32_t aTotal,
|
|||
gSHLog, LogLevel::Debug,
|
||||
(" %s%s Is in BFCache = %s\n", prefix.get(), childCount > 0 ? "|" : " ",
|
||||
aEntry->GetIsInBFCache() ? "true" : "false"));
|
||||
MOZ_LOG(gSHLog, LogLevel::Debug,
|
||||
(" %s%s Has User Interaction = %s\n", prefix.get(),
|
||||
childCount > 0 ? "|" : " ",
|
||||
aEntry->GetHasUserInteraction() ? "true" : "false"));
|
||||
|
||||
nsCOMPtr<nsISHEntry> prevChild;
|
||||
for (int32_t i = 0; i < childCount; ++i) {
|
||||
|
|
|
@ -310,6 +310,9 @@ support-files = ["overlink_test.html"]
|
|||
["browser_replace_state_during_navigation.js"]
|
||||
support-files = ["file_replace_state_during_navigation.html"]
|
||||
|
||||
["browser_replace_state_during_navigation_from_first_page.js"]
|
||||
support-files = ["file_replace_state_during_navigation.html"]
|
||||
|
||||
["browser_search_notification.js"]
|
||||
|
||||
["browser_tab_replace_while_loading.js"]
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
"use strict";
|
||||
|
||||
const TEST_URI =
|
||||
getRootDirectory(gTestPath).replace(
|
||||
"chrome://mochitests/content",
|
||||
"https://example.com"
|
||||
) + "file_replace_state_during_navigation.html";
|
||||
|
||||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.navigation.requireUserInteraction", true]],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async () => {
|
||||
await BrowserTestUtils.withNewTab(TEST_URI, async browser => {
|
||||
// Add user interaction to the first page.
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter("body", {}, browser);
|
||||
|
||||
// Navigate, causing a hashchange event to fire and call history.replaceState
|
||||
await BrowserTestUtils.synthesizeMouseAtCenter("#link", {}, browser);
|
||||
|
||||
await assertMenulist([TEST_URI + "#1", TEST_URI + "#inject", TEST_URI]);
|
||||
});
|
||||
});
|
Загрузка…
Ссылка в новой задаче