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

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: Address comments 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 3013 matching lines...) Expand 10 before | Expand all | Expand 10 after
3024 { 3024 {
3025 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache); 3025 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache);
3026 } 3026 }
3027 3027
3028 private: 3028 private:
3029 WebFrame* const m_frame; 3029 WebFrame* const m_frame;
3030 const KURL m_url; 3030 const KURL m_url;
3031 const bool m_ignoreCache; 3031 const bool m_ignoreCache;
3032 }; 3032 };
3033 3033
3034 class ClearScrollStateOnCommitWebFrameClient : public FrameTestHelpers::TestWebF rameClient {
3035 public:
3036 void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, W ebHistoryCommitType) override
3037 {
3038 frame->view()->resetScrollAndScaleState();
3039 }
3040 };
3041
3034 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) 3042 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState)
3035 { 3043 {
3036 const std::string firstURL = "200-by-300.html"; 3044 const std::string firstURL = "200-by-300.html";
3037 const std::string secondURL = "content-width-1000.html"; 3045 const std::string secondURL = "content-width-1000.html";
3038 const std::string thirdURL = "very_tall_div.html"; 3046 const std::string thirdURL = "very_tall_div.html";
3039 const float pageScaleFactor = 1.1684f; 3047 const float pageScaleFactor = 1.1684f;
3040 const int pageWidth = 120; 3048 const int pageWidth = 120;
3041 const int pageHeight = 100; 3049 const int pageHeight = 100;
3042 3050
3043 registerMockedHttpURLLoad(firstURL); 3051 registerMockedHttpURLLoad(firstURL);
3044 registerMockedHttpURLLoad(secondURL); 3052 registerMockedHttpURLLoad(secondURL);
3045 registerMockedHttpURLLoad(thirdURL); 3053 registerMockedHttpURLLoad(thirdURL);
3046 3054
3047 FrameTestHelpers::WebViewHelper webViewHelper; 3055 FrameTestHelpers::WebViewHelper webViewHelper;
3048 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true); 3056 ClearScrollStateOnCommitWebFrameClient client;
3057 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client);
3049 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight)); 3058 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight));
3050 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4)); 3059 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth / 4, pageHeight / 4));
3051 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor); 3060 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor);
3052 3061
3053 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff set(); 3062 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff set();
3054 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); 3063 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor();
3055 3064
3056 // Reload the page using the cache. 3065 // Reload the page and end up at the same url. State should be propagated.
3057 Platform::current()->currentThread()->postTask( 3066 Platform::current()->currentThread()->postTask(
3058 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + secondURL), false)); 3067 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + firstURL), false));
3059 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame()); 3068 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame());
3060 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc rollOffset().width); 3069 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc rollOffset().width);
3061 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s crollOffset().height); 3070 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s crollOffset().height);
3062 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); 3071 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor());
3063 3072
3064 // Reload the page while ignoring the cache. 3073 // Reload the page using the cache. State should not be propagated.
3074 Platform::current()->currentThread()->postTask(
3075 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + secondURL), false));
3076 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame());
3077 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width) ;
3078 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height );
3079 EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor());
3080
3081 // Reload the page while ignoring the cache. State should not be propagated.
3065 Platform::current()->currentThread()->postTask( 3082 Platform::current()->currentThread()->postTask(
3066 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + thirdURL), true)); 3083 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma inFrame(), toKURL(m_baseURL + thirdURL), true));
3067 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame()); 3084 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m ainFrame());
3068 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc rollOffset().width); 3085 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width) ;
3069 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s crollOffset().height); 3086 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height );
3070 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); 3087 EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor());
3071 } 3088 }
3072 3089
3073 TEST_P(ParametrizedWebFrameTest, ReloadWhileProvisional) 3090 TEST_P(ParametrizedWebFrameTest, ReloadWhileProvisional)
3074 { 3091 {
3075 // Test that reloading while the previous load is still pending does not cau se the initial 3092 // Test that reloading while the previous load is still pending does not cau se the initial
3076 // request to get lost. 3093 // request to get lost.
3077 registerMockedHttpURLLoad("fixed_layout.html"); 3094 registerMockedHttpURLLoad("fixed_layout.html");
3078 3095
3079 FrameTestHelpers::WebViewHelper webViewHelper(this); 3096 FrameTestHelpers::WebViewHelper webViewHelper(this);
3080 webViewHelper.initialize(); 3097 webViewHelper.initialize();
(...skipping 4324 matching lines...) Expand 10 before | Expand all | Expand 10 after
7405 7422
7406 EXPECT_EQ(parent, firstFrame->parent()); 7423 EXPECT_EQ(parent, firstFrame->parent());
7407 EXPECT_EQ(parent, secondFrame->parent()); 7424 EXPECT_EQ(parent, secondFrame->parent());
7408 EXPECT_EQ(parent, thirdFrame->parent()); 7425 EXPECT_EQ(parent, thirdFrame->parent());
7409 EXPECT_EQ(parent, fourthFrame->parent()); 7426 EXPECT_EQ(parent, fourthFrame->parent());
7410 7427
7411 view->close(); 7428 view->close();
7412 } 7429 }
7413 7430
7414 } // namespace blink 7431 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698