| 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 4071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4082 registerMockedHttpURLLoad("form.html"); | 4082 registerMockedHttpURLLoad("form.html"); |
| 4083 | 4083 |
| 4084 TestReloadDoesntRedirectWebFrameClient webFrameClient; | 4084 TestReloadDoesntRedirectWebFrameClient webFrameClient; |
| 4085 FrameTestHelpers::WebViewHelper webViewHelper; | 4085 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4086 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, | 4086 webViewHelper.initializeAndLoad(m_baseURL + "form.html", false, |
| 4087 &webFrameClient); | 4087 &webFrameClient); |
| 4088 | 4088 |
| 4089 webViewHelper.webView()->mainFrame()->reload( | 4089 webViewHelper.webView()->mainFrame()->reload( |
| 4090 WebFrameLoadType::ReloadBypassingCache); | 4090 WebFrameLoadType::ReloadBypassingCache); |
| 4091 // start another reload before request is delivered. | 4091 // start another reload before request is delivered. |
| 4092 FrameTestHelpers::reloadFrameIgnoringCache( | 4092 FrameTestHelpers::reloadFrameBypassingCache( |
| 4093 webViewHelper.webView()->mainFrame()); | 4093 webViewHelper.webView()->mainFrame()); |
| 4094 } | 4094 } |
| 4095 | 4095 |
| 4096 class ClearScrollStateOnCommitWebFrameClient | 4096 class ClearScrollStateOnCommitWebFrameClient |
| 4097 : public FrameTestHelpers::TestWebFrameClient { | 4097 : public FrameTestHelpers::TestWebFrameClient { |
| 4098 public: | 4098 public: |
| 4099 void didCommitProvisionalLoad(WebLocalFrame* frame, | 4099 void didCommitProvisionalLoad(WebLocalFrame* frame, |
| 4100 const WebHistoryItem&, | 4100 const WebHistoryItem&, |
| 4101 WebHistoryCommitType) override { | 4101 WebHistoryCommitType) override { |
| 4102 frame->view()->resetScrollAndScaleState(); | 4102 frame->view()->resetScrollAndScaleState(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4140 | 4140 |
| 4141 // Reload the page using the cache. State should not be propagated. | 4141 // Reload the page using the cache. State should not be propagated. |
| 4142 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( | 4142 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( |
| 4143 toKURL(m_baseURL + secondURL), WebFrameLoadType::Reload); | 4143 toKURL(m_baseURL + secondURL), WebFrameLoadType::Reload); |
| 4144 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 4144 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
| 4145 webViewHelper.webView()->mainFrame()); | 4145 webViewHelper.webView()->mainFrame()); |
| 4146 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().width); | 4146 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().width); |
| 4147 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().height); | 4147 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().height); |
| 4148 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 4148 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
| 4149 | 4149 |
| 4150 // Reload the page while ignoring the cache. State should not be propagated. | 4150 // Reload the page while bypassing the cache. State should not be propagated. |
| 4151 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( | 4151 webViewHelper.webView()->mainFrame()->reloadWithOverrideURL( |
| 4152 toKURL(m_baseURL + thirdURL), WebFrameLoadType::ReloadBypassingCache); | 4152 toKURL(m_baseURL + thirdURL), WebFrameLoadType::ReloadBypassingCache); |
| 4153 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( | 4153 FrameTestHelpers::pumpPendingRequestsForFrameToLoad( |
| 4154 webViewHelper.webView()->mainFrame()); | 4154 webViewHelper.webView()->mainFrame()); |
| 4155 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().width); | 4155 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().width); |
| 4156 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().height); | 4156 EXPECT_EQ(0, webViewHelper.webView()->mainFrame()->getScrollOffset().height); |
| 4157 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); | 4157 EXPECT_EQ(1.0f, webViewHelper.webView()->pageScaleFactor()); |
| 4158 } | 4158 } |
| 4159 | 4159 |
| 4160 TEST_P(ParameterizedWebFrameTest, ReloadWhileProvisional) { | 4160 TEST_P(ParameterizedWebFrameTest, ReloadWhileProvisional) { |
| 4161 // Test that reloading while the previous load is still pending does not cause | 4161 // Test that reloading while the previous load is still pending does not cause |
| 4162 // the initial request to get lost. | 4162 // the initial request to get lost. |
| 4163 registerMockedHttpURLLoad("fixed_layout.html"); | 4163 registerMockedHttpURLLoad("fixed_layout.html"); |
| 4164 | 4164 |
| 4165 FrameTestHelpers::WebViewHelper webViewHelper; | 4165 FrameTestHelpers::WebViewHelper webViewHelper; |
| 4166 webViewHelper.initialize(); | 4166 webViewHelper.initialize(); |
| 4167 WebURLRequest request(toKURL(m_baseURL + "fixed_layout.html")); | 4167 WebURLRequest request(toKURL(m_baseURL + "fixed_layout.html")); |
| 4168 webViewHelper.webView()->mainFrame()->loadRequest(request); | 4168 webViewHelper.webView()->mainFrame()->loadRequest(request); |
| 4169 // start reload before first request is delivered. | 4169 // start reload before first request is delivered. |
| 4170 FrameTestHelpers::reloadFrameIgnoringCache( | 4170 FrameTestHelpers::reloadFrameBypassingCache( |
| 4171 webViewHelper.webView()->mainFrame()); | 4171 webViewHelper.webView()->mainFrame()); |
| 4172 | 4172 |
| 4173 WebDataSource* dataSource = | 4173 WebDataSource* dataSource = |
| 4174 webViewHelper.webView()->mainFrame()->dataSource(); | 4174 webViewHelper.webView()->mainFrame()->dataSource(); |
| 4175 ASSERT_TRUE(dataSource); | 4175 ASSERT_TRUE(dataSource); |
| 4176 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), | 4176 EXPECT_EQ(toKURL(m_baseURL + "fixed_layout.html"), |
| 4177 KURL(dataSource->request().url())); | 4177 KURL(dataSource->request().url())); |
| 4178 } | 4178 } |
| 4179 | 4179 |
| 4180 TEST_P(ParameterizedWebFrameTest, AppendRedirects) { | 4180 TEST_P(ParameterizedWebFrameTest, AppendRedirects) { |
| (...skipping 2900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7081 FrameTestHelpers::reloadFrame(mainFrame); | 7081 FrameTestHelpers::reloadFrame(mainFrame); |
| 7082 | 7082 |
| 7083 // A new WebFrame should have been created, but the child WebFrameClient | 7083 // A new WebFrame should have been created, but the child WebFrameClient |
| 7084 // should be reused. | 7084 // should be reused. |
| 7085 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); | 7085 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); |
| 7086 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), | 7086 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), |
| 7087 &childClient); | 7087 &childClient); |
| 7088 | 7088 |
| 7089 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); | 7089 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); |
| 7090 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); | 7090 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); |
| 7091 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::ValidatingCacheData); | 7091 |
| 7092 // Sub-frames should not be forcibly revalidated. |
| 7093 // TODO(toyoshim): Will consider to revalidate main resources in sub-frames |
| 7094 // on reloads. Or will do only for bypassingCache. |
| 7095 EXPECT_EQ(childClient.getCachePolicy(), |
| 7096 WebCachePolicy::UseProtocolCachePolicy); |
| 7092 } | 7097 } |
| 7093 | 7098 |
| 7094 class TestSameDocumentWebFrameClient | 7099 class TestSameDocumentWebFrameClient |
| 7095 : public FrameTestHelpers::TestWebFrameClient { | 7100 : public FrameTestHelpers::TestWebFrameClient { |
| 7096 public: | 7101 public: |
| 7097 TestSameDocumentWebFrameClient() | 7102 TestSameDocumentWebFrameClient() |
| 7098 : m_frameLoadTypeReloadMainResourceSeen(false) {} | 7103 : m_frameLoadTypeReloadMainResourceSeen(false) {} |
| 7099 | 7104 |
| 7100 virtual void willSendRequest(WebLocalFrame* frame, WebURLRequest&) { | 7105 virtual void willSendRequest(WebLocalFrame* frame, WebURLRequest&) { |
| 7101 if (toWebLocalFrameImpl(frame)->frame()->loader().loadType() == | 7106 if (toWebLocalFrameImpl(frame)->frame()->loader().loadType() == |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8243 Document* document = | 8248 Document* document = |
| 8244 webViewHelper.webView()->mainFrameImpl()->frame()->document(); | 8249 webViewHelper.webView()->mainFrameImpl()->frame()->document(); |
| 8245 | 8250 |
| 8246 Resource* resource = fetchManifest( | 8251 Resource* resource = fetchManifest( |
| 8247 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); | 8252 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); |
| 8248 | 8253 |
| 8249 EXPECT_TRUE(resource->isLoaded()); | 8254 EXPECT_TRUE(resource->isLoaded()); |
| 8250 } | 8255 } |
| 8251 | 8256 |
| 8252 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) { | 8257 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) { |
| 8253 // Check that a reload ignoring cache on a frame will result in the cache | 8258 // Check that a reload bypassing cache on a frame will result in the cache |
| 8254 // policy of the request being set to ReloadBypassingCache. | 8259 // policy of the request being set to ReloadBypassingCache. |
| 8255 registerMockedHttpURLLoad("foo.html"); | 8260 registerMockedHttpURLLoad("foo.html"); |
| 8256 FrameTestHelpers::WebViewHelper webViewHelper; | 8261 FrameTestHelpers::WebViewHelper webViewHelper; |
| 8257 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); | 8262 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); |
| 8258 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 8263 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 8259 FrameTestHelpers::reloadFrameIgnoringCache(frame); | 8264 FrameTestHelpers::reloadFrameBypassingCache(frame); |
| 8260 EXPECT_EQ(WebCachePolicy::BypassingCache, | 8265 EXPECT_EQ(WebCachePolicy::BypassingCache, |
| 8261 frame->dataSource()->request().getCachePolicy()); | 8266 frame->dataSource()->request().getCachePolicy()); |
| 8262 } | 8267 } |
| 8263 | 8268 |
| 8264 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, | 8269 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, |
| 8265 DragImage* dragImage) { | 8270 DragImage* dragImage) { |
| 8266 // Prepare the reference bitmap. | 8271 // Prepare the reference bitmap. |
| 8267 SkBitmap bitmap; | 8272 SkBitmap bitmap; |
| 8268 bitmap.allocN32Pixels(referenceBitmapSize.width(), | 8273 bitmap.allocN32Pixels(referenceBitmapSize.width(), |
| 8269 referenceBitmapSize.height()); | 8274 referenceBitmapSize.height()); |
| (...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11005 | 11010 |
| 11006 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 11011 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
| 11007 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 11012 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
| 11008 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 11013 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
| 11009 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 11014 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
| 11010 | 11015 |
| 11011 webViewHelper.reset(); | 11016 webViewHelper.reset(); |
| 11012 } | 11017 } |
| 11013 | 11018 |
| 11014 } // namespace blink | 11019 } // namespace blink |
| OLD | NEW |