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

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

Issue 1371673002: Remove a bunch of provisionalDataSource() usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 #include "public/web/WebScriptExecutionCallback.h" 110 #include "public/web/WebScriptExecutionCallback.h"
111 #include "public/web/WebScriptSource.h" 111 #include "public/web/WebScriptSource.h"
112 #include "public/web/WebSearchableFormData.h" 112 #include "public/web/WebSearchableFormData.h"
113 #include "public/web/WebSecurityPolicy.h" 113 #include "public/web/WebSecurityPolicy.h"
114 #include "public/web/WebSelection.h" 114 #include "public/web/WebSelection.h"
115 #include "public/web/WebSettings.h" 115 #include "public/web/WebSettings.h"
116 #include "public/web/WebSpellCheckClient.h" 116 #include "public/web/WebSpellCheckClient.h"
117 #include "public/web/WebTextCheckingCompletion.h" 117 #include "public/web/WebTextCheckingCompletion.h"
118 #include "public/web/WebTextCheckingResult.h" 118 #include "public/web/WebTextCheckingResult.h"
119 #include "public/web/WebViewClient.h" 119 #include "public/web/WebViewClient.h"
120 #include "web/WebDataSourceImpl.h"
120 #include "web/WebLocalFrameImpl.h" 121 #include "web/WebLocalFrameImpl.h"
121 #include "web/WebRemoteFrameImpl.h" 122 #include "web/WebRemoteFrameImpl.h"
122 #include "web/WebViewImpl.h" 123 #include "web/WebViewImpl.h"
123 #include "web/tests/FrameTestHelpers.h" 124 #include "web/tests/FrameTestHelpers.h"
124 #include "wtf/Forward.h" 125 #include "wtf/Forward.h"
125 #include "wtf/dtoa/utils.h" 126 #include "wtf/dtoa/utils.h"
126 #include <gmock/gmock.h> 127 #include <gmock/gmock.h>
127 #include <gtest/gtest.h> 128 #include <gtest/gtest.h>
128 #include <map> 129 #include <map>
129 #include <stdarg.h> 130 #include <stdarg.h>
(...skipping 4889 matching lines...) Expand 10 before | Expand all | Expand 10 after
5019 5020
5020 client.resetTriggered(); 5021 client.resetTriggered();
5021 webViewHelper.webView()->handleInputEvent(fatTap(690, 570)); 5022 webViewHelper.webView()->handleInputEvent(fatTap(690, 570));
5022 EXPECT_FALSE(client.triggered()); 5023 EXPECT_FALSE(client.triggered());
5023 } 5024 }
5024 5025
5025 class TestSubstituteDataWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient { 5026 class TestSubstituteDataWebFrameClient : public FrameTestHelpers::TestWebFrameCl ient {
5026 public: 5027 public:
5027 TestSubstituteDataWebFrameClient() 5028 TestSubstituteDataWebFrameClient()
5028 : m_commitCalled(false) 5029 : m_commitCalled(false)
5030 , m_frame(nullptr)
5029 { 5031 {
5030 } 5032 }
5031 5033
5032 virtual void didFailProvisionalLoad(WebLocalFrame* frame, const WebURLError& error, WebHistoryCommitType) 5034 virtual void didFailProvisionalLoad(WebDataSource*, const WebURLError& error , WebHistoryCommitType)
5033 { 5035 {
5034 frame->loadHTMLString("This should appear", toKURL("data:text/html,chrom ewebdata"), error.unreachableURL, true); 5036 m_frame->loadHTMLString("This should appear", toKURL("data:text/html,chr omewebdata"), error.unreachableURL, true);
5035 } 5037 }
5036 5038
5037 virtual void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistory Item&, WebHistoryCommitType) 5039 virtual void didCommitProvisionalLoad(WebLocalFrame* frame, const WebHistory Item&, WebHistoryCommitType)
5038 { 5040 {
5039 if (frame->dataSource()->response().url() != WebURL(URLTestHelpers::toKU RL("about:blank"))) 5041 if (frame->dataSource()->response().url() != WebURL(URLTestHelpers::toKU RL("about:blank")))
5040 m_commitCalled = true; 5042 m_commitCalled = true;
5041 } 5043 }
5042 5044
5043 bool commitCalled() const { return m_commitCalled; } 5045 bool commitCalled() const { return m_commitCalled; }
5046 void setFrame(WebLocalFrame* frame) { m_frame = frame; }
5044 5047
5045 private: 5048 private:
5046 bool m_commitCalled; 5049 bool m_commitCalled;
5050 WebLocalFrame* m_frame;
5047 }; 5051 };
5048 5052
5049 TEST_P(ParameterizedWebFrameTest, ReplaceNavigationAfterHistoryNavigation) 5053 TEST_P(ParameterizedWebFrameTest, ReplaceNavigationAfterHistoryNavigation)
5050 { 5054 {
5051 TestSubstituteDataWebFrameClient webFrameClient; 5055 TestSubstituteDataWebFrameClient webFrameClient;
5052 5056
5053 FrameTestHelpers::WebViewHelper webViewHelper(this); 5057 FrameTestHelpers::WebViewHelper webViewHelper(this);
5054 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient); 5058 webViewHelper.initializeAndLoad("about:blank", true, &webFrameClient);
5055 WebFrame* frame = webViewHelper.webView()->mainFrame(); 5059 WebFrame* frame = webViewHelper.webView()->mainFrame();
5060 webFrameClient.setFrame(frame->toWebLocalFrame());
5056 5061
5057 // Load a url as a history navigation that will return an error. TestSubstit uteDataWebFrameClient 5062 // Load a url as a history navigation that will return an error. TestSubstit uteDataWebFrameClient
5058 // will start a SubstituteData load in response to the load failure, which s hould get fully committed. 5063 // will start a SubstituteData load in response to the load failure, which s hould get fully committed.
5059 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec eiveData() wasn't getting 5064 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec eiveData() wasn't getting
5060 // called in this case, which resulted in the SubstituteData document not ge tting displayed. 5065 // called in this case, which resulted in the SubstituteData document not ge tting displayed.
5061 WebURLError error; 5066 WebURLError error;
5062 error.reason = 1337; 5067 error.reason = 1337;
5063 error.domain = "WebFrameTest"; 5068 error.domain = "WebFrameTest";
5064 std::string errorURL = "http://0.0.0.0"; 5069 std::string errorURL = "http://0.0.0.0";
5065 WebURLResponse response; 5070 WebURLResponse response;
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
5942 5947
5943 virtual void didStopLoading() 5948 virtual void didStopLoading()
5944 { 5949 {
5945 if (m_parentClient) { 5950 if (m_parentClient) {
5946 m_parentClient->didStopLoading(); 5951 m_parentClient->didStopLoading();
5947 return; 5952 return;
5948 } 5953 }
5949 TestWebFrameClient::didStopLoading(); 5954 TestWebFrameClient::didStopLoading();
5950 } 5955 }
5951 5956
5952 void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request, const WebURLResponse&) override 5957 void willSendRequest(WebDataSource*, unsigned, WebURLRequest& request, const WebURLResponse&) override
5953 { 5958 {
5954 m_policy = request.cachePolicy(); 5959 m_policy = request.cachePolicy();
5955 m_willSendRequestCallCount++; 5960 m_willSendRequestCallCount++;
5956 } 5961 }
5957 5962
5958 private: 5963 private:
5959 TestCachePolicyWebFrameClient* m_parentClient; 5964 TestCachePolicyWebFrameClient* m_parentClient;
5960 5965
5961 WebURLRequest::CachePolicy m_policy; 5966 WebURLRequest::CachePolicy m_policy;
5962 TestCachePolicyWebFrameClient* m_childClient; 5967 TestCachePolicyWebFrameClient* m_childClient;
(...skipping 30 matching lines...) Expand all
5993 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData) ; 5998 EXPECT_EQ(childClient.cachePolicy(), WebURLRequest::ReloadIgnoringCacheData) ;
5994 } 5999 }
5995 6000
5996 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie nt { 6001 class TestSameDocumentWebFrameClient : public FrameTestHelpers::TestWebFrameClie nt {
5997 public: 6002 public:
5998 TestSameDocumentWebFrameClient() 6003 TestSameDocumentWebFrameClient()
5999 : m_frameLoadTypeSameSeen(false) 6004 : m_frameLoadTypeSameSeen(false)
6000 { 6005 {
6001 } 6006 }
6002 6007
6003 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest&, const WebURLResponse&) 6008 virtual void willSendRequest(WebDataSource* dataSource, unsigned, WebURLRequ est&, const WebURLResponse&)
6004 { 6009 {
6005 if (toWebLocalFrameImpl(frame)->frame()->loader().loadType() == FrameLoa dTypeSame) 6010 if (static_cast<WebDataSourceImpl*>(dataSource)->frame()->loader().loadT ype() == FrameLoadTypeSame)
6006 m_frameLoadTypeSameSeen = true; 6011 m_frameLoadTypeSameSeen = true;
6007 } 6012 }
6008 6013
6009 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; } 6014 bool frameLoadTypeSameSeen() const { return m_frameLoadTypeSameSeen; }
6010 6015
6011 private: 6016 private:
6012 bool m_frameLoadTypeSameSeen; 6017 bool m_frameLoadTypeSameSeen;
6013 }; 6018 };
6014 6019
6015 TEST_P(ParameterizedWebFrameTest, NavigateToSame) 6020 TEST_P(ParameterizedWebFrameTest, NavigateToSame)
(...skipping 11 matching lines...) Expand all
6027 EXPECT_TRUE(client.frameLoadTypeSameSeen()); 6032 EXPECT_TRUE(client.frameLoadTypeSameSeen());
6028 } 6033 }
6029 6034
6030 class TestSameDocumentWithImageWebFrameClient : public FrameTestHelpers::TestWeb FrameClient { 6035 class TestSameDocumentWithImageWebFrameClient : public FrameTestHelpers::TestWeb FrameClient {
6031 public: 6036 public:
6032 TestSameDocumentWithImageWebFrameClient() 6037 TestSameDocumentWithImageWebFrameClient()
6033 : m_numOfImageRequests(0) 6038 : m_numOfImageRequests(0)
6034 { 6039 {
6035 } 6040 }
6036 6041
6037 virtual void willSendRequest(WebLocalFrame* frame, unsigned, WebURLRequest& request, const WebURLResponse&) 6042 virtual void willSendRequest(WebDataSource*, unsigned, WebURLRequest& reques t, const WebURLResponse&)
6038 { 6043 {
6039 if (request.requestContext() == WebURLRequest::RequestContextImage) { 6044 if (request.requestContext() == WebURLRequest::RequestContextImage) {
6040 m_numOfImageRequests++; 6045 m_numOfImageRequests++;
6041 EXPECT_EQ(WebURLRequest::UseProtocolCachePolicy, request.cachePolicy ()); 6046 EXPECT_EQ(WebURLRequest::UseProtocolCachePolicy, request.cachePolicy ());
6042 } 6047 }
6043 } 6048 }
6044 6049
6045 int numOfImageRequests() const { return m_numOfImageRequests; } 6050 int numOfImageRequests() const { return m_numOfImageRequests; }
6046 6051
6047 private: 6052 private:
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
6165 item.get(), UseProtocolCachePolicy)), 6170 item.get(), UseProtocolCachePolicy)),
6166 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad); 6171 FrameLoadTypeBackForward, item.get(), HistorySameDocumentLoad);
6167 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType()); 6172 EXPECT_EQ(WebBackForwardCommit, client.lastCommitType());
6168 } 6173 }
6169 6174
6170 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient { 6175 class TestHistoryWebFrameClient : public FrameTestHelpers::TestWebFrameClient {
6171 public: 6176 public:
6172 TestHistoryWebFrameClient() 6177 TestHistoryWebFrameClient()
6173 { 6178 {
6174 m_replacesCurrentHistoryItem = false; 6179 m_replacesCurrentHistoryItem = false;
6175 m_frame = nullptr;
6176 } 6180 }
6177 6181
6178 void didStartProvisionalLoad(WebLocalFrame* frame, double) 6182 void didStartProvisionalLoad(WebDataSource* ds, double)
6179 { 6183 {
6180 WebDataSource* ds = frame->provisionalDataSource();
6181 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem(); 6184 m_replacesCurrentHistoryItem = ds->replacesCurrentHistoryItem();
6182 m_frame = frame;
6183 } 6185 }
6184 6186
6185 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; } 6187 bool replacesCurrentHistoryItem() { return m_replacesCurrentHistoryItem; }
6186 WebFrame* frame() { return m_frame; }
6187 6188
6188 private: 6189 private:
6189 bool m_replacesCurrentHistoryItem; 6190 bool m_replacesCurrentHistoryItem;
6190 WebFrame* m_frame;
6191 }; 6191 };
6192 6192
6193 // Tests that the first navigation in an initially blank subframe will result in 6193 // Tests that the first navigation in an initially blank subframe will result in
6194 // a history entry being replaced and not a new one being added. 6194 // a history entry being replaced and not a new one being added.
6195 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation) 6195 TEST_P(ParameterizedWebFrameTest, FirstBlankSubframeNavigation)
6196 { 6196 {
6197 registerMockedHttpURLLoad("history.html"); 6197 registerMockedHttpURLLoad("history.html");
6198 registerMockedHttpURLLoad("find.html"); 6198 registerMockedHttpURLLoad("find.html");
6199 6199
6200 FrameTestHelpers::WebViewHelper webViewHelper(this); 6200 FrameTestHelpers::WebViewHelper webViewHelper(this);
6201 TestHistoryWebFrameClient client; 6201 TestHistoryWebFrameClient client;
6202 webViewHelper.initializeAndLoad("about:blank", true, &client); 6202 webViewHelper.initializeAndLoad("about:blank", true, &client);
6203 6203
6204 WebFrame* frame = webViewHelper.webView()->mainFrame(); 6204 WebFrame* frame = webViewHelper.webView()->mainFrame();
6205 6205
6206 frame->executeScript(WebScriptSource(WebString::fromUTF8( 6206 frame->executeScript(WebScriptSource(WebString::fromUTF8(
6207 "document.body.appendChild(document.createElement('iframe'))"))); 6207 "document.body.appendChild(document.createElement('iframe'))")));
6208 6208
6209 WebFrame* iframe = frame->firstChild(); 6209 WebFrame* iframe = frame->firstChild();
6210 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client()); 6210 ASSERT_EQ(&client, toWebLocalFrameImpl(iframe)->client());
6211 EXPECT_EQ(iframe, client.frame());
6212 6211
6213 std::string url1 = m_baseURL + "history.html"; 6212 std::string url1 = m_baseURL + "history.html";
6214 FrameTestHelpers::loadFrame(iframe, url1); 6213 FrameTestHelpers::loadFrame(iframe, url1);
6215 EXPECT_EQ(iframe, client.frame());
6216 EXPECT_EQ(url1, iframe->document().url().string().utf8()); 6214 EXPECT_EQ(url1, iframe->document().url().string().utf8());
6217 EXPECT_TRUE(client.replacesCurrentHistoryItem()); 6215 EXPECT_TRUE(client.replacesCurrentHistoryItem());
6218 6216
6219 std::string url2 = m_baseURL + "find.html"; 6217 std::string url2 = m_baseURL + "find.html";
6220 FrameTestHelpers::loadFrame(iframe, url2); 6218 FrameTestHelpers::loadFrame(iframe, url2);
6221 EXPECT_EQ(iframe, client.frame());
6222 EXPECT_EQ(url2, iframe->document().url().string().utf8()); 6219 EXPECT_EQ(url2, iframe->document().url().string().utf8());
6223 EXPECT_FALSE(client.replacesCurrentHistoryItem()); 6220 EXPECT_FALSE(client.replacesCurrentHistoryItem());
6224 } 6221 }
6225 6222
6226 // Tests that a navigation in a frame with a non-blank initial URL will create 6223 // Tests that a navigation in a frame with a non-blank initial URL will create
6227 // a new history item, unlike the case above. 6224 // a new history item, unlike the case above.
6228 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation) 6225 TEST_P(ParameterizedWebFrameTest, FirstNonBlankSubframeNavigation)
6229 { 6226 {
6230 registerMockedHttpURLLoad("history.html"); 6227 registerMockedHttpURLLoad("history.html");
6231 registerMockedHttpURLLoad("find.html"); 6228 registerMockedHttpURLLoad("find.html");
6232 6229
6233 FrameTestHelpers::WebViewHelper webViewHelper(this); 6230 FrameTestHelpers::WebViewHelper webViewHelper(this);
6234 TestHistoryWebFrameClient client; 6231 TestHistoryWebFrameClient client;
6235 webViewHelper.initializeAndLoad("about:blank", true, &client); 6232 webViewHelper.initializeAndLoad("about:blank", true, &client);
6236 6233
6237 WebFrame* frame = webViewHelper.webView()->mainFrame(); 6234 WebFrame* frame = webViewHelper.webView()->mainFrame();
6238 6235
6239 std::string url1 = m_baseURL + "history.html"; 6236 std::string url1 = m_baseURL + "history.html";
6240 FrameTestHelpers::loadFrame(frame, 6237 FrameTestHelpers::loadFrame(frame,
6241 "javascript:var f = document.createElement('iframe'); " 6238 "javascript:var f = document.createElement('iframe'); "
6242 "f.src = '" + url1 + "';" 6239 "f.src = '" + url1 + "';"
6243 "document.body.appendChild(f)"); 6240 "document.body.appendChild(f)");
6244 6241
6245 WebFrame* iframe = frame->firstChild(); 6242 WebFrame* iframe = frame->firstChild();
6246 EXPECT_EQ(iframe, client.frame());
6247 EXPECT_EQ(url1, iframe->document().url().string().utf8()); 6243 EXPECT_EQ(url1, iframe->document().url().string().utf8());
6248 6244
6249 std::string url2 = m_baseURL + "find.html"; 6245 std::string url2 = m_baseURL + "find.html";
6250 FrameTestHelpers::loadFrame(iframe, url2); 6246 FrameTestHelpers::loadFrame(iframe, url2);
6251 EXPECT_EQ(iframe, client.frame());
6252 EXPECT_EQ(url2, iframe->document().url().string().utf8()); 6247 EXPECT_EQ(url2, iframe->document().url().string().utf8());
6253 EXPECT_FALSE(client.replacesCurrentHistoryItem()); 6248 EXPECT_FALSE(client.replacesCurrentHistoryItem());
6254 } 6249 }
6255 6250
6256 // Test verifies that layout will change a layer's scrollable attibutes 6251 // Test verifies that layout will change a layer's scrollable attibutes
6257 TEST_F(WebFrameTest, overflowHiddenRewrite) 6252 TEST_F(WebFrameTest, overflowHiddenRewrite)
6258 { 6253 {
6259 registerMockedHttpURLLoad("non-scrollable.html"); 6254 registerMockedHttpURLLoad("non-scrollable.html");
6260 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr (new FakeCompositingWebViewClient()); 6255 OwnPtr<FakeCompositingWebViewClient> fakeCompositingWebViewClient = adoptPtr (new FakeCompositingWebViewClient());
6261 FrameTestHelpers::WebViewHelper webViewHelper; 6256 FrameTestHelpers::WebViewHelper webViewHelper;
(...skipping 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after
8216 8211
8217 TEST_F(WebFrameTest, MaxFramesDetach) 8212 TEST_F(WebFrameTest, MaxFramesDetach)
8218 { 8213 {
8219 registerMockedHttpURLLoad("max-frames-detach.html"); 8214 registerMockedHttpURLLoad("max-frames-detach.html");
8220 FrameTestHelpers::WebViewHelper webViewHelper; 8215 FrameTestHelpers::WebViewHelper webViewHelper;
8221 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 8216 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
8222 webViewImpl->mainFrameImpl()->collectGarbage(); 8217 webViewImpl->mainFrameImpl()->collectGarbage();
8223 } 8218 }
8224 8219
8225 } // namespace blink 8220 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp ('k') | third_party/WebKit/public/web/WebFrameClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698