mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1909698 - Use URI from session history when coming out from bfcache. r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D222118
This commit is contained in:
parent
52ec377ade
commit
ff63578440
@ -1329,7 +1329,20 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
|
||||
mEODForCurrentDocument = false;
|
||||
mIsRestoringDocument = true;
|
||||
mLoadGroup->AddRequest(channel, nullptr);
|
||||
SetCurrentURI(doc->GetDocumentURI(), channel,
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
if (doc->FragmentDirective()) {
|
||||
// If we have fragment directives, then we've mutated the document
|
||||
// uri. Set the current URI from session history instead.
|
||||
if (mozilla::SessionHistoryInParent()) {
|
||||
uri = mActiveEntry ? mActiveEntry->GetURI() : nullptr;
|
||||
} else if (mOSHE) {
|
||||
uri = mOSHE->GetURI();
|
||||
}
|
||||
}
|
||||
if (!uri) {
|
||||
uri = doc->GetDocumentURI();
|
||||
}
|
||||
SetCurrentURI(uri, channel,
|
||||
/* aFireOnLocationChange */ true,
|
||||
/* aIsInitialAboutBlank */ false,
|
||||
/* aLocationFlags */ 0);
|
||||
|
@ -78,6 +78,8 @@ support-files = [
|
||||
"file_backforward_restore_scroll.html^headers^",
|
||||
]
|
||||
|
||||
["browser_backforward_text_fragment_restore_urlbar.js"]
|
||||
|
||||
["browser_backforward_userinteraction.js"]
|
||||
support-files = ["dummy_iframe_page.html"]
|
||||
skip-if = ["os == 'linux' && bits == 64 && !debug"] # Bug 1607713
|
||||
|
@ -0,0 +1,33 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const ROOT = getRootDirectory(gTestPath).replace(
|
||||
"chrome://mochitests/content",
|
||||
"http://mochi.test:8888"
|
||||
);
|
||||
|
||||
const URL = `${ROOT}/dummy_page.html#:~:text=dummy`;
|
||||
|
||||
function waitForPageShow(browser) {
|
||||
return BrowserTestUtils.waitForContentEvent(browser, "pageshow", true);
|
||||
}
|
||||
|
||||
add_task(async function test_fragment_restore_urlbar() {
|
||||
await BrowserTestUtils.withNewTab("https://example.com", async browser => {
|
||||
let loaded = BrowserTestUtils.browserLoaded(browser, false);
|
||||
BrowserTestUtils.startLoadingURIString(browser, URL);
|
||||
await loaded;
|
||||
|
||||
// Go back in history.
|
||||
let change = waitForPageShow(browser);
|
||||
browser.goBack();
|
||||
await change;
|
||||
change = waitForPageShow(browser);
|
||||
// Go forward in history.
|
||||
browser.goForward();
|
||||
await change;
|
||||
is(gURLBar.inputField.value, URL, "URL should have text directive");
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user