OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015, Google Inc. All rights reserved. | 2 * Copyright (c) 2015, 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 void expectUpgrade(const char* input, WebURLRequest::RequestContext requestC
ontext, WebURLRequest::FrameType frameType, const char* expected) | 180 void expectUpgrade(const char* input, WebURLRequest::RequestContext requestC
ontext, WebURLRequest::FrameType frameType, const char* expected) |
181 { | 181 { |
182 KURL inputURL(ParsedURLString, input); | 182 KURL inputURL(ParsedURLString, input); |
183 KURL expectedURL(ParsedURLString, expected); | 183 KURL expectedURL(ParsedURLString, expected); |
184 | 184 |
185 FetchRequest fetchRequest = FetchRequest(ResourceRequest(inputURL), Fetc
hInitiatorInfo()); | 185 FetchRequest fetchRequest = FetchRequest(ResourceRequest(inputURL), Fetc
hInitiatorInfo()); |
186 fetchRequest.mutableResourceRequest().setRequestContext(requestContext); | 186 fetchRequest.mutableResourceRequest().setRequestContext(requestContext); |
187 fetchRequest.mutableResourceRequest().setFrameType(frameType); | 187 fetchRequest.mutableResourceRequest().setFrameType(frameType); |
188 | 188 |
189 fetchContext->upgradeInsecureRequest(fetchRequest); | 189 fetchContext->upgradeInsecureRequest(fetchRequest.mutableResourceRequest
()); |
190 | 190 |
191 EXPECT_STREQ(expectedURL.getString().utf8().data(), fetchRequest.resourc
eRequest().url().getString().utf8().data()); | 191 EXPECT_STREQ(expectedURL.getString().utf8().data(), fetchRequest.resourc
eRequest().url().getString().utf8().data()); |
192 EXPECT_EQ(expectedURL.protocol(), fetchRequest.resourceRequest().url().p
rotocol()); | 192 EXPECT_EQ(expectedURL.protocol(), fetchRequest.resourceRequest().url().p
rotocol()); |
193 EXPECT_EQ(expectedURL.host(), fetchRequest.resourceRequest().url().host(
)); | 193 EXPECT_EQ(expectedURL.host(), fetchRequest.resourceRequest().url().host(
)); |
194 EXPECT_EQ(expectedURL.port(), fetchRequest.resourceRequest().url().port(
)); | 194 EXPECT_EQ(expectedURL.port(), fetchRequest.resourceRequest().url().port(
)); |
195 EXPECT_EQ(expectedURL.hasPort(), fetchRequest.resourceRequest().url().ha
sPort()); | 195 EXPECT_EQ(expectedURL.hasPort(), fetchRequest.resourceRequest().url().ha
sPort()); |
196 EXPECT_EQ(expectedURL.path(), fetchRequest.resourceRequest().url().path(
)); | 196 EXPECT_EQ(expectedURL.path(), fetchRequest.resourceRequest().url().path(
)); |
197 } | 197 } |
198 | 198 |
199 void expectHTTPSHeader(const char* input, WebURLRequest::FrameType frameType
, bool shouldPrefer) | 199 void expectHTTPSHeader(const char* input, WebURLRequest::FrameType frameType
, bool shouldPrefer) |
200 { | 200 { |
201 KURL inputURL(ParsedURLString, input); | 201 KURL inputURL(ParsedURLString, input); |
202 | 202 |
203 FetchRequest fetchRequest = FetchRequest(ResourceRequest(inputURL), Fetc
hInitiatorInfo()); | 203 FetchRequest fetchRequest = FetchRequest(ResourceRequest(inputURL), Fetc
hInitiatorInfo()); |
204 fetchRequest.mutableResourceRequest().setRequestContext(WebURLRequest::R
equestContextScript); | 204 fetchRequest.mutableResourceRequest().setRequestContext(WebURLRequest::R
equestContextScript); |
205 fetchRequest.mutableResourceRequest().setFrameType(frameType); | 205 fetchRequest.mutableResourceRequest().setFrameType(frameType); |
206 | 206 |
207 fetchContext->upgradeInsecureRequest(fetchRequest); | 207 fetchContext->upgradeInsecureRequest(fetchRequest.mutableResourceRequest
()); |
208 | 208 |
209 EXPECT_STREQ(shouldPrefer ? "1" : "", | 209 EXPECT_STREQ(shouldPrefer ? "1" : "", |
210 fetchRequest.resourceRequest().httpHeaderField(HTTPNames::Upgrade_In
secure_Requests).utf8().data()); | 210 fetchRequest.resourceRequest().httpHeaderField(HTTPNames::Upgrade_In
secure_Requests).utf8().data()); |
211 } | 211 } |
212 | 212 |
213 RefPtr<SecurityOrigin> exampleOrigin; | 213 RefPtr<SecurityOrigin> exampleOrigin; |
214 RefPtr<SecurityOrigin> secureOrigin; | 214 RefPtr<SecurityOrigin> secureOrigin; |
215 }; | 215 }; |
216 | 216 |
217 TEST_F(FrameFetchContextUpgradeTest, UpgradeInsecureResourceRequests) | 217 TEST_F(FrameFetchContextUpgradeTest, UpgradeInsecureResourceRequests) |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource
); | 630 fetchContext->addAdditionalRequestHeaders(mainRequest, FetchMainResource
); |
631 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); | 631 EXPECT_EQ(mainRequest.isExternalRequest(), test.isExternalExpectation); |
632 | 632 |
633 ResourceRequest subRequest(test.url); | 633 ResourceRequest subRequest(test.url); |
634 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); | 634 fetchContext->addAdditionalRequestHeaders(subRequest, FetchSubresource); |
635 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); | 635 EXPECT_EQ(subRequest.isExternalRequest(), test.isExternalExpectation); |
636 } | 636 } |
637 } | 637 } |
638 | 638 |
639 } // namespace blink | 639 } // namespace blink |
OLD | NEW |