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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2973 matching lines...) Expand 10 before | Expand all | Expand 10 after
2984 { 2984 {
2985 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache); 2985 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache);
2986 } 2986 }
2987 2987
2988 private: 2988 private:
2989 WebFrame* const m_frame; 2989 WebFrame* const m_frame;
2990 const KURL m_url; 2990 const KURL m_url;
2991 const bool m_ignoreCache; 2991 const bool m_ignoreCache;
2992 }; 2992 };
2993 2993
2994 class ClearScrollStateOnCommitWebFrameClient : public FrameTestHelpers::TestWebF rameClient {
2995 public:
2996 void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, W ebHistoryCommitType) override
2997 {
2998 frame->view()->resetScrollAndScaleState();
2999 }
3000 };
3001
2994 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) 3002 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState)
2995 { 3003 {
2996 const std::string firstURL = "200-by-300.html"; 3004 const std::string firstURL = "200-by-300.html";
2997 const std::string secondURL = "content-width-1000.html"; 3005 const std::string secondURL = "content-width-1000.html";
2998 const std::string thirdURL = "very_tall_div.html"; 3006 const std::string thirdURL = "very_tall_div.html";
2999 const float pageScaleFactor = 1.1684f; 3007 const float pageScaleFactor = 1.1684f;
3000 const int pageWidth = 120; 3008 const int pageWidth = 120;
3001 const int pageHeight = 100; 3009 const int pageHeight = 100;
3002 3010
3003 registerMockedHttpURLLoad(firstURL); 3011 registerMockedHttpURLLoad(firstURL);
3004 registerMockedHttpURLLoad(secondURL); 3012 registerMockedHttpURLLoad(secondURL);
3005 registerMockedHttpURLLoad(thirdURL); 3013 registerMockedHttpURLLoad(thirdURL);
3006 3014
3007 FrameTestHelpers::WebViewHelper webViewHelper; 3015 FrameTestHelpers::WebViewHelper webViewHelper;
3008 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true); 3016 ClearScrollStateOnCommitWebFrameClient client;
3017 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client);
3009 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight)); 3018 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight));
3010 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4)); 3019 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4));
3011 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor); 3020 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor);
3012 3021
3013 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff set(); 3022 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff set();
3014 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); 3023 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor();
3015 3024
3016 // Reload the page using the cache. 3025 // Reload the page and end up at the same url. State should be propagated.
3017 Platform::current()->currentThread()->postTask( 3026 Platform::current()->currentThread()->postTask(
3018 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + secondURL), false)); 3027 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + firstURL), false));
3019 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame()); 3028 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame());
3020 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc rollOffset().width); 3029 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc rollOffset().width);
3021 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s crollOffset().height); 3030 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s crollOffset().height);
3022 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); 3031 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor());
3023 3032
3024 // Reload the page while ignoring the cache. 3033 // Reload the page using the cache. State should not be propagated.
3034 Platform::current()->currentThread()->postTask(
3035 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + secondURL), false));
3036 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame());
3037 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width) ;
3038 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height );
3039 EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor());
3040
3041 // Reload the page while ignoring the cache. State should not be propagated.
3025 Platform::current()->currentThread()->postTask( 3042 Platform::current()->currentThread()->postTask(
3026 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + thirdURL), true)); 3043 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + thirdURL), true));
3027 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame()); 3044 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame());
3028 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc rollOffset().width); 3045 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width) ;
3029 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s crollOffset().height); 3046 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height );
3030 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); 3047 EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor());
3031 } 3048 }
3032 3049
3033 TEST_F(WebFrameTest, ReloadWhileProvisional) 3050 TEST_F(WebFrameTest, ReloadWhileProvisional)
3034 { 3051 {
3035 // Test that reloading while the previous load is still pending does not cau se the initial 3052 // Test that reloading while the previous load is still pending does not cau se the initial
3036 // request to get lost. 3053 // request to get lost.
3037 registerMockedHttpURLLoad("fixed_layout.html"); 3054 registerMockedHttpURLLoad("fixed_layout.html");
3038 3055
3039 FrameTestHelpers::WebViewHelper webViewHelper; 3056 FrameTestHelpers::WebViewHelper webViewHelper;
3040 webViewHelper.initialize(); 3057 webViewHelper.initialize();
(...skipping 4294 matching lines...) Expand 10 before | Expand all | Expand 10 after
7335 7352
7336 EXPECT_EQ(parent, firstFrame->parent()); 7353 EXPECT_EQ(parent, firstFrame->parent());
7337 EXPECT_EQ(parent, secondFrame->parent()); 7354 EXPECT_EQ(parent, secondFrame->parent());
7338 EXPECT_EQ(parent, thirdFrame->parent()); 7355 EXPECT_EQ(parent, thirdFrame->parent());
7339 EXPECT_EQ(parent, fourthFrame->parent()); 7356 EXPECT_EQ(parent, fourthFrame->parent());
7340 7357
7341 view->close(); 7358 view->close();
7342 } 7359 }
7343 7360
7344 } // namespace blink 7361 } // namespace blink
OLDNEW
« Source/core/loader/FrameLoader.cpp ('K') | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698