mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1769189, ensure history state is updated if beforeunload listener calls replaceState, r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D152170
This commit is contained in:
parent
d50a36b7e8
commit
b989d9a4ca
@ -572,6 +572,12 @@ CanonicalBrowsingContext::CreateLoadingSessionHistoryEntryForLoad(
|
||||
if (!entry) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// If the entry was updated, update also the LoadingSessionHistoryInfo.
|
||||
UniquePtr<LoadingSessionHistoryInfo> lshi =
|
||||
MakeUnique<LoadingSessionHistoryInfo>(entry, existingLoadingInfo);
|
||||
aLoadState->SetLoadingSessionHistoryInfo(std::move(lshi));
|
||||
existingLoadingInfo = aLoadState->GetLoadingSessionHistoryInfo();
|
||||
Unused << SetHistoryEntryCount(entry->BCHistoryLength());
|
||||
} else if (aLoadState->LoadType() == LOAD_REFRESH &&
|
||||
!ShouldAddEntryForRefresh(aLoadState->URI(),
|
||||
|
@ -385,7 +385,7 @@ LoadingSessionHistoryInfo::LoadingSessionHistoryInfo(
|
||||
}
|
||||
|
||||
LoadingSessionHistoryInfo::LoadingSessionHistoryInfo(
|
||||
SessionHistoryEntry* aEntry, LoadingSessionHistoryInfo* aInfo)
|
||||
SessionHistoryEntry* aEntry, const LoadingSessionHistoryInfo* aInfo)
|
||||
: mInfo(aEntry->Info()),
|
||||
mLoadId(aInfo->mLoadId),
|
||||
mLoadIsFromSessionHistory(aInfo->mLoadIsFromSessionHistory),
|
||||
|
@ -222,7 +222,7 @@ struct LoadingSessionHistoryInfo {
|
||||
explicit LoadingSessionHistoryInfo(SessionHistoryEntry* aEntry);
|
||||
// Initializes mInfo using aEntry and otherwise copies the values from aInfo.
|
||||
LoadingSessionHistoryInfo(SessionHistoryEntry* aEntry,
|
||||
LoadingSessionHistoryInfo* aInfo);
|
||||
const LoadingSessionHistoryInfo* aInfo);
|
||||
// For about:blank only.
|
||||
explicit LoadingSessionHistoryInfo(const SessionHistoryInfo& aInfo);
|
||||
|
||||
|
@ -111,6 +111,7 @@ https_first_disabled = true
|
||||
skip-if = !fission || !crashreporter # On a crash we only keep history when fission is enabled.
|
||||
[browser_bug1719178.js]
|
||||
[browser_bug1757005.js]
|
||||
[browser_bug1769189.js]
|
||||
[browser_bug234628-1.js]
|
||||
[browser_bug234628-10.js]
|
||||
[browser_bug234628-11.js]
|
||||
|
33
docshell/test/browser/browser_bug1769189.js
Normal file
33
docshell/test/browser/browser_bug1769189.js
Normal file
@ -0,0 +1,33 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_beforeUnload_and_replaceState() {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{
|
||||
gBrowser,
|
||||
url:
|
||||
"data:text/html,<script>window.addEventListener('beforeunload', () => { window.history.replaceState(true, ''); });</script>",
|
||||
},
|
||||
async function(browser) {
|
||||
let initialState = await SpecialPowers.spawn(browser, [], () => {
|
||||
return content.history.state;
|
||||
});
|
||||
|
||||
is(initialState, null, "history.state should be initially null.");
|
||||
|
||||
let awaitPageShow = BrowserTestUtils.waitForContentEvent(
|
||||
browser,
|
||||
"pageshow"
|
||||
);
|
||||
BrowserReload();
|
||||
await awaitPageShow;
|
||||
|
||||
let updatedState = await SpecialPowers.spawn(browser, [], () => {
|
||||
return content.history.state;
|
||||
});
|
||||
is(updatedState, true, "history.state should have been updated.");
|
||||
}
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue
Block a user