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

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

Issue 2117313002: Remove WebURLResponse::initialize() [revised] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanups Created 4 years, 5 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 void registerMockedChromeURLLoad(const std::string& fileName) 202 void registerMockedChromeURLLoad(const std::string& fileName)
203 { 203 {
204 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom eURL.c_str()), WebString::fromUTF8(fileName.c_str())); 204 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom eURL.c_str()), WebString::fromUTF8(fileName.c_str()));
205 } 205 }
206 206
207 207
208 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, const std ::string& csp, bool reportOnly = false) 208 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, const std ::string& csp, bool reportOnly = false)
209 { 209 {
210 WebURLResponse response; 210 WebURLResponse response;
211 response.initialize();
212 response.setMIMEType("text/html"); 211 response.setMIMEType("text/html");
213 response.addHTTPHeaderField(reportOnly ? WebString("Content-Security-Pol icy-Report-Only") : WebString("Content-Security-Policy"), WebString::fromUTF8(cs p)); 212 response.addHTTPHeaderField(reportOnly ? WebString("Content-Security-Pol icy-Report-Only") : WebString("Content-Security-Policy"), WebString::fromUTF8(cs p));
214 std::string fullString = m_baseURL + fileName; 213 std::string fullString = m_baseURL + fileName;
215 URLTestHelpers::registerMockedURLLoadWithCustomResponse(toKURL(fullStrin g.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(""), resp onse); 214 URLTestHelpers::registerMockedURLLoadWithCustomResponse(toKURL(fullStrin g.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(""), resp onse);
216 } 215 }
217 216
218 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, cons t std::string& mimeType) 217 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, cons t std::string& mimeType)
219 { 218 {
220 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType )); 219 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType ));
221 } 220 }
(...skipping 4845 matching lines...) Expand 10 before | Expand all | Expand 10 after
5067 5066
5068 // Load a url as a history navigation that will return an error. TestSubstit uteDataWebFrameClient 5067 // Load a url as a history navigation that will return an error. TestSubstit uteDataWebFrameClient
5069 // will start a SubstituteData load in response to the load failure, which s hould get fully committed. 5068 // will start a SubstituteData load in response to the load failure, which s hould get fully committed.
5070 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec eiveData() wasn't getting 5069 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec eiveData() wasn't getting
5071 // called in this case, which resulted in the SubstituteData document not ge tting displayed. 5070 // called in this case, which resulted in the SubstituteData document not ge tting displayed.
5072 WebURLError error; 5071 WebURLError error;
5073 error.reason = 1337; 5072 error.reason = 1337;
5074 error.domain = "WebFrameTest"; 5073 error.domain = "WebFrameTest";
5075 std::string errorURL = "http://0.0.0.0"; 5074 std::string errorURL = "http://0.0.0.0";
5076 WebURLResponse response; 5075 WebURLResponse response;
5077 response.initialize();
5078 response.setURL(URLTestHelpers::toKURL(errorURL)); 5076 response.setURL(URLTestHelpers::toKURL(errorURL));
5079 response.setMIMEType("text/html"); 5077 response.setMIMEType("text/html");
5080 response.setHTTPStatusCode(500); 5078 response.setHTTPStatusCode(500);
5081 WebHistoryItem errorHistoryItem; 5079 WebHistoryItem errorHistoryItem;
5082 errorHistoryItem.initialize(); 5080 errorHistoryItem.initialize();
5083 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL .length())); 5081 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL .length()));
5084 Platform::current()->getURLLoaderMockFactory()->registerErrorURL(URLTestHelp ers::toKURL(errorURL), response, error); 5082 Platform::current()->getURLLoaderMockFactory()->registerErrorURL(URLTestHelp ers::toKURL(errorURL), response, error);
5085 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere ntDocumentLoad, WebCachePolicy::UseProtocolCachePolicy); 5083 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere ntDocumentLoad, WebCachePolicy::UseProtocolCachePolicy);
5086 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max()); 5084 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV iew(), std::numeric_limits<size_t>::max());
5087 EXPECT_EQ("This should appear", text.utf8()); 5085 EXPECT_EQ("This should appear", text.utf8());
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
5713 5711
5714 TEST_P(ParameterizedWebFrameTest, FirstPartyForCookiesForRedirect) 5712 TEST_P(ParameterizedWebFrameTest, FirstPartyForCookiesForRedirect)
5715 { 5713 {
5716 String filePath = testing::blinkRootDir(); 5714 String filePath = testing::blinkRootDir();
5717 filePath.append("/Source/web/tests/data/first_party.html"); 5715 filePath.append("/Source/web/tests/data/first_party.html");
5718 5716
5719 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); 5717 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html"));
5720 char redirect[] = "http://internal.test/first_party.html"; 5718 char redirect[] = "http://internal.test/first_party.html";
5721 WebURL redirectURL(toKURL(redirect)); 5719 WebURL redirectURL(toKURL(redirect));
5722 WebURLResponse redirectResponse; 5720 WebURLResponse redirectResponse;
5723 redirectResponse.initialize();
5724 redirectResponse.setMIMEType("text/html"); 5721 redirectResponse.setMIMEType("text/html");
5725 redirectResponse.setHTTPStatusCode(302); 5722 redirectResponse.setHTTPStatusCode(302);
5726 redirectResponse.setHTTPHeaderField("Location", redirect); 5723 redirectResponse.setHTTPHeaderField("Location", redirect);
5727 Platform::current()->getURLLoaderMockFactory()->registerURL(testURL, redirec tResponse, filePath); 5724 Platform::current()->getURLLoaderMockFactory()->registerURL(testURL, redirec tResponse, filePath);
5728 5725
5729 WebURLResponse finalResponse; 5726 WebURLResponse finalResponse;
5730 finalResponse.initialize();
5731 finalResponse.setMIMEType("text/html"); 5727 finalResponse.setMIMEType("text/html");
5732 Platform::current()->getURLLoaderMockFactory()->registerURL(redirectURL, fin alResponse, filePath); 5728 Platform::current()->getURLLoaderMockFactory()->registerURL(redirectURL, fin alResponse, filePath);
5733 5729
5734 FrameTestHelpers::WebViewHelper webViewHelper(this); 5730 FrameTestHelpers::WebViewHelper webViewHelper(this);
5735 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru e); 5731 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru e);
5736 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo okies() == redirectURL); 5732 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo okies() == redirectURL);
5737 } 5733 }
5738 5734
5739 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame Client { 5735 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame Client {
5740 public: 5736 public:
(...skipping 3073 matching lines...) Expand 10 before | Expand all | Expand 10 after
8814 request.setURL(toKURL("javascript:location='" + redirectURL + "'")); 8810 request.setURL(toKURL("javascript:location='" + redirectURL + "'"));
8815 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); 8811 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request);
8816 8812
8817 // Normally, the result of the JS url replaces the existing contents on the 8813 // Normally, the result of the JS url replaces the existing contents on the
8818 // Document. However, if the JS triggers a navigation, the contents should 8814 // Document. However, if the JS triggers a navigation, the contents should
8819 // not be replaced. 8815 // not be replaced.
8820 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum ent()->documentElement()->innerText()); 8816 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum ent()->documentElement()->innerText());
8821 } 8817 }
8822 8818
8823 } // namespace blink 8819 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698