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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 1858533002: Introduce WebCachePolicy to merge cache policy enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review, minor fixes Created 4 years, 8 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
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/WebURLResponse.h" 97 #include "public/platform/WebURLResponse.h"
97 #include "public/platform/WebUnitTestSupport.h" 98 #include "public/platform/WebUnitTestSupport.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 5021 matching lines...) Expand 10 before | Expand all | Expand 10 after
5123 std::string errorURL = "http://0.0.0.0"; 5124 std::string errorURL = "http://0.0.0.0";
5124 WebURLResponse response; 5125 WebURLResponse response;
5125 response.initialize(); 5126 response.initialize();
5126 response.setURL(URLTestHelpers::toKURL(errorURL)); 5127 response.setURL(URLTestHelpers::toKURL(errorURL));
5127 response.setMIMEType("text/html"); 5128 response.setMIMEType("text/html");
5128 response.setHTTPStatusCode(500); 5129 response.setHTTPStatusCode(500);
5129 WebHistoryItem errorHistoryItem; 5130 WebHistoryItem errorHistoryItem;
5130 errorHistoryItem.initialize(); 5131 errorHistoryItem.initialize();
5131 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL .length())); 5132 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL .length()));
5132 Platform::current()->unitTestSupport()->registerMockedErrorURL(URLTestHelper s::toKURL(errorURL), response, error); 5133 Platform::current()->unitTestSupport()->registerMockedErrorURL(URLTestHelper s::toKURL(errorURL), response, error);
5133 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere ntDocumentLoad, WebURLRequest::UseProtocolCachePolicy); 5134 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere ntDocumentLoad, WebCachePolicy::UseProtocolCachePolicy);
5134 5135
5135 WebString text = WebFrameContentDumper::dumpFrameTreeAsText(frame->toWebLoca lFrame(), std::numeric_limits<size_t>::max()); 5136 WebString text = WebFrameContentDumper::dumpFrameTreeAsText(frame->toWebLoca lFrame(), std::numeric_limits<size_t>::max());
5136 EXPECT_EQ("This should appear", text.utf8()); 5137 EXPECT_EQ("This should appear", text.utf8());
5137 EXPECT_TRUE(webFrameClient.commitCalled()); 5138 EXPECT_TRUE(webFrameClient.commitCalled());
5138 } 5139 }
5139 5140
5140 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient { 5141 class TestWillInsertBodyWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient {
5141 public: 5142 public:
5142 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false) 5143 TestWillInsertBodyWebFrameClient() : m_numBodies(0), m_didLoad(false)
5143 { 5144 {
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
5875 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue); 5876 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue);
5876 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5877 WebFrame* frame = webViewHelper.webView()->mainFrame();
5877 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader(); 5878 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader();
5878 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); 5879 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem();
5879 EXPECT_TRUE(firstItem); 5880 EXPECT_TRUE(firstItem);
5880 5881
5881 registerMockedHttpURLLoad("white-1x1.png"); 5882 registerMockedHttpURLLoad("white-1x1.png");
5882 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); 5883 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png");
5883 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); 5884 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem());
5884 5885
5885 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We bHistoryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); 5886 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem.get()), We bHistoryDifferentDocumentLoad, WebCachePolicy::UseProtocolCachePolicy);
5886 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); 5887 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem());
5887 5888
5888 FrameTestHelpers::reloadFrame(frame); 5889 FrameTestHelpers::reloadFrame(frame);
5889 EXPECT_EQ(WebURLRequest::ValidatingCacheData, frame->dataSource()->request() .getCachePolicy()); 5890 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request( ).getCachePolicy());
5890 } 5891 }
5891 5892
5892 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload) 5893 TEST_P(ParameterizedWebFrameTest, BackDuringChildFrameReload)
5893 { 5894 {
5894 registerMockedHttpURLLoad("page_with_blank_iframe.html"); 5895 registerMockedHttpURLLoad("page_with_blank_iframe.html");
5895 FrameTestHelpers::WebViewHelper webViewHelper(this); 5896 FrameTestHelpers::WebViewHelper webViewHelper(this);
5896 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t rue); 5897 webViewHelper.initializeAndLoad(m_baseURL + "page_with_blank_iframe.html", t rue);
5897 WebFrame* mainFrame = webViewHelper.webView()->mainFrame(); 5898 WebFrame* mainFrame = webViewHelper.webView()->mainFrame();
5898 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader(); 5899 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader();
5899 WebFrame* childFrame = mainFrame->firstChild(); 5900 WebFrame* childFrame = mainFrame->firstChild();
5900 ASSERT_TRUE(childFrame); 5901 ASSERT_TRUE(childFrame);
5901 5902
5902 // Start a history navigation, then have a different frame commit a navigati on. 5903 // Start a history navigation, then have a different frame commit a navigati on.
5903 // In this case, reload an about:blank frame, which will commit synchronousl y. 5904 // In this case, reload an about:blank frame, which will commit synchronousl y.
5904 // After the history navigation completes, both the appropriate document url and 5905 // After the history navigation completes, both the appropriate document url and
5905 // the current history item should reflect the history navigation. 5906 // the current history item should reflect the history navigation.
5906 registerMockedHttpURLLoad("white-1x1.png"); 5907 registerMockedHttpURLLoad("white-1x1.png");
5907 WebHistoryItem item; 5908 WebHistoryItem item;
5908 item.initialize(); 5909 item.initialize();
5909 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png")); 5910 WebURL historyURL(toKURL(m_baseURL + "white-1x1.png"));
5910 item.setURLString(historyURL.string()); 5911 item.setURLString(historyURL.string());
5911 mainFrame->loadHistoryItem(item, WebHistoryDifferentDocumentLoad, WebURLRequ est::UseProtocolCachePolicy); 5912 mainFrame->loadHistoryItem(item, WebHistoryDifferentDocumentLoad, WebCachePo licy::UseProtocolCachePolicy);
5912 5913
5913 FrameTestHelpers::reloadFrame(childFrame); 5914 FrameTestHelpers::reloadFrame(childFrame);
5914 EXPECT_EQ(item.urlString(), mainFrame->document().url().string()); 5915 EXPECT_EQ(item.urlString(), mainFrame->document().url().string());
5915 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri ng())); 5916 EXPECT_EQ(item.urlString(), WebString(mainFrameLoader.currentItem()->urlStri ng()));
5916 } 5917 }
5917 5918
5918 TEST_P(ParameterizedWebFrameTest, ReloadPost) 5919 TEST_P(ParameterizedWebFrameTest, ReloadPost)
5919 { 5920 {
5920 registerMockedHttpURLLoad("reload_post.html"); 5921 registerMockedHttpURLLoad("reload_post.html");
5921 FrameTestHelpers::WebViewHelper webViewHelper(this); 5922 FrameTestHelpers::WebViewHelper webViewHelper(this);
5922 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true); 5923 webViewHelper.initializeAndLoad(m_baseURL + "reload_post.html", true);
5923 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5924 WebFrame* frame = webViewHelper.webView()->mainFrame();
5924 5925
5925 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip t:document.forms[0].submit()"); 5926 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), "javascrip t:document.forms[0].submit()");
5926 // Pump requests one more time after the javascript URL has executed to 5927 // Pump requests one more time after the javascript URL has executed to
5927 // trigger the actual POST load request. 5928 // trigger the actual POST load request.
5928 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame()); 5929 FrameTestHelpers::pumpPendingRequestsForFrameToLoad(webViewHelper.webView()- >mainFrame());
5929 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe thod()); 5930 EXPECT_EQ(WebString::fromUTF8("POST"), frame->dataSource()->request().httpMe thod());
5930 5931
5931 FrameTestHelpers::reloadFrame(frame); 5932 FrameTestHelpers::reloadFrame(frame);
5932 EXPECT_EQ(WebURLRequest::ValidatingCacheData, frame->dataSource()->request() .getCachePolicy()); 5933 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request( ).getCachePolicy());
5933 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT ype()); 5934 EXPECT_EQ(WebNavigationTypeFormResubmitted, frame->dataSource()->navigationT ype());
5934 } 5935 }
5935 5936
5936 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload) 5937 TEST_P(ParameterizedWebFrameTest, LoadHistoryItemReload)
5937 { 5938 {
5938 registerMockedHttpURLLoad("fragment_middle_click.html"); 5939 registerMockedHttpURLLoad("fragment_middle_click.html");
5939 FrameTestHelpers::WebViewHelper webViewHelper(this); 5940 FrameTestHelpers::WebViewHelper webViewHelper(this);
5940 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue); 5941 webViewHelper.initializeAndLoad(m_baseURL + "fragment_middle_click.html", tr ue);
5941 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5942 WebFrame* frame = webViewHelper.webView()->mainFrame();
5942 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader(); 5943 const FrameLoader& mainFrameLoader = webViewHelper.webViewImpl()->mainFrameI mpl()->frame()->loader();
5943 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem(); 5944 Persistent<HistoryItem> firstItem = mainFrameLoader.currentItem();
5944 EXPECT_TRUE(firstItem); 5945 EXPECT_TRUE(firstItem);
5945 5946
5946 registerMockedHttpURLLoad("white-1x1.png"); 5947 registerMockedHttpURLLoad("white-1x1.png");
5947 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png"); 5948 FrameTestHelpers::loadFrame(frame, m_baseURL + "white-1x1.png");
5948 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem()); 5949 EXPECT_NE(firstItem.get(), mainFrameLoader.currentItem());
5949 5950
5950 // Cache policy overrides should take. 5951 // Cache policy overrides should take.
5951 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto ryDifferentDocumentLoad, WebURLRequest::ValidatingCacheData); 5952 FrameTestHelpers::loadHistoryItem(frame, WebHistoryItem(firstItem), WebHisto ryDifferentDocumentLoad, WebCachePolicy::ValidatingCacheData);
5952 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem()); 5953 EXPECT_EQ(firstItem.get(), mainFrameLoader.currentItem());
5953 EXPECT_EQ(WebURLRequest::ValidatingCacheData, frame->dataSource()->request() .getCachePolicy()); 5954 EXPECT_EQ(WebCachePolicy::ValidatingCacheData, frame->dataSource()->request( ).getCachePolicy());
5954 } 5955 }
5955 5956
5956 5957
5957 class TestCachePolicyWebFrameClient : public FrameTestHelpers::TestWebFrameClien t { 5958 class TestCachePolicyWebFrameClient : public FrameTestHelpers::TestWebFrameClien t {
5958 public: 5959 public:
5959 explicit TestCachePolicyWebFrameClient(TestCachePolicyWebFrameClient* parent Client) 5960 explicit TestCachePolicyWebFrameClient(TestCachePolicyWebFrameClient* parent Client)
5960 : m_parentClient(parentClient) 5961 : m_parentClient(parentClient)
5961 , m_policy(WebURLRequest::UseProtocolCachePolicy) 5962 , m_policy(WebCachePolicy::UseProtocolCachePolicy)
5962 , m_childClient(0) 5963 , m_childClient(0)
5963 , m_willSendRequestCallCount(0) 5964 , m_willSendRequestCallCount(0)
5964 , m_childFrameCreationCount(0) 5965 , m_childFrameCreationCount(0)
5965 { 5966 {
5966 } 5967 }
5967 5968
5968 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; } 5969 void setChildWebFrameClient(TestCachePolicyWebFrameClient* client) { m_child Client = client; }
5969 WebURLRequest::CachePolicy getCachePolicy() const { return m_policy; } 5970 WebCachePolicy getCachePolicy() const { return m_policy; }
5970 int willSendRequestCallCount() const { return m_willSendRequestCallCount; } 5971 int willSendRequestCallCount() const { return m_willSendRequestCallCount; }
5971 int childFrameCreationCount() const { return m_childFrameCreationCount; } 5972 int childFrameCreationCount() const { return m_childFrameCreationCount; }
5972 5973
5973 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOwnerPr operties& frameOwnerProperties) 5974 virtual WebFrame* createChildFrame(WebLocalFrame* parent, WebTreeScopeType s cope, const WebString&, const WebString&, WebSandboxFlags, const WebFrameOwnerPr operties& frameOwnerProperties)
5974 { 5975 {
5975 DCHECK(m_childClient); 5976 DCHECK(m_childClient);
5976 m_childFrameCreationCount++; 5977 m_childFrameCreationCount++;
5977 WebFrame* frame = WebLocalFrame::create(scope, m_childClient); 5978 WebFrame* frame = WebLocalFrame::create(scope, m_childClient);
5978 parent->appendChild(frame); 5979 parent->appendChild(frame);
5979 return frame; 5980 return frame;
(...skipping 19 matching lines...) Expand all
5999 6000
6000 void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request, const WebURLResponse&) override 6001 void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request, const WebURLResponse&) override
6001 { 6002 {
6002 m_policy = request.getCachePolicy(); 6003 m_policy = request.getCachePolicy();
6003 m_willSendRequestCallCount++; 6004 m_willSendRequestCallCount++;
6004 } 6005 }
6005 6006
6006 private: 6007 private:
6007 TestCachePolicyWebFrameClient* m_parentClient; 6008 TestCachePolicyWebFrameClient* m_parentClient;
6008 6009
6009 WebURLRequest::CachePolicy m_policy; 6010 WebCachePolicy m_policy;
6010 TestCachePolicyWebFrameClient* m_childClient; 6011 TestCachePolicyWebFrameClient* m_childClient;
6011 int m_willSendRequestCallCount; 6012 int m_willSendRequestCallCount;
6012 int m_childFrameCreationCount; 6013 int m_childFrameCreationCount;
6013 }; 6014 };
6014 6015
6015 TEST_P(ParameterizedWebFrameTest, ReloadIframe) 6016 TEST_P(ParameterizedWebFrameTest, ReloadIframe)
6016 { 6017 {
6017 registerMockedHttpURLLoad("iframe_reload.html"); 6018 registerMockedHttpURLLoad("iframe_reload.html");
6018 registerMockedHttpURLLoad("visible_iframe.html"); 6019 registerMockedHttpURLLoad("visible_iframe.html");
6019 TestCachePolicyWebFrameClient mainClient(0); 6020 TestCachePolicyWebFrameClient mainClient(0);
6020 TestCachePolicyWebFrameClient childClient(&mainClient); 6021 TestCachePolicyWebFrameClient childClient(&mainClient);
6021 mainClient.setChildWebFrameClient(&childClient); 6022 mainClient.setChildWebFrameClient(&childClient);
6022 6023
6023 FrameTestHelpers::WebViewHelper webViewHelper(this); 6024 FrameTestHelpers::WebViewHelper webViewHelper(this);
6024 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai nClient); 6025 webViewHelper.initializeAndLoad(m_baseURL + "iframe_reload.html", true, &mai nClient);
6025 6026
6026 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl(); 6027 WebLocalFrameImpl* mainFrame = webViewHelper.webViewImpl()->mainFrameImpl();
6027 RawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC hild()); 6028 RawPtr<WebLocalFrameImpl> childFrame = toWebLocalFrameImpl(mainFrame->firstC hild());
6028 ASSERT_EQ(childFrame->client(), &childClient); 6029 ASSERT_EQ(childFrame->client(), &childClient);
6029 EXPECT_EQ(mainClient.childFrameCreationCount(), 1); 6030 EXPECT_EQ(mainClient.childFrameCreationCount(), 1);
6030 EXPECT_EQ(childClient.willSendRequestCallCount(), 1); 6031 EXPECT_EQ(childClient.willSendRequestCallCount(), 1);
6031 EXPECT_EQ(childClient.getCachePolicy(), WebURLRequest::UseProtocolCachePolic y); 6032 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::UseProtocolCachePoli cy);
6032 6033
6033 FrameTestHelpers::reloadFrame(mainFrame); 6034 FrameTestHelpers::reloadFrame(mainFrame);
6034 6035
6035 // A new WebFrame should have been created, but the child WebFrameClient sho uld be reused. 6036 // A new WebFrame should have been created, but the child WebFrameClient sho uld be reused.
6036 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild())); 6037 ASSERT_NE(childFrame, toWebLocalFrameImpl(mainFrame->firstChild()));
6037 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie nt); 6038 ASSERT_EQ(toWebLocalFrameImpl(mainFrame->firstChild())->client(), &childClie nt);
6038 6039
6039 EXPECT_EQ(mainClient.childFrameCreationCount(), 2); 6040 EXPECT_EQ(mainClient.childFrameCreationCount(), 2);
6040 EXPECT_EQ(childClient.willSendRequestCallCount(), 2); 6041 EXPECT_EQ(childClient.willSendRequestCallCount(), 2);
6041 EXPECT_EQ(childClient.getCachePolicy(), WebURLRequest::ValidatingCacheData); 6042 EXPECT_EQ(childClient.getCachePolicy(), WebCachePolicy::ValidatingCacheData) ;
6042 } 6043 }
6043 6044
6044 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie nt { 6045 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie nt {
6045 public: 6046 public:
6046 TestSameDocumentWebFrameClient() 6047 TestSameDocumentWebFrameClient()
6047 : m_frameLoadTypeSameSeen(false) 6048 : m_frameLoadTypeSameSeen(false)
6048 { 6049 {
6049 } 6050 }
6050 6051
6051 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&, const WebURLResponse&) 6052 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&, const WebURLResponse&)
(...skipping 27 matching lines...) Expand all
6079 public: 6080 public:
6080 TestSameDocumentWithImageWebFrameClient() 6081 TestSameDocumentWithImageWebFrameClient()
6081 : m_numOfImageRequests(0) 6082 : m_numOfImageRequests(0)
6082 { 6083 {
6083 } 6084 }
6084 6085
6085 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request, const WebURLResponse&) 6086 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request, const WebURLResponse&)
6086 { 6087 {
6087 if (request.getRequestContext() == WebURLRequest::RequestContextImage) { 6088 if (request.getRequestContext() == WebURLRequest::RequestContextImage) {
6088 m_numOfImageRequests++; 6089 m_numOfImageRequests++;
6089 EXPECT_EQ(WebURLRequest::UseProtocolCachePolicy, request.getCachePol icy()); 6090 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, request.getCachePo licy());
6090 } 6091 }
6091 } 6092 }
6092 6093
6093 int numOfImageRequests() const { return m_numOfImageRequests; } 6094 int numOfImageRequests() const { return m_numOfImageRequests; }
6094 6095
6095 private: 6096 private:
6096 int m_numOfImageRequests; 6097 int m_numOfImageRequests;
6097 }; 6098 };
6098 6099
6099 TEST_P(ParameterizedWebFrameTest, NavigateToSameNoConditionalRequestForSubresour ce) 6100 TEST_P(ParameterizedWebFrameTest, NavigateToSameNoConditionalRequestForSubresour ce)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
6201 6202
6202 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType) 6203 TEST_P(ParameterizedWebFrameTest, SameDocumentHistoryNavigationCommitType)
6203 { 6204 {
6204 registerMockedHttpURLLoad("push_state.html"); 6205 registerMockedHttpURLLoad("push_state.html");
6205 TestDidNavigateCommitTypeWebFrameClient client; 6206 TestDidNavigateCommitTypeWebFrameClient client;
6206 FrameTestHelpers::WebViewHelper webViewHelper(this); 6207 FrameTestHelpers::WebViewHelper webViewHelper(this);
6207 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push _state.html", true, &client); 6208 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "push _state.html", true, &client);
6208 Persistent<HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFrame() )->loader().currentItem(); 6209 Persistent<HistoryItem> item = toLocalFrame(webViewImpl->page()->mainFrame() )->loader().currentItem();
6209 runPendingTasks(); 6210 runPendingTasks();
6210 6211
6211 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load( 6212 toLocalFrame(webViewImpl->page()->mainFrame())->loader().load(FrameLoadReque st(nullptr, FrameLoader::resourceRequestFromHistoryItem(item.get(), WebCachePoli cy::UseProtocolCachePolicy)), FrameLoadTypeBackForward, item.get(), HistorySameD ocumentLoad);
6212 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
6213 item.get(), UseProtocolCachePolicy)),
6214 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad);
6215 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); 6213 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType());
6216 } 6214 }
6217 6215
6218 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 6216 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
6219 public: 6217 public:
6220 TestHistoryWebFrameClient() 6218 TestHistoryWebFrameClient()
6221 { 6219 {
6222 m_replacesCurrentHistoryItem = false; 6220 m_replacesCurrentHistoryItem = false;
6223 m_frame = nullptr; 6221 m_frame = nullptr;
6224 } 6222 }
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
6872 6870
6873 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache) 6871 TEST_P(ParameterizedWebFrameTest, ReloadBypassingCache)
6874 { 6872 {
6875 // Check that a reload ignoring cache on a frame will result in the cache 6873 // Check that a reload ignoring cache on a frame will result in the cache
6876 // policy of the request being set to ReloadBypassingCache. 6874 // policy of the request being set to ReloadBypassingCache.
6877 registerMockedHttpURLLoad("foo.html"); 6875 registerMockedHttpURLLoad("foo.html");
6878 FrameTestHelpers::WebViewHelper webViewHelper(this); 6876 FrameTestHelpers::WebViewHelper webViewHelper(this);
6879 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true); 6877 webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true);
6880 WebFrame* frame = webViewHelper.webView()->mainFrame(); 6878 WebFrame* frame = webViewHelper.webView()->mainFrame();
6881 FrameTestHelpers::reloadFrameIgnoringCache(frame); 6879 FrameTestHelpers::reloadFrameIgnoringCache(frame);
6882 EXPECT_EQ(WebURLRequest::BypassingCache, frame->dataSource()->request().getC achePolicy()); 6880 EXPECT_EQ(WebCachePolicy::BypassingCache, frame->dataSource()->request().get CachePolicy());
6883 } 6881 }
6884 6882
6885 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, DragImag e* dragImage) 6883 static void nodeImageTestValidation(const IntSize& referenceBitmapSize, DragImag e* dragImage)
6886 { 6884 {
6887 // Prepare the reference bitmap. 6885 // Prepare the reference bitmap.
6888 SkBitmap bitmap; 6886 SkBitmap bitmap;
6889 bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.heigh t()); 6887 bitmap.allocN32Pixels(referenceBitmapSize.width(), referenceBitmapSize.heigh t());
6890 SkCanvas canvas(bitmap); 6888 SkCanvas canvas(bitmap);
6891 canvas.drawColor(SK_ColorGREEN); 6889 canvas.drawColor(SK_ColorGREEN);
6892 6890
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after
8499 } 8497 }
8500 8498
8501 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) 8499 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange)
8502 { 8500 {
8503 swapLocalFrameToRemoteFrame(); 8501 swapLocalFrameToRemoteFrame();
8504 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';")); 8502 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';"));
8505 EXPECT_FALSE(remoteFrameClient()->isVisible()); 8503 EXPECT_FALSE(remoteFrameClient()->isVisible());
8506 } 8504 }
8507 8505
8508 } // namespace blink 8506 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698