| OLD | NEW |
| 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 3039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3050 { | 3050 { |
| 3051 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache); | 3051 m_frame->reloadWithOverrideURL(m_url, m_ignoreCache); |
| 3052 } | 3052 } |
| 3053 | 3053 |
| 3054 private: | 3054 private: |
| 3055 WebFrame* const m_frame; | 3055 WebFrame* const m_frame; |
| 3056 const KURL m_url; | 3056 const KURL m_url; |
| 3057 const bool m_ignoreCache; | 3057 const bool m_ignoreCache; |
| 3058 }; | 3058 }; |
| 3059 | 3059 |
| 3060 class ClearScrollStateOnCommitWebFrameClient : public FrameTestHelpers::TestWebF
rameClient { |
| 3061 public: |
| 3062 void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistoryItem&, W
ebHistoryCommitType) override |
| 3063 { |
| 3064 frame->view()->resetScrollAndScaleState(); |
| 3065 } |
| 3066 }; |
| 3067 |
| 3060 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) | 3068 TEST_F(WebFrameTest, ReloadWithOverrideURLPreservesState) |
| 3061 { | 3069 { |
| 3062 const std::string firstURL = "200-by-300.html"; | 3070 const std::string firstURL = "200-by-300.html"; |
| 3063 const std::string secondURL = "content-width-1000.html"; | 3071 const std::string secondURL = "content-width-1000.html"; |
| 3064 const std::string thirdURL = "very_tall_div.html"; | 3072 const std::string thirdURL = "very_tall_div.html"; |
| 3065 const float pageScaleFactor = 1.1684f; | 3073 const float pageScaleFactor = 1.1684f; |
| 3066 const int pageWidth = 120; | 3074 const int pageWidth = 120; |
| 3067 const int pageHeight = 100; | 3075 const int pageHeight = 100; |
| 3068 | 3076 |
| 3069 registerMockedHttpURLLoad(firstURL); | 3077 registerMockedHttpURLLoad(firstURL); |
| 3070 registerMockedHttpURLLoad(secondURL); | 3078 registerMockedHttpURLLoad(secondURL); |
| 3071 registerMockedHttpURLLoad(thirdURL); | 3079 registerMockedHttpURLLoad(thirdURL); |
| 3072 | 3080 |
| 3073 FrameTestHelpers::WebViewHelper webViewHelper; | 3081 FrameTestHelpers::WebViewHelper webViewHelper; |
| 3074 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true); | 3082 ClearScrollStateOnCommitWebFrameClient client; |
| 3083 webViewHelper.initializeAndLoad(m_baseURL + firstURL, true, &client); |
| 3075 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight)); | 3084 webViewHelper.webViewImpl()->resize(WebSize(pageWidth, pageHeight)); |
| 3076 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth
/ 4, pageHeight / 4)); | 3085 webViewHelper.webViewImpl()->mainFrame()->setScrollOffset(WebSize(pageWidth
/ 4, pageHeight / 4)); |
| 3077 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor); | 3086 webViewHelper.webViewImpl()->setPageScaleFactor(pageScaleFactor); |
| 3078 | 3087 |
| 3079 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff
set(); | 3088 WebSize previousOffset = webViewHelper.webViewImpl()->mainFrame()->scrollOff
set(); |
| 3080 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); | 3089 float previousScale = webViewHelper.webViewImpl()->pageScaleFactor(); |
| 3081 | 3090 |
| 3082 // Reload the page using the cache. | 3091 // Reload the page and end up at the same url. State should be propagated. |
| 3083 Platform::current()->currentThread()->postTask( | 3092 Platform::current()->currentThread()->postTask( |
| 3084 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma
inFrame(), toKURL(m_baseURL + secondURL), false)); | 3093 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma
inFrame(), toKURL(m_baseURL + firstURL), false)); |
| 3085 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m
ainFrame()); | 3094 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m
ainFrame()); |
| 3086 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc
rollOffset().width); | 3095 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc
rollOffset().width); |
| 3087 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s
crollOffset().height); | 3096 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s
crollOffset().height); |
| 3088 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); | 3097 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); |
| 3089 | 3098 |
| 3090 // Reload the page while ignoring the cache. | 3099 // Reload the page using the cache. State should not be propagated. |
| 3100 Platform::current()->currentThread()->postTask( |
| 3101 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma
inFrame(), toKURL(m_baseURL + secondURL), false)); |
| 3102 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m
ainFrame()); |
| 3103 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width)
; |
| 3104 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height
); |
| 3105 EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor()); |
| 3106 |
| 3107 // Reload the page while ignoring the cache. State should not be propagated. |
| 3091 Platform::current()->currentThread()->postTask( | 3108 Platform::current()->currentThread()->postTask( |
| 3092 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma
inFrame(), toKURL(m_baseURL + thirdURL), true)); | 3109 FROM_HERE, new ReloadWithOverrideURLTask(webViewHelper.webViewImpl()->ma
inFrame(), toKURL(m_baseURL + thirdURL), true)); |
| 3093 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m
ainFrame()); | 3110 FrameTestHelpers::pumpPendingRequestsDoNotUse(webViewHelper.webViewImpl()->m
ainFrame()); |
| 3094 EXPECT_EQ(previousOffset.width, webViewHelper.webViewImpl()->mainFrame()->sc
rollOffset().width); | 3111 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().width)
; |
| 3095 EXPECT_EQ(previousOffset.height, webViewHelper.webViewImpl()->mainFrame()->s
crollOffset().height); | 3112 EXPECT_EQ(0, webViewHelper.webViewImpl()->mainFrame()->scrollOffset().height
); |
| 3096 EXPECT_EQ(previousScale, webViewHelper.webViewImpl()->pageScaleFactor()); | 3113 EXPECT_EQ(1.0f, webViewHelper.webViewImpl()->pageScaleFactor()); |
| 3097 } | 3114 } |
| 3098 | 3115 |
| 3099 TEST_P(ParametrizedWebFrameTest, ReloadWhileProvisional) | 3116 TEST_P(ParametrizedWebFrameTest, ReloadWhileProvisional) |
| 3100 { | 3117 { |
| 3101 // Test that reloading while the previous load is still pending does not cau
se the initial | 3118 // Test that reloading while the previous load is still pending does not cau
se the initial |
| 3102 // request to get lost. | 3119 // request to get lost. |
| 3103 registerMockedHttpURLLoad("fixed_layout.html"); | 3120 registerMockedHttpURLLoad("fixed_layout.html"); |
| 3104 | 3121 |
| 3105 FrameTestHelpers::WebViewHelper webViewHelper(this); | 3122 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 3106 webViewHelper.initialize(); | 3123 webViewHelper.initialize(); |
| (...skipping 4324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7431 | 7448 |
| 7432 EXPECT_EQ(parent, firstFrame->parent()); | 7449 EXPECT_EQ(parent, firstFrame->parent()); |
| 7433 EXPECT_EQ(parent, secondFrame->parent()); | 7450 EXPECT_EQ(parent, secondFrame->parent()); |
| 7434 EXPECT_EQ(parent, thirdFrame->parent()); | 7451 EXPECT_EQ(parent, thirdFrame->parent()); |
| 7435 EXPECT_EQ(parent, fourthFrame->parent()); | 7452 EXPECT_EQ(parent, fourthFrame->parent()); |
| 7436 | 7453 |
| 7437 view->close(); | 7454 view->close(); |
| 7438 } | 7455 } |
| 7439 | 7456 |
| 7440 } // namespace blink | 7457 } // namespace blink |
| OLD | NEW |