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

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: Address comments Created 5 years, 7 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
Index: Source/web/tests/WebFrameTest.cpp
diff --git a/Source/web/tests/WebFrameTest.cpp b/Source/web/tests/WebFrameTest.cpp
index 592b348d5827a214bbc3bb0be0ed1a7d82ad6f85..2c6efc1fb7ff59cd6e557f16c04e67267d96ca41 100644
--- a/Source/web/tests/WebFrameTest.cpp
+++ b/Source/web/tests/WebFrameTest.cpp
@@ -3031,6 +3031,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";
@@ -3045,7 +3053,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);
@@ -3053,21 +3062,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)

Powered by Google App Engine
This is Rietveld 408576698