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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 { "https://example.test/image.png", "https://example.test/image.png" }, | 145 { "https://example.test/image.png", "https://example.test/image.png" }, |
146 { "https://example.test:80/image.png", "https://example.test:80/image.pn
g" }, | 146 { "https://example.test:80/image.png", "https://example.test:80/image.pn
g" }, |
147 { "https://example.test:1212/image.png", "https://example.test:1212/imag
e.png" }, | 147 { "https://example.test:1212/image.png", "https://example.test:1212/imag
e.png" }, |
148 | 148 |
149 { "ftp://example.test/image.png", "ftp://example.test/image.png" }, | 149 { "ftp://example.test/image.png", "ftp://example.test/image.png" }, |
150 { "ftp://example.test:21/image.png", "ftp://example.test:21/image.png" }
, | 150 { "ftp://example.test:21/image.png", "ftp://example.test:21/image.png" }
, |
151 { "ftp://example.test:1212/image.png", "ftp://example.test:1212/image.pn
g" }, | 151 { "ftp://example.test:1212/image.png", "ftp://example.test:1212/image.pn
g" }, |
152 }; | 152 }; |
153 | 153 |
154 document->setInsecureContentPolicy(SecurityContext::InsecureContentUpgrade); | 154 document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsUpgrade
); |
155 | 155 |
156 for (auto test : tests) { | 156 for (auto test : tests) { |
157 // secureOrigin's host is 'secureorigin.test', not 'example.test' | 157 // secureOrigin's host is 'secureorigin.test', not 'example.test' |
158 document->setSecurityOrigin(secureOrigin); | 158 document->setSecurityOrigin(secureOrigin); |
159 | 159 |
160 // We always upgrade for FrameTypeNone and FrameTypeNested. | 160 // We always upgrade for FrameTypeNone and FrameTypeNested. |
161 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeNone, test.upgraded); | 161 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeNone, test.upgraded); |
162 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeNested, test.upgraded); | 162 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeNested, test.upgraded); |
163 | 163 |
164 // We do not upgrade for FrameTypeTopLevel or FrameTypeAuxiliary... | 164 // We do not upgrade for FrameTypeTopLevel or FrameTypeAuxiliary... |
165 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeTopLevel, test.original); | 165 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeTopLevel, test.original); |
166 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeAuxiliary, test.original); | 166 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeAuxiliary, test.original); |
167 | 167 |
168 // unless the request context is RequestContextForm. | 168 // unless the request context is RequestContextForm. |
169 expectUpgrade(test.original, WebURLRequest::RequestContextForm, WebURLRe
quest::FrameTypeTopLevel, test.upgraded); | 169 expectUpgrade(test.original, WebURLRequest::RequestContextForm, WebURLRe
quest::FrameTypeTopLevel, test.upgraded); |
170 expectUpgrade(test.original, WebURLRequest::RequestContextForm, WebURLRe
quest::FrameTypeAuxiliary, test.upgraded); | 170 expectUpgrade(test.original, WebURLRequest::RequestContextForm, WebURLRe
quest::FrameTypeAuxiliary, test.upgraded); |
171 | 171 |
172 // Or unless the host of the document matches the host of the resource: | 172 // Or unless the host of the document matches the host of the resource: |
173 document->setSecurityOrigin(exampleOrigin); | 173 document->setSecurityOrigin(exampleOrigin); |
174 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeTopLevel, test.upgraded); | 174 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeTopLevel, test.upgraded); |
175 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeAuxiliary, test.upgraded); | 175 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL
Request::FrameTypeAuxiliary, test.upgraded); |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 TEST_F(ResourceFetcherUpgradeTest, DoNotUpgradeInsecureResourceRequests) | 179 TEST_F(ResourceFetcherUpgradeTest, DoNotUpgradeInsecureResourceRequests) |
180 { | 180 { |
181 document->setSecurityOrigin(secureOrigin); | 181 document->setSecurityOrigin(secureOrigin); |
182 document->setInsecureContentPolicy(SecurityContext::InsecureContentDoNotUpgr
ade); | 182 document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsDoNotUp
grade); |
183 | 183 |
184 expectUpgrade("http://example.test/image.png", "http://example.test/image.pn
g"); | 184 expectUpgrade("http://example.test/image.png", "http://example.test/image.pn
g"); |
185 expectUpgrade("http://example.test:80/image.png", "http://example.test:80/im
age.png"); | 185 expectUpgrade("http://example.test:80/image.png", "http://example.test:80/im
age.png"); |
186 expectUpgrade("http://example.test:1212/image.png", "http://example.test:121
2/image.png"); | 186 expectUpgrade("http://example.test:1212/image.png", "http://example.test:121
2/image.png"); |
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"
); |
(...skipping 12 matching lines...) Expand all Loading... |
205 { "http://example.test/page.html", WebURLRequest::FrameTypeNested, true
}, | 205 { "http://example.test/page.html", WebURLRequest::FrameTypeNested, true
}, |
206 { "http://example.test/page.html", WebURLRequest::FrameTypeNone, false }
, | 206 { "http://example.test/page.html", WebURLRequest::FrameTypeNone, false }
, |
207 { "http://example.test/page.html", WebURLRequest::FrameTypeTopLevel, tru
e }, | 207 { "http://example.test/page.html", WebURLRequest::FrameTypeTopLevel, tru
e }, |
208 { "https://example.test/page.html", WebURLRequest::FrameTypeAuxiliary, f
alse }, | 208 { "https://example.test/page.html", WebURLRequest::FrameTypeAuxiliary, f
alse }, |
209 { "https://example.test/page.html", WebURLRequest::FrameTypeNested, fals
e }, | 209 { "https://example.test/page.html", WebURLRequest::FrameTypeNested, fals
e }, |
210 { "https://example.test/page.html", WebURLRequest::FrameTypeNone, false
}, | 210 { "https://example.test/page.html", WebURLRequest::FrameTypeNone, false
}, |
211 { "https://example.test/page.html", WebURLRequest::FrameTypeTopLevel, fa
lse } | 211 { "https://example.test/page.html", WebURLRequest::FrameTypeTopLevel, fa
lse } |
212 }; | 212 }; |
213 | 213 |
214 for (auto test : tests) { | 214 for (auto test : tests) { |
215 document->setInsecureContentPolicy(SecurityContext::InsecureContentDoNot
Upgrade); | 215 document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsDoN
otUpgrade); |
216 expectPreferHeader(test.toRequest, test.frameType, test.shouldPrefer); | 216 expectPreferHeader(test.toRequest, test.frameType, test.shouldPrefer); |
217 | 217 |
218 document->setInsecureContentPolicy(SecurityContext::InsecureContentUpgra
de); | 218 document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsUpg
rade); |
219 expectPreferHeader(test.toRequest, test.frameType, test.shouldPrefer); | 219 expectPreferHeader(test.toRequest, test.frameType, test.shouldPrefer); |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 class ResourceFetcherHintsTest : public ::testing::Test { | 223 class ResourceFetcherHintsTest : public ::testing::Test { |
224 public: | 224 public: |
225 ResourceFetcherHintsTest() { } | 225 ResourceFetcherHintsTest() { } |
226 | 226 |
227 protected: | 227 protected: |
228 virtual void SetUp() | 228 virtual void SetUp() |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); | 279 expectHeader("http://www.example.com/1.gif", "DPR", false, ""); |
280 expectHeader("http://www.example.com/1.gif", "RW", false, ""); | 280 expectHeader("http://www.example.com/1.gif", "RW", false, ""); |
281 | 281 |
282 dummyPageHolder->frame().setShouldSendDPRHint(); | 282 dummyPageHolder->frame().setShouldSendDPRHint(); |
283 dummyPageHolder->frame().setShouldSendRWHint(); | 283 dummyPageHolder->frame().setShouldSendRWHint(); |
284 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); | 284 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); |
285 expectHeader("http://www.example.com/1.gif", "RW", true, "500"); | 285 expectHeader("http://www.example.com/1.gif", "RW", true, "500"); |
286 } | 286 } |
287 | 287 |
288 } // namespace | 288 } // namespace |
OLD | NEW |