From fb35bc42f0feff099f5c45cbb8546477fac8642f Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Wed, 6 Jan 2016 04:03:42 +0200 Subject: [PATCH] Bug 1237075 - Navigating from 'manual' to 'auto' session history entry should scroll the page, r=jst --HG-- extra : rebase_source : c6d901084edf1b17e21c44515a0483c7fbcc77dd --- docshell/base/nsDocShell.cpp | 5 +++++ docshell/test/navigation/file_scrollRestoration.html | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 09ca13ffe77b..00554985b4bb 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -10072,6 +10072,11 @@ nsDocShell::InternalLoad(nsIURI* aURI, } } + // If we're doing a history load, use its scroll restoration state. + if (aSHEntry) { + aSHEntry->GetScrollRestorationIsManual(&scrollRestorationIsManual); + } + /* Assign mOSHE to mLSHE. This will either be a new entry created * by OnNewURI() for normal loads or aSHEntry for history loads. */ diff --git a/docshell/test/navigation/file_scrollRestoration.html b/docshell/test/navigation/file_scrollRestoration.html index 203394adaae7..5450c27246a0 100644 --- a/docshell/test/navigation/file_scrollRestoration.html +++ b/docshell/test/navigation/file_scrollRestoration.html @@ -82,6 +82,15 @@ opener.is(window.scrollY, 0, "Shouldn't have scrolled back to the state3's position"); opener.is(history.state.state, "state3", "Unexpected state."); + history.pushState({ state: "state5" }, "state5"); + history.scrollRestoration = "auto"; + document.getElementById("bottom").scrollIntoView(); + opener.isnot(window.scrollY, 0, "Should have scrolled to 'bottom'."); + history.back(); + window.scrollTo(0, 0); + history.forward(); + opener.isnot(window.scrollY, 0, "Should have scrolled back to the state5's position"); + var ifr = document.createElement("iframe"); ifr.src = "data:text/html,"; document.body.appendChild(ifr);