Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1404)

Unified Diff: Source/web/tests/WebFrameTest.cpp

Issue 1159723003: Don't reuse HistoryItems for multiple navigations (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index 8fb12ccf6801050fdfda693a3160fbb0b3e3f54c..eadda1a2c2eb79f7955ef3d144a7878beffe0f02 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -3057,6 +3057,14 @@ private:
const bool m_ignoreCache;
};
+class ClearScrollStateOnCommitWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
+public:
+ void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, WebHistoryCommitType) override
+ {
+ frame->view()->resetScrollAndScaleState();
+ }
+};
+
TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState)
{
const std::string firstURL = "200-by-300.html";
@@ -3071,7 +3079,8 @@ TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState)
registerMockedHttpURLLoad(thirdURL);
FrameTestHelpers::WebViewHelper webViewHelper;
- webViewHelper.initializeAndLoad(m_baseURL + firstURL, true);
+ ClearScrollStateOnCommitWebFrameClient client;
+ webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client);
webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight));
webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4));
webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor);
@@ -3079,21 +3088,29 @@ TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState)
WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOffset();
float previousScale = webViewHelper.webViewImpl()->pageScaleFactor();
- // Reload the page using the cache.
+ // Reload the page and end up at the same url. State should be propagated.
Platform::current()->currentThread()->postTask(
- FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(), toKURL(m_baseURL + secondURL), false));
+ FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(), toKURL(m_baseURL + firstURL), false));
FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->mainFrame());
EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width);
EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height);
EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor());
- // Reload the page while ignoring the cache.
+ // Reload the page using the cache. State should not be propagated.
+ Platform::current()->currentThread()->postTask(
+ FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(), toKURL(m_baseURL + secondURL), false));
+ FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->mainFrame());
+ EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width);
+ EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height);
+ EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor());
+
+ // Reload the page while ignoring the cache. State should not be propagated.
Platform::current()->currentThread()->postTask(
FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->mainFrame(), toKURL(m_baseURL + thirdURL), true));
FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->mainFrame());
- EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width);
- EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height);
- EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor());
+ EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width);
+ EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height);
+ EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor());
}
TEST_P(ParametrizedWebFrameTest, ReloadWhileProvisional)
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698