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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 void registerMockedChromeURLLoad(const std::string& fileName) | 200 void registerMockedChromeURLLoad(const std::string& fileName) |
201 { | 201 { |
202 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); | 202 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); |
203 } | 203 } |
204 | 204 |
205 | 205 |
206 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, const std
::string& csp, bool reportOnly = false) | 206 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, const std
::string& csp, bool reportOnly = false) |
207 { | 207 { |
208 WebURLResponse response; | 208 WebURLResponse response; |
209 response.initialize(); | |
210 response.setMIMEType("text/html"); | 209 response.setMIMEType("text/html"); |
211 response.addHTTPHeaderField(reportOnly ? WebString("Content-Security-Pol
icy-Report-Only") : WebString("Content-Security-Policy"), WebString::fromUTF8(cs
p)); | 210 response.addHTTPHeaderField(reportOnly ? WebString("Content-Security-Pol
icy-Report-Only") : WebString("Content-Security-Policy"), WebString::fromUTF8(cs
p)); |
212 std::string fullString = m_baseURL + fileName; | 211 std::string fullString = m_baseURL + fileName; |
213 URLTestHelpers::registerMockedURLLoadWithCustomResponse(toKURL(fullStrin
g.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(""), resp
onse); | 212 URLTestHelpers::registerMockedURLLoadWithCustomResponse(toKURL(fullStrin
g.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(""), resp
onse); |
214 } | 213 } |
215 | 214 |
216 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, cons
t std::string& mimeType) | 215 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, cons
t std::string& mimeType) |
217 { | 216 { |
218 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType
)); | 217 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType
)); |
219 } | 218 } |
(...skipping 4845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5065 | 5064 |
5066 // Load a url as a history navigation that will return an error. TestSubstit
uteDataWebFrameClient | 5065 // Load a url as a history navigation that will return an error. TestSubstit
uteDataWebFrameClient |
5067 // will start a SubstituteData load in response to the load failure, which s
hould get fully committed. | 5066 // will start a SubstituteData load in response to the load failure, which s
hould get fully committed. |
5068 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec
eiveData() wasn't getting | 5067 // Due to https://bugs.webkit.org/show_bug.cgi?id=91685, FrameLoader::didRec
eiveData() wasn't getting |
5069 // called in this case, which resulted in the SubstituteData document not ge
tting displayed. | 5068 // called in this case, which resulted in the SubstituteData document not ge
tting displayed. |
5070 WebURLError error; | 5069 WebURLError error; |
5071 error.reason = 1337; | 5070 error.reason = 1337; |
5072 error.domain = "WebFrameTest"; | 5071 error.domain = "WebFrameTest"; |
5073 std::string errorURL = "http://0.0.0.0"; | 5072 std::string errorURL = "http://0.0.0.0"; |
5074 WebURLResponse response; | 5073 WebURLResponse response; |
5075 response.initialize(); | |
5076 response.setURL(URLTestHelpers::toKURL(errorURL)); | 5074 response.setURL(URLTestHelpers::toKURL(errorURL)); |
5077 response.setMIMEType("text/html"); | 5075 response.setMIMEType("text/html"); |
5078 response.setHTTPStatusCode(500); | 5076 response.setHTTPStatusCode(500); |
5079 WebHistoryItem errorHistoryItem; | 5077 WebHistoryItem errorHistoryItem; |
5080 errorHistoryItem.initialize(); | 5078 errorHistoryItem.initialize(); |
5081 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); | 5079 errorHistoryItem.setURLString(WebString::fromUTF8(errorURL.c_str(), errorURL
.length())); |
5082 Platform::current()->getURLLoaderMockFactory()->registerErrorURL(URLTestHelp
ers::toKURL(errorURL), response, error); | 5080 Platform::current()->getURLLoaderMockFactory()->registerErrorURL(URLTestHelp
ers::toKURL(errorURL), response, error); |
5083 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere
ntDocumentLoad, WebCachePolicy::UseProtocolCachePolicy); | 5081 FrameTestHelpers::loadHistoryItem(frame, errorHistoryItem, WebHistoryDiffere
ntDocumentLoad, WebCachePolicy::UseProtocolCachePolicy); |
5084 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); | 5082 WebString text = WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webV
iew(), std::numeric_limits<size_t>::max()); |
5085 EXPECT_EQ("This should appear", text.utf8()); | 5083 EXPECT_EQ("This should appear", text.utf8()); |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5711 | 5709 |
5712 TEST_P(ParameterizedWebFrameTest, FirstPartyForCookiesForRedirect) | 5710 TEST_P(ParameterizedWebFrameTest, FirstPartyForCookiesForRedirect) |
5713 { | 5711 { |
5714 String filePath = testing::blinkRootDir(); | 5712 String filePath = testing::blinkRootDir(); |
5715 filePath.append("/Source/web/tests/data/first_party.html"); | 5713 filePath.append("/Source/web/tests/data/first_party.html"); |
5716 | 5714 |
5717 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); | 5715 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); |
5718 char redirect[] = "http://internal.test/first_party.html"; | 5716 char redirect[] = "http://internal.test/first_party.html"; |
5719 WebURL redirectURL(toKURL(redirect)); | 5717 WebURL redirectURL(toKURL(redirect)); |
5720 WebURLResponse redirectResponse; | 5718 WebURLResponse redirectResponse; |
5721 redirectResponse.initialize(); | |
5722 redirectResponse.setMIMEType("text/html"); | 5719 redirectResponse.setMIMEType("text/html"); |
5723 redirectResponse.setHTTPStatusCode(302); | 5720 redirectResponse.setHTTPStatusCode(302); |
5724 redirectResponse.setHTTPHeaderField("Location", redirect); | 5721 redirectResponse.setHTTPHeaderField("Location", redirect); |
5725 Platform::current()->getURLLoaderMockFactory()->registerURL(testURL, redirec
tResponse, filePath); | 5722 Platform::current()->getURLLoaderMockFactory()->registerURL(testURL, redirec
tResponse, filePath); |
5726 | 5723 |
5727 WebURLResponse finalResponse; | 5724 WebURLResponse finalResponse; |
5728 finalResponse.initialize(); | |
5729 finalResponse.setMIMEType("text/html"); | 5725 finalResponse.setMIMEType("text/html"); |
5730 Platform::current()->getURLLoaderMockFactory()->registerURL(redirectURL, fin
alResponse, filePath); | 5726 Platform::current()->getURLLoaderMockFactory()->registerURL(redirectURL, fin
alResponse, filePath); |
5731 | 5727 |
5732 FrameTestHelpers::WebViewHelper webViewHelper(this); | 5728 FrameTestHelpers::WebViewHelper webViewHelper(this); |
5733 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru
e); | 5729 webViewHelper.initializeAndLoad(m_baseURL + "first_party_redirect.html", tru
e); |
5734 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo
okies() == redirectURL); | 5730 EXPECT_TRUE(webViewHelper.webView()->mainFrame()->document().firstPartyForCo
okies() == redirectURL); |
5735 } | 5731 } |
5736 | 5732 |
5737 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame
Client { | 5733 class TestNavigationPolicyWebFrameClient : public FrameTestHelpers::TestWebFrame
Client { |
5738 public: | 5734 public: |
(...skipping 2959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8698 ASSERT_FALSE(grandchildFrame->canHaveSecureChild()); | 8694 ASSERT_FALSE(grandchildFrame->canHaveSecureChild()); |
8699 Document* mainDocument = mainFrame->document(); | 8695 Document* mainDocument = mainFrame->document(); |
8700 Document* childDocument = childFrame->document(); | 8696 Document* childDocument = childFrame->document(); |
8701 Document* grandchildDocument = grandchildFrame->document(); | 8697 Document* grandchildDocument = grandchildFrame->document(); |
8702 ASSERT_FALSE(mainDocument->isSecureContext()); | 8698 ASSERT_FALSE(mainDocument->isSecureContext()); |
8703 ASSERT_TRUE(childDocument->isSecureContext()); | 8699 ASSERT_TRUE(childDocument->isSecureContext()); |
8704 ASSERT_FALSE(grandchildDocument->isSecureContext()); | 8700 ASSERT_FALSE(grandchildDocument->isSecureContext()); |
8705 } | 8701 } |
8706 | 8702 |
8707 } // namespace blink | 8703 } // namespace blink |
OLD | NEW |