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

Side by Side Diff: third_party/WebKit/Source/platform/network/ResourceRequestTest.cpp

Issue 2053693002: WIP: Move 'Upgrade-Insecure-Requests' to the browser process. Base URL: https://chromium.googlesource.com/chromium/src.git@replicate
Patch Set: Rebase. :( Created 3 years, 9 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/network/ResourceRequest.h" 5 #include "platform/network/ResourceRequest.h"
6 6
7 #include <memory>
7 #include "platform/network/EncodedFormData.h" 8 #include "platform/network/EncodedFormData.h"
8 #include "platform/weborigin/KURL.h" 9 #include "platform/weborigin/KURL.h"
9 #include "platform/weborigin/Referrer.h" 10 #include "platform/weborigin/Referrer.h"
10 #include "public/platform/WebCachePolicy.h" 11 #include "public/platform/WebCachePolicy.h"
12 #include "public/platform/WebInsecureRequestPolicy.h"
11 #include "public/platform/WebURLRequest.h" 13 #include "public/platform/WebURLRequest.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 #include "wtf/text/AtomicString.h" 15 #include "wtf/text/AtomicString.h"
14 #include <memory>
15 16
16 namespace blink { 17 namespace blink {
17 18
18 TEST(ResourceRequestTest, RequestorOriginNonNull) { 19 TEST(ResourceRequestTest, RequestorOriginNonNull) {
19 ResourceRequest req; 20 ResourceRequest req;
20 EXPECT_NE(nullptr, req.requestorOrigin().get()); 21 EXPECT_NE(nullptr, req.requestorOrigin().get());
21 EXPECT_TRUE(req.requestorOrigin()->isUnique()); 22 EXPECT_TRUE(req.requestorOrigin()->isUnique());
22 } 23 }
23 24
24 TEST(ResourceRequestTest, CrossThreadResourceRequestData) { 25 TEST(ResourceRequestTest, CrossThreadResourceRequestData) {
(...skipping 20 matching lines...) Expand all
45 original.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS); 46 original.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS);
46 original.setFetchCredentialsMode( 47 original.setFetchCredentialsMode(
47 WebURLRequest::FetchCredentialsModeSameOrigin); 48 WebURLRequest::FetchCredentialsModeSameOrigin);
48 original.setRequestorID(30); 49 original.setRequestorID(30);
49 original.setRequestorProcessID(40); 50 original.setRequestorProcessID(40);
50 original.setAppCacheHostID(50); 51 original.setAppCacheHostID(50);
51 original.setRequestContext(WebURLRequest::RequestContextAudio); 52 original.setRequestContext(WebURLRequest::RequestContextAudio);
52 original.setFrameType(WebURLRequest::FrameTypeNested); 53 original.setFrameType(WebURLRequest::FrameTypeNested);
53 original.setHTTPReferrer( 54 original.setHTTPReferrer(
54 Referrer("http://www.example.com/referrer.htm", ReferrerPolicyDefault)); 55 Referrer("http://www.example.com/referrer.htm", ReferrerPolicyDefault));
56 original.setInsecureRequestPolicy(kUpgradeInsecureRequests);
55 57
56 EXPECT_STREQ("http://www.example.com/test.htm", 58 EXPECT_STREQ("http://www.example.com/test.htm",
57 original.url().getString().utf8().data()); 59 original.url().getString().utf8().data());
58 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, original.getCachePolicy()); 60 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, original.getCachePolicy());
59 EXPECT_EQ(10, original.timeoutInterval()); 61 EXPECT_EQ(10, original.timeoutInterval());
60 EXPECT_STREQ("http://www.example.com/first_party.htm", 62 EXPECT_STREQ("http://www.example.com/first_party.htm",
61 original.firstPartyForCookies().getString().utf8().data()); 63 original.firstPartyForCookies().getString().utf8().data());
62 EXPECT_STREQ("www.example.com", 64 EXPECT_STREQ("www.example.com",
63 original.requestorOrigin()->host().utf8().data()); 65 original.requestorOrigin()->host().utf8().data());
64 EXPECT_STREQ("GET", original.httpMethod().utf8().data()); 66 EXPECT_STREQ("GET", original.httpMethod().utf8().data());
(...skipping 12 matching lines...) Expand all
77 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, 79 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin,
78 original.fetchCredentialsMode()); 80 original.fetchCredentialsMode());
79 EXPECT_EQ(30, original.requestorID()); 81 EXPECT_EQ(30, original.requestorID());
80 EXPECT_EQ(40, original.requestorProcessID()); 82 EXPECT_EQ(40, original.requestorProcessID());
81 EXPECT_EQ(50, original.appCacheHostID()); 83 EXPECT_EQ(50, original.appCacheHostID());
82 EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext()); 84 EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext());
83 EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType()); 85 EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType());
84 EXPECT_STREQ("http://www.example.com/referrer.htm", 86 EXPECT_STREQ("http://www.example.com/referrer.htm",
85 original.httpReferrer().utf8().data()); 87 original.httpReferrer().utf8().data());
86 EXPECT_EQ(ReferrerPolicyDefault, original.getReferrerPolicy()); 88 EXPECT_EQ(ReferrerPolicyDefault, original.getReferrerPolicy());
89 EXPECT_EQ(kUpgradeInsecureRequests, original.getInsecureRequestPolicy());
87 90
88 std::unique_ptr<CrossThreadResourceRequestData> data1(original.copyData()); 91 std::unique_ptr<CrossThreadResourceRequestData> data1(original.copyData());
89 ResourceRequest copy1(data1.get()); 92 ResourceRequest copy1(data1.get());
90 93
91 EXPECT_STREQ("http://www.example.com/test.htm", 94 EXPECT_STREQ("http://www.example.com/test.htm",
92 copy1.url().getString().utf8().data()); 95 copy1.url().getString().utf8().data());
93 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, copy1.getCachePolicy()); 96 EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, copy1.getCachePolicy());
94 EXPECT_EQ(10, copy1.timeoutInterval()); 97 EXPECT_EQ(10, copy1.timeoutInterval());
95 EXPECT_STREQ("http://www.example.com/first_party.htm", 98 EXPECT_STREQ("http://www.example.com/first_party.htm",
96 copy1.firstPartyForCookies().getString().utf8().data()); 99 copy1.firstPartyForCookies().getString().utf8().data());
(...skipping 12 matching lines...) Expand all
109 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, 112 EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin,
110 copy1.fetchCredentialsMode()); 113 copy1.fetchCredentialsMode());
111 EXPECT_EQ(30, copy1.requestorID()); 114 EXPECT_EQ(30, copy1.requestorID());
112 EXPECT_EQ(40, copy1.requestorProcessID()); 115 EXPECT_EQ(40, copy1.requestorProcessID());
113 EXPECT_EQ(50, copy1.appCacheHostID()); 116 EXPECT_EQ(50, copy1.appCacheHostID());
114 EXPECT_EQ(WebURLRequest::RequestContextAudio, copy1.requestContext()); 117 EXPECT_EQ(WebURLRequest::RequestContextAudio, copy1.requestContext());
115 EXPECT_EQ(WebURLRequest::FrameTypeNested, copy1.frameType()); 118 EXPECT_EQ(WebURLRequest::FrameTypeNested, copy1.frameType());
116 EXPECT_STREQ("http://www.example.com/referrer.htm", 119 EXPECT_STREQ("http://www.example.com/referrer.htm",
117 copy1.httpReferrer().utf8().data()); 120 copy1.httpReferrer().utf8().data());
118 EXPECT_EQ(ReferrerPolicyDefault, copy1.getReferrerPolicy()); 121 EXPECT_EQ(ReferrerPolicyDefault, copy1.getReferrerPolicy());
122 EXPECT_EQ(kUpgradeInsecureRequests, copy1.getInsecureRequestPolicy());
119 123
120 copy1.setAllowStoredCredentials(true); 124 copy1.setAllowStoredCredentials(true);
121 copy1.setReportUploadProgress(true); 125 copy1.setReportUploadProgress(true);
122 copy1.setHasUserGesture(true); 126 copy1.setHasUserGesture(true);
123 copy1.setDownloadToFile(true); 127 copy1.setDownloadToFile(true);
124 copy1.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); 128 copy1.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All);
125 copy1.setFetchRequestMode(WebURLRequest::FetchRequestModeNoCORS); 129 copy1.setFetchRequestMode(WebURLRequest::FetchRequestModeNoCORS);
126 copy1.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeInclude); 130 copy1.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeInclude);
127 131
128 std::unique_ptr<CrossThreadResourceRequestData> data2(copy1.copyData()); 132 std::unique_ptr<CrossThreadResourceRequestData> data2(copy1.copyData());
(...skipping 11 matching lines...) Expand all
140 TEST(ResourceRequestTest, SetHasUserGesture) { 144 TEST(ResourceRequestTest, SetHasUserGesture) {
141 ResourceRequest original; 145 ResourceRequest original;
142 EXPECT_FALSE(original.hasUserGesture()); 146 EXPECT_FALSE(original.hasUserGesture());
143 original.setHasUserGesture(true); 147 original.setHasUserGesture(true);
144 EXPECT_TRUE(original.hasUserGesture()); 148 EXPECT_TRUE(original.hasUserGesture());
145 original.setHasUserGesture(false); 149 original.setHasUserGesture(false);
146 EXPECT_TRUE(original.hasUserGesture()); 150 EXPECT_TRUE(original.hasUserGesture());
147 } 151 }
148 152
149 } // namespace blink 153 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/network/ResourceRequest.cpp ('k') | third_party/WebKit/public/platform/WebURLRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698