OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 expectUpgrade("https://example.test/image.png", "https://example.test/image.
png"); | 188 expectUpgrade("https://example.test/image.png", "https://example.test/image.
png"); |
189 expectUpgrade("https://example.test:80/image.png", "https://example.test:80/
image.png"); | 189 expectUpgrade("https://example.test:80/image.png", "https://example.test:80/
image.png"); |
190 expectUpgrade("https://example.test:1212/image.png", "https://example.test:1
212/image.png"); | 190 expectUpgrade("https://example.test:1212/image.png", "https://example.test:1
212/image.png"); |
191 | 191 |
192 expectUpgrade("ftp://example.test/image.png", "ftp://example.test/image.png"
); | 192 expectUpgrade("ftp://example.test/image.png", "ftp://example.test/image.png"
); |
193 expectUpgrade("ftp://example.test:21/image.png", "ftp://example.test:21/imag
e.png"); | 193 expectUpgrade("ftp://example.test:21/image.png", "ftp://example.test:21/imag
e.png"); |
194 expectUpgrade("ftp://example.test:1212/image.png", "ftp://example.test:1212/
image.png"); | 194 expectUpgrade("ftp://example.test:1212/image.png", "ftp://example.test:1212/
image.png"); |
195 } | 195 } |
196 | 196 |
197 TEST_F(ResourceFetcherUpgradeTest, MonitorInsecureResourceRequests) | |
198 { | |
199 document->setSecurityOrigin(secureOrigin); | |
200 document->setInsecureContentPolicy(SecurityContext::InsecureContentMonitor); | |
201 | |
202 expectUpgrade("http://example.test/image.png", "http://example.test/image.pn
g"); | |
203 expectUpgrade("http://example.test:80/image.png", "http://example.test:80/im
age.png"); | |
204 expectUpgrade("http://example.test:1212/image.png", "http://example.test:121
2/image.png"); | |
205 | |
206 expectUpgrade("https://example.test/image.png", "https://example.test/image.
png"); | |
207 expectUpgrade("https://example.test:80/image.png", "https://example.test:80/
image.png"); | |
208 expectUpgrade("https://example.test:1212/image.png", "https://example.test:1
212/image.png"); | |
209 | |
210 expectUpgrade("ftp://example.test/image.png", "ftp://example.test/image.png"
); | |
211 expectUpgrade("ftp://example.test:21/image.png", "ftp://example.test:21/imag
e.png"); | |
212 expectUpgrade("ftp://example.test:1212/image.png", "ftp://example.test:1212/
image.png"); | |
213 } | |
214 | |
215 TEST_F(ResourceFetcherUpgradeTest, SendPreferHeader) | 197 TEST_F(ResourceFetcherUpgradeTest, SendPreferHeader) |
216 { | 198 { |
217 struct TestCase { | 199 struct TestCase { |
218 const char* toRequest; | 200 const char* toRequest; |
219 WebURLRequest::FrameType frameType; | 201 WebURLRequest::FrameType frameType; |
220 bool shouldPrefer; | 202 bool shouldPrefer; |
221 } tests[] = { | 203 } tests[] = { |
222 { "http://example.test/page.html", WebURLRequest::FrameTypeAuxiliary, tr
ue }, | 204 { "http://example.test/page.html", WebURLRequest::FrameTypeAuxiliary, tr
ue }, |
223 { "http://example.test/page.html", WebURLRequest::FrameTypeNested, true
}, | 205 { "http://example.test/page.html", WebURLRequest::FrameTypeNested, true
}, |
224 { "http://example.test/page.html", WebURLRequest::FrameTypeNone, false }
, | 206 { "http://example.test/page.html", WebURLRequest::FrameTypeNone, false }
, |
225 { "http://example.test/page.html", WebURLRequest::FrameTypeTopLevel, tru
e }, | 207 { "http://example.test/page.html", WebURLRequest::FrameTypeTopLevel, tru
e }, |
226 { "https://example.test/page.html", WebURLRequest::FrameTypeAuxiliary, f
alse }, | 208 { "https://example.test/page.html", WebURLRequest::FrameTypeAuxiliary, f
alse }, |
227 { "https://example.test/page.html", WebURLRequest::FrameTypeNested, fals
e }, | 209 { "https://example.test/page.html", WebURLRequest::FrameTypeNested, fals
e }, |
228 { "https://example.test/page.html", WebURLRequest::FrameTypeNone, false
}, | 210 { "https://example.test/page.html", WebURLRequest::FrameTypeNone, false
}, |
229 { "https://example.test/page.html", WebURLRequest::FrameTypeTopLevel, fa
lse } | 211 { "https://example.test/page.html", WebURLRequest::FrameTypeTopLevel, fa
lse } |
230 }; | 212 }; |
231 | 213 |
232 for (auto test : tests) { | 214 for (auto test : tests) { |
233 document->setInsecureContentPolicy(SecurityContext::InsecureContentDoNot
Upgrade); | 215 document->setInsecureContentPolicy(SecurityContext::InsecureContentDoNot
Upgrade); |
234 expectPreferHeader(test.toRequest, test.frameType, test.shouldPrefer); | 216 expectPreferHeader(test.toRequest, test.frameType, test.shouldPrefer); |
235 | 217 |
236 document->setInsecureContentPolicy(SecurityContext::InsecureContentUpgra
de); | 218 document->setInsecureContentPolicy(SecurityContext::InsecureContentUpgra
de); |
237 expectPreferHeader(test.toRequest, test.frameType, test.shouldPrefer); | 219 expectPreferHeader(test.toRequest, test.frameType, test.shouldPrefer); |
238 | |
239 document->setInsecureContentPolicy(SecurityContext::InsecureContentMonit
or); | |
240 expectPreferHeader(test.toRequest, test.frameType, test.shouldPrefer); | |
241 } | 220 } |
242 } | 221 } |
243 | 222 |
244 class ResourceFetcherHintsTest : public ::testing::Test { | 223 class ResourceFetcherHintsTest : public ::testing::Test { |
245 public: | 224 public: |
246 ResourceFetcherHintsTest() { } | 225 ResourceFetcherHintsTest() { } |
247 | 226 |
248 protected: | 227 protected: |
249 virtual void SetUp() | 228 virtual void SetUp() |
250 { | 229 { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); | 279 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); |
301 expectHeader("http://www.example.com/1.gif", "RW", false, ""); | 280 expectHeader("http://www.example.com/1.gif", "RW", false, ""); |
302 | 281 |
303 dummyPageHolder->frame().setShouldSendDPRHint(); | 282 dummyPageHolder->frame().setShouldSendDPRHint(); |
304 dummyPageHolder->frame().setShouldSendRWHint(); | 283 dummyPageHolder->frame().setShouldSendRWHint(); |
305 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); | 284 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); |
306 expectHeader("http://www.example.com/1.gif", "RW", true, "500"); | 285 expectHeader("http://www.example.com/1.gif", "RW", true, "500"); |
307 } | 286 } |
308 | 287 |
309 } // namespace | 288 } // namespace |
OLD | NEW |