mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1684310 - Selecting a specific history entry from the dropdown may not cause a navigation, r=jesup
Differential Revision: https://phabricator.services.mozilla.com/D102503
This commit is contained in:
parent
6bd423b374
commit
8c3701e76e
@ -166,16 +166,6 @@ void ChildSHistory::Go(int32_t aOffset, bool aRequireUserInteraction,
|
||||
}
|
||||
}
|
||||
|
||||
if (mozilla::SessionHistoryInParent() && !mPendingEpoch) {
|
||||
mPendingEpoch = true;
|
||||
RefPtr<ChildSHistory> self(this);
|
||||
NS_DispatchToCurrentThread(
|
||||
NS_NewRunnableFunction("UpdateEpochRunnable", [self] {
|
||||
self->mHistoryEpoch++;
|
||||
self->mPendingEpoch = false;
|
||||
}));
|
||||
}
|
||||
|
||||
GotoIndex(index.value(), aOffset, aRequireUserInteraction, aRv);
|
||||
}
|
||||
|
||||
@ -204,6 +194,16 @@ void ChildSHistory::GotoIndex(int32_t aIndex, int32_t aOffset,
|
||||
("ChildSHistory::GotoIndex(%d, %d), epoch %" PRIu64, aIndex, aOffset,
|
||||
mHistoryEpoch));
|
||||
if (mozilla::SessionHistoryInParent()) {
|
||||
if (!mPendingEpoch) {
|
||||
mPendingEpoch = true;
|
||||
RefPtr<ChildSHistory> self(this);
|
||||
NS_DispatchToCurrentThread(
|
||||
NS_NewRunnableFunction("UpdateEpochRunnable", [self] {
|
||||
self->mHistoryEpoch++;
|
||||
self->mPendingEpoch = false;
|
||||
}));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISHistory> shistory = mHistory;
|
||||
mBrowsingContext->HistoryGo(
|
||||
aOffset, mHistoryEpoch, aRequireUserInteraction,
|
||||
|
42
docshell/test/navigation/file_docshell_gotoindex.html
Normal file
42
docshell/test/navigation/file_docshell_gotoindex.html
Normal file
@ -0,0 +1,42 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
function loaded() {
|
||||
if (location.search == "") {
|
||||
if (opener.loadedInitialPage) {
|
||||
opener.ok(true, "got back to the initial page.");
|
||||
opener.setTimeout("SimpleTest.finish();");
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
opener.loadedInitialPage = true;
|
||||
opener.info("Loaded initial page.");
|
||||
// Load another page (which is this same document, but different URL.)
|
||||
location.href = location.href + "?anotherPage";
|
||||
} else {
|
||||
opener.info("Loaded the second page.");
|
||||
location.hash = "1";
|
||||
window.onhashchange = function() {
|
||||
opener.info("hash: " + location.hash);
|
||||
location.hash = "2";
|
||||
window.onhashchange = function() {
|
||||
opener.info("hash: " + location.hash);
|
||||
var docShell = SpecialPowers.wrap(window).docShell;
|
||||
var webNavigation =
|
||||
SpecialPowers.do_QueryInterface(docShell, "nsIWebNavigation");
|
||||
webNavigation.gotoIndex(history.length - 2);
|
||||
window.onhashchange = function() {
|
||||
opener.info("hash: " + location.hash);
|
||||
webNavigation.gotoIndex(history.length - 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onpageshow="setTimeout(loaded)">
|
||||
<a href="#1" name="1">1</a>
|
||||
<a href="#2" name="2">2</a>
|
||||
</body>
|
||||
</html>
|
@ -79,6 +79,8 @@ skip-if = (os == "android") || fission # Bug 1560378, bug 1666449
|
||||
[test_bug1536471.html]
|
||||
support-files = file_bug1536471.html
|
||||
[test_child.html]
|
||||
[test_docshell_gotoindex.html]
|
||||
support-files = file_docshell_gotoindex.html
|
||||
[test_grandchild.html]
|
||||
[test_load_history_entry.html]
|
||||
[test_not-opener.html]
|
||||
|
29
docshell/test/navigation/test_docshell_gotoindex.html
Normal file
29
docshell/test/navigation/test_docshell_gotoindex.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Bug 1684310</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function test() {
|
||||
/*
|
||||
* This test is for nsIWebNavigation.gotoIndex.
|
||||
*
|
||||
* The test
|
||||
* - opens a new window
|
||||
* - loads a page there
|
||||
* - loads another page
|
||||
* - navigates to some fragments in the page
|
||||
* - goes back to one of the fragments
|
||||
* - tries to go back to the initial page.
|
||||
*/
|
||||
window.open("file_docshell_gotoindex.html");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="test()">
|
||||
<p id="display"></p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user