| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 #include "platform/RuntimeEnabledFeatures.h" | 82 #include "platform/RuntimeEnabledFeatures.h" |
| 83 #include "platform/UserGestureIndicator.h" | 83 #include "platform/UserGestureIndicator.h" |
| 84 #include "platform/geometry/FloatRect.h" | 84 #include "platform/geometry/FloatRect.h" |
| 85 #include "platform/network/ResourceError.h" | 85 #include "platform/network/ResourceError.h" |
| 86 #include "platform/scroll/ScrollbarTheme.h" | 86 #include "platform/scroll/ScrollbarTheme.h" |
| 87 #include "platform/testing/URLTestHelpers.h" | 87 #include "platform/testing/URLTestHelpers.h" |
| 88 #include "platform/testing/UnitTestHelpers.h" | 88 #include "platform/testing/UnitTestHelpers.h" |
| 89 #include "platform/weborigin/SchemeRegistry.h" | 89 #include "platform/weborigin/SchemeRegistry.h" |
| 90 #include "platform/weborigin/SecurityOrigin.h" | 90 #include "platform/weborigin/SecurityOrigin.h" |
| 91 #include "public/platform/Platform.h" | 91 #include "public/platform/Platform.h" |
| 92 #include "public/platform/WebCachePolicy.h" |
| 92 #include "public/platform/WebFloatRect.h" | 93 #include "public/platform/WebFloatRect.h" |
| 93 #include "public/platform/WebSecurityOrigin.h" | 94 #include "public/platform/WebSecurityOrigin.h" |
| 94 #include "public/platform/WebThread.h" | 95 #include "public/platform/WebThread.h" |
| 95 #include "public/platform/WebURL.h" | 96 #include "public/platform/WebURL.h" |
| 96 #include "public/platform/WebURLLoaderMockFactory.h" | 97 #include "public/platform/WebURLLoaderMockFactory.h" |
| 97 #include "public/platform/WebURLResponse.h" | 98 #include "public/platform/WebURLResponse.h" |
| 98 #include "public/web/WebCache.h" | 99 #include "public/web/WebCache.h" |
| 99 #include "public/web/WebConsoleMessage.h" | 100 #include "public/web/WebConsoleMessage.h" |
| 100 #include "public/web/WebDataSource.h" | 101 #include "public/web/WebDataSource.h" |
| 101 #include "public/web/WebDeviceEmulationParams.h" | 102 #include "public/web/WebDeviceEmulationParams.h" |
| (...skipping 5013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5115 std::string errorURL = "http://0.0.0.0"; | 5116 std::string errorURL = "http://0.0.0.0"; |
| 5116 WebURLResponse response; | 5117 WebURLResponse response; |
| 5117 response.initialize(); | 5118 response.initialize(); |
| 5118 response.setURL(URLTestHelpers::toKURL(errorURL)); | 5119 response.setURL(URLTestHelpers::toKURL(errorURL)); |
| 5119 response.setMIMEType("text/html"); | 5120 response.setMIMEType("text/html"); |
| 5120 response.setHTTPStatusCode(500); | 5121 response.setHTTPStatusCode(500); |
| 5121 WebHistoryItem errorHistoryItem; | 5122 WebHistoryItem errorHistoryItem; |
| 5122 errorHistoryItem.initialize(); | 5123 errorHistoryItem.initialize(); |
| 5123 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); | 5124 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); |
| 5124 Platform::current()->getURLLoaderMockFactory()->registerErrorURL(URLTestHelp
ers::toKURL(errorURL), response, error); | 5125 Platform::current()->getURLLoaderMockFactory()->registerErrorURL(URLTestHelp
ers::toKURL(errorURL), response, error); |
| 5125 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere
ntDocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 5126 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere
ntDocumentLoad, WebCachePolicy::UseProtocolCachePolicy); |
| 5126 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); | 5127 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); |
| 5127 EXPECT_EQ("This should appear", text.utf8()); | 5128 EXPECT_EQ("This should appear", text.utf8()); |
| 5128 EXPECT_TRUE(webFrameClient.commitCalled()); | 5129 EXPECT_TRUE(webFrameClient.commitCalled()); |
| 5129 } | 5130 } |
| 5130 | 5131 |
| 5131 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { | 5132 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl
ient { |
| 5132 public: | 5133 public: |
| 5133 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) | 5134 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) |
| 5134 { | 5135 { |
| 5135 } | 5136 } |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5866 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 5867 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
| 5867 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5868 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5868 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); | 5869 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); |
| 5869 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); | 5870 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); |
| 5870 EXPECT_TRUE(firstItem); | 5871 EXPECT_TRUE(firstItem); |
| 5871 | 5872 |
| 5872 registerMockedHttpURLLoad("white-1x1.png"); | 5873 registerMockedHttpURLLoad("white-1x1.png"); |
| 5873 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 5874 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
| 5874 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 5875 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
| 5875 | 5876 |
| 5876 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 5877 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We
bHistoryDifferentDocumentLoad, WebCachePolicy::UseProtocolCachePolicy); |
| 5877 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 5878 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
| 5878 | 5879 |
| 5879 FrameTestHelpers::reloadFrame(frame); | 5880 FrameTestHelpers::reloadFrame(frame); |
| 5880 EXPECT_EQ(WebURLRequest::ValidatingCacheData, frame->dataSource()->request()
.getCachePolicy()); | 5881 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request(
).getCachePolicy()); |
| 5881 } | 5882 } |
| 5882 | 5883 |
| 5883 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) | 5884 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) |
| 5884 { | 5885 { |
| 5885 registerMockedHttpURLLoad("page_with_blank_iframe.html"); | 5886 registerMockedHttpURLLoad("page_with_blank_iframe.html"); |
| 5886 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5887 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 5887 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); | 5888 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t
rue); |
| 5888 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); | 5889 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); |
| 5889 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); | 5890 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); |
| 5890 WebFrame* childFrame = mainFrame->firstChild(); | 5891 WebFrame* childFrame = mainFrame->firstChild(); |
| 5891 ASSERT_TRUE(childFrame); | 5892 ASSERT_TRUE(childFrame); |
| 5892 | 5893 |
| 5893 // Start a history navigation, then have a different frame commit a navigati
on. | 5894 // Start a history navigation, then have a different frame commit a navigati
on. |
| 5894 // In this case, reload an about:blank frame, which will commit synchronousl
y. | 5895 // In this case, reload an about:blank frame, which will commit synchronousl
y. |
| 5895 // After the history navigation completes, both the appropriate document url
and | 5896 // After the history navigation completes, both the appropriate document url
and |
| 5896 // the current history item should reflect the history navigation. | 5897 // the current history item should reflect the history navigation. |
| 5897 registerMockedHttpURLLoad("white-1x1.png"); | 5898 registerMockedHttpURLLoad("white-1x1.png"); |
| 5898 WebHistoryItem item; | 5899 WebHistoryItem item; |
| 5899 item.initialize(); | 5900 item.initialize(); |
| 5900 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); | 5901 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); |
| 5901 item.setURLString(historyURL.string()); | 5902 item.setURLString(historyURL.string()); |
| 5902 mainFrame->loadHistoryItem(item, WebHistoryDifferentDocumentLoad, WebURLRequ
est::UseProtocolCachePolicy); | 5903 mainFrame->loadHistoryItem(item, WebHistoryDifferentDocumentLoad, WebCachePo
licy::UseProtocolCachePolicy); |
| 5903 | 5904 |
| 5904 FrameTestHelpers::reloadFrame(childFrame); | 5905 FrameTestHelpers::reloadFrame(childFrame); |
| 5905 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); | 5906 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); |
| 5906 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri
ng())); | 5907 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri
ng())); |
| 5907 } | 5908 } |
| 5908 | 5909 |
| 5909 TEST_P(ParameterizedWebFrameTest, ReloadPost) | 5910 TEST_P(ParameterizedWebFrameTest, ReloadPost) |
| 5910 { | 5911 { |
| 5911 registerMockedHttpURLLoad("reload_post.html"); | 5912 registerMockedHttpURLLoad("reload_post.html"); |
| 5912 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5913 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 5913 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); | 5914 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); |
| 5914 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5915 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5915 | 5916 |
| 5916 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); | 5917 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip
t:document.forms[0].submit()"); |
| 5917 // Pump requests one more time after the javascript URL has executed to | 5918 // Pump requests one more time after the javascript URL has executed to |
| 5918 // trigger the actual POST load request. | 5919 // trigger the actual POST load request. |
| 5919 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); | 5920 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()-
>mainFrame()); |
| 5920 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); | 5921 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe
thod()); |
| 5921 | 5922 |
| 5922 FrameTestHelpers::reloadFrame(frame); | 5923 FrameTestHelpers::reloadFrame(frame); |
| 5923 EXPECT_EQ(WebURLRequest::ValidatingCacheData, frame->dataSource()->request()
.getCachePolicy()); | 5924 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request(
).getCachePolicy()); |
| 5924 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); | 5925 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT
ype()); |
| 5925 } | 5926 } |
| 5926 | 5927 |
| 5927 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) | 5928 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) |
| 5928 { | 5929 { |
| 5929 registerMockedHttpURLLoad("fragment_middle_click.html"); | 5930 registerMockedHttpURLLoad("fragment_middle_click.html"); |
| 5930 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5931 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 5931 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); | 5932 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr
ue); |
| 5932 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 5933 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 5933 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); | 5934 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI
mpl()->frame()->loader(); |
| 5934 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); | 5935 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); |
| 5935 EXPECT_TRUE(firstItem); | 5936 EXPECT_TRUE(firstItem); |
| 5936 | 5937 |
| 5937 registerMockedHttpURLLoad("white-1x1.png"); | 5938 registerMockedHttpURLLoad("white-1x1.png"); |
| 5938 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); | 5939 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); |
| 5939 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); | 5940 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); |
| 5940 | 5941 |
| 5941 // Cache policy overrides should take. | 5942 // Cache policy overrides should take. |
| 5942 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto
ryDifferentDocumentLoad, WebURLRequest::ValidatingCacheData); | 5943 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto
ryDifferentDocumentLoad, WebCachePolicy::ValidatingCacheData); |
| 5943 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); | 5944 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); |
| 5944 EXPECT_EQ(WebURLRequest::ValidatingCacheData, frame->dataSource()->request()
.getCachePolicy()); | 5945 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request(
).getCachePolicy()); |
| 5945 } | 5946 } |
| 5946 | 5947 |
| 5947 | 5948 |
| 5948 class TestCachePolicyWebFrameClient : public FrameTestHelpers::TestWebFrameClien
t { | 5949 class TestCachePolicyWebFrameClient : public FrameTestHelpers::TestWebFrameClien
t { |
| 5949 public: | 5950 public: |
| 5950 explicit TestCachePolicyWebFrameClient(TestCachePolicyWebFrameClient* parent
Client) | 5951 explicit TestCachePolicyWebFrameClient(TestCachePolicyWebFrameClient* parent
Client) |
| 5951 : m_parentClient(parentClient) | 5952 : m_parentClient(parentClient) |
| 5952 , m_policy(WebURLRequest::UseProtocolCachePolicy) | 5953 , m_policy(WebCachePolicy::UseProtocolCachePolicy) |
| 5953 , m_childClient(0) | 5954 , m_childClient(0) |
| 5954 , m_willSendRequestCallCount(0) | 5955 , m_willSendRequestCallCount(0) |
| 5955 , m_childFrameCreationCount(0) | 5956 , m_childFrameCreationCount(0) |
| 5956 { | 5957 { |
| 5957 } | 5958 } |
| 5958 | 5959 |
| 5959 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child
Client = client; } | 5960 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child
Client = client; } |
| 5960 WebURLRequest::CachePolicy getCachePolicy() const { return m_policy; } | 5961 WebCachePolicy getCachePolicy() const { return m_policy; } |
| 5961 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } | 5962 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } |
| 5962 int childFrameCreationCount() const { return m_childFrameCreationCount; } | 5963 int childFrameCreationCount() const { return m_childFrameCreationCount; } |
| 5963 | 5964 |
| 5964 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s
cope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOwnerPr
operties& frameOwnerProperties) | 5965 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s
cope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOwnerPr
operties& frameOwnerProperties) |
| 5965 { | 5966 { |
| 5966 DCHECK(m_childClient); | 5967 DCHECK(m_childClient); |
| 5967 m_childFrameCreationCount++; | 5968 m_childFrameCreationCount++; |
| 5968 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); | 5969 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); |
| 5969 parent->appendChild(frame); | 5970 parent->appendChild(frame); |
| 5970 return frame; | 5971 return frame; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5990 | 5991 |
| 5991 void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request,
const WebURLResponse&) override | 5992 void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request,
const WebURLResponse&) override |
| 5992 { | 5993 { |
| 5993 m_policy = request.getCachePolicy(); | 5994 m_policy = request.getCachePolicy(); |
| 5994 m_willSendRequestCallCount++; | 5995 m_willSendRequestCallCount++; |
| 5995 } | 5996 } |
| 5996 | 5997 |
| 5997 private: | 5998 private: |
| 5998 TestCachePolicyWebFrameClient* m_parentClient; | 5999 TestCachePolicyWebFrameClient* m_parentClient; |
| 5999 | 6000 |
| 6000 WebURLRequest::CachePolicy m_policy; | 6001 WebCachePolicy m_policy; |
| 6001 TestCachePolicyWebFrameClient* m_childClient; | 6002 TestCachePolicyWebFrameClient* m_childClient; |
| 6002 int m_willSendRequestCallCount; | 6003 int m_willSendRequestCallCount; |
| 6003 int m_childFrameCreationCount; | 6004 int m_childFrameCreationCount; |
| 6004 }; | 6005 }; |
| 6005 | 6006 |
| 6006 TEST_P(ParameterizedWebFrameTest, ReloadIframe) | 6007 TEST_P(ParameterizedWebFrameTest, ReloadIframe) |
| 6007 { | 6008 { |
| 6008 registerMockedHttpURLLoad("iframe_reload.html"); | 6009 registerMockedHttpURLLoad("iframe_reload.html"); |
| 6009 registerMockedHttpURLLoad("visible_iframe.html"); | 6010 registerMockedHttpURLLoad("visible_iframe.html"); |
| 6010 TestCachePolicyWebFrameClient mainClient(0); | 6011 TestCachePolicyWebFrameClient mainClient(0); |
| 6011 TestCachePolicyWebFrameClient childClient(&mainClient); | 6012 TestCachePolicyWebFrameClient childClient(&mainClient); |
| 6012 mainClient.setChildWebFrameClient(&childClient); | 6013 mainClient.setChildWebFrameClient(&childClient); |
| 6013 | 6014 |
| 6014 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6015 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 6015 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); | 6016 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai
nClient); |
| 6016 | 6017 |
| 6017 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); | 6018 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); |
| 6018 RawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC
hild()); | 6019 RawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC
hild()); |
| 6019 ASSERT_EQ(childFrame->client(), &childClient); | 6020 ASSERT_EQ(childFrame->client(), &childClient); |
| 6020 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); | 6021 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); |
| 6021 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); | 6022 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); |
| 6022 EXPECT_EQ(childClient.getCachePolicy(), WebURLRequest::UseProtocolCachePolic
y); | 6023 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::UseProtocolCachePoli
cy); |
| 6023 | 6024 |
| 6024 FrameTestHelpers::reloadFrame(mainFrame); | 6025 FrameTestHelpers::reloadFrame(mainFrame); |
| 6025 | 6026 |
| 6026 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. | 6027 // A new WebFrame should have been created, but the child WebFrameClient sho
uld be reused. |
| 6027 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); | 6028 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); |
| 6028 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); | 6029 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie
nt); |
| 6029 | 6030 |
| 6030 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); | 6031 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); |
| 6031 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); | 6032 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); |
| 6032 EXPECT_EQ(childClient.getCachePolicy(), WebURLRequest::ValidatingCacheData); | 6033 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::ValidatingCacheData)
; |
| 6033 } | 6034 } |
| 6034 | 6035 |
| 6035 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { | 6036 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie
nt { |
| 6036 public: | 6037 public: |
| 6037 TestSameDocumentWebFrameClient() | 6038 TestSameDocumentWebFrameClient() |
| 6038 : m_frameLoadTypeSameSeen(false) | 6039 : m_frameLoadTypeSameSeen(false) |
| 6039 { | 6040 { |
| 6040 } | 6041 } |
| 6041 | 6042 |
| 6042 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) | 6043 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&,
const WebURLResponse&) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 6070 public: | 6071 public: |
| 6071 TestSameDocumentWithImageWebFrameClient() | 6072 TestSameDocumentWithImageWebFrameClient() |
| 6072 : m_numOfImageRequests(0) | 6073 : m_numOfImageRequests(0) |
| 6073 { | 6074 { |
| 6074 } | 6075 } |
| 6075 | 6076 |
| 6076 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&
request, const WebURLResponse&) | 6077 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&
request, const WebURLResponse&) |
| 6077 { | 6078 { |
| 6078 if (request.getRequestContext() == WebURLRequest::RequestContextImage) { | 6079 if (request.getRequestContext() == WebURLRequest::RequestContextImage) { |
| 6079 m_numOfImageRequests++; | 6080 m_numOfImageRequests++; |
| 6080 EXPECT_EQ(WebURLRequest::UseProtocolCachePolicy, request.getCachePol
icy()); | 6081 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, request.getCachePo
licy()); |
| 6081 } | 6082 } |
| 6082 } | 6083 } |
| 6083 | 6084 |
| 6084 int numOfImageRequests() const { return m_numOfImageRequests; } | 6085 int numOfImageRequests() const { return m_numOfImageRequests; } |
| 6085 | 6086 |
| 6086 private: | 6087 private: |
| 6087 int m_numOfImageRequests; | 6088 int m_numOfImageRequests; |
| 6088 }; | 6089 }; |
| 6089 | 6090 |
| 6090 TEST_P(ParameterizedWebFrameTest, NavigateToSameNoConditionalRequestForSubresour
ce) | 6091 TEST_P(ParameterizedWebFrameTest, NavigateToSameNoConditionalRequestForSubresour
ce) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6192 | 6193 |
| 6193 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType) | 6194 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType) |
| 6194 { | 6195 { |
| 6195 registerMockedHttpURLLoad("push_state.html"); | 6196 registerMockedHttpURLLoad("push_state.html"); |
| 6196 TestDidNavigateCommitTypeWebFrameClient client; | 6197 TestDidNavigateCommitTypeWebFrameClient client; |
| 6197 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6198 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 6198 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); | 6199 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push
_state.html", true, &client); |
| 6199 Persistent<HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFrame()
)->loader().currentItem(); | 6200 Persistent<HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFrame()
)->loader().currentItem(); |
| 6200 runPendingTasks(); | 6201 runPendingTasks(); |
| 6201 | 6202 |
| 6202 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load( | 6203 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(FrameLoadReque
st(nullptr, FrameLoader::resourceRequestFromHistoryItem(item.get(), WebCachePoli
cy::UseProtocolCachePolicy)), FrameLoadTypeBackForward, item.get(), HistorySameD
ocumentLoad); |
| 6203 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem( | |
| 6204 item.get(), UseProtocolCachePolicy)), | |
| 6205 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); | |
| 6206 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); | 6204 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); |
| 6207 } | 6205 } |
| 6208 | 6206 |
| 6209 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { | 6207 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { |
| 6210 public: | 6208 public: |
| 6211 TestHistoryWebFrameClient() | 6209 TestHistoryWebFrameClient() |
| 6212 { | 6210 { |
| 6213 m_replacesCurrentHistoryItem = false; | 6211 m_replacesCurrentHistoryItem = false; |
| 6214 m_frame = nullptr; | 6212 m_frame = nullptr; |
| 6215 } | 6213 } |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6863 | 6861 |
| 6864 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) | 6862 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) |
| 6865 { | 6863 { |
| 6866 // Check that a reload ignoring cache on a frame will result in the cache | 6864 // Check that a reload ignoring cache on a frame will result in the cache |
| 6867 // policy of the request being set to ReloadBypassingCache. | 6865 // policy of the request being set to ReloadBypassingCache. |
| 6868 registerMockedHttpURLLoad("foo.html"); | 6866 registerMockedHttpURLLoad("foo.html"); |
| 6869 FrameTestHelpers::WebViewHelper webViewHelper(this); | 6867 FrameTestHelpers::WebViewHelper webViewHelper(this); |
| 6870 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); | 6868 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); |
| 6871 WebFrame* frame = webViewHelper.webView()->mainFrame(); | 6869 WebFrame* frame = webViewHelper.webView()->mainFrame(); |
| 6872 FrameTestHelpers::reloadFrameIgnoringCache(frame); | 6870 FrameTestHelpers::reloadFrameIgnoringCache(frame); |
| 6873 EXPECT_EQ(WebURLRequest::BypassingCache, frame->dataSource()->request().getC
achePolicy()); | 6871 EXPECT_EQ(WebCachePolicy::BypassingCache, frame->dataSource()->request().get
CachePolicy()); |
| 6874 } | 6872 } |
| 6875 | 6873 |
| 6876 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, DragImag
e* dragImage) | 6874 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, DragImag
e* dragImage) |
| 6877 { | 6875 { |
| 6878 // Prepare the reference bitmap. | 6876 // Prepare the reference bitmap. |
| 6879 SkBitmap bitmap; | 6877 SkBitmap bitmap; |
| 6880 bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.heigh
t()); | 6878 bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.heigh
t()); |
| 6881 SkCanvas canvas(bitmap); | 6879 SkCanvas canvas(bitmap); |
| 6882 canvas.drawColor(SK_ColorGREEN); | 6880 canvas.drawColor(SK_ColorGREEN); |
| 6883 | 6881 |
| (...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8561 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); | 8559 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); |
| 8562 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 8560 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 8563 mainFrame->executeScript(WebScriptSource("hello = 'world';")); | 8561 mainFrame->executeScript(WebScriptSource("hello = 'world';")); |
| 8564 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); | 8562 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); |
| 8565 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); | 8563 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); |
| 8566 ASSERT_TRUE(result->IsString()); | 8564 ASSERT_TRUE(result->IsString()); |
| 8567 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); | 8565 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); |
| 8568 } | 8566 } |
| 8569 | 8567 |
| 8570 } // namespace blink | 8568 } // namespace blink |
| OLD | NEW |