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

Side by Side Diff: Source/core/loader/FrameFetchContextTest.cpp

Issue 1010893003: Upgrade insecure requests: Pipe navigational hosts down into nested documents. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 5 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 | Annotate | Revision Log
OLDNEW
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 { "https://example.test:1212/image.png", "https://example.test:1212/imag e.png" }, 128 { "https://example.test:1212/image.png", "https://example.test:1212/imag e.png" },
129 129
130 { "ftp://example.test/image.png", "ftp://example.test/image.png" }, 130 { "ftp://example.test/image.png", "ftp://example.test/image.png" },
131 { "ftp://example.test:21/image.png", "ftp://example.test:21/image.png" } , 131 { "ftp://example.test:21/image.png", "ftp://example.test:21/image.png" } ,
132 { "ftp://example.test:1212/image.png", "ftp://example.test:1212/image.pn g" }, 132 { "ftp://example.test:1212/image.png", "ftp://example.test:1212/image.pn g" },
133 }; 133 };
134 134
135 document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsUpgrade ); 135 document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsUpgrade );
136 136
137 for (auto test : tests) { 137 for (auto test : tests) {
138 // secureOrigin's host is 'secureorigin.test', not 'example.test' 138 document->insecureNavigationsToUpgrade()->clear();
139 document->setSecurityOrigin(secureOrigin);
140 139
141 // We always upgrade for FrameTypeNone and FrameTypeNested. 140 // We always upgrade for FrameTypeNone and FrameTypeNested.
142 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeNone, test.upgraded); 141 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeNone, test.upgraded);
143 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeNested, test.upgraded); 142 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeNested, test.upgraded);
144 143
145 // We do not upgrade for FrameTypeTopLevel or FrameTypeAuxiliary... 144 // We do not upgrade for FrameTypeTopLevel or FrameTypeAuxiliary...
146 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeTopLevel, test.original); 145 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeTopLevel, test.original);
147 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeAuxiliary, test.original); 146 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeAuxiliary, test.original);
148 147
149 // unless the request context is RequestContextForm. 148 // unless the request context is RequestContextForm.
150 expectUpgrade(test.original, WebURLRequest::RequestContextForm, WebURLRe quest::FrameTypeTopLevel, test.upgraded); 149 expectUpgrade(test.original, WebURLRequest::RequestContextForm, WebURLRe quest::FrameTypeTopLevel, test.upgraded);
151 expectUpgrade(test.original, WebURLRequest::RequestContextForm, WebURLRe quest::FrameTypeAuxiliary, test.upgraded); 150 expectUpgrade(test.original, WebURLRequest::RequestContextForm, WebURLRe quest::FrameTypeAuxiliary, test.upgraded);
152 151
153 // Or unless the host of the document matches the host of the resource: 152 // Or unless the host of the resource is in the document's InsecureNavig ationsSet:
154 document->setSecurityOrigin(exampleOrigin); 153 document->addInsecureNavigationUpgrade(exampleOrigin->host().impl()->has h());
155 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeTopLevel, test.upgraded); 154 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeTopLevel, test.upgraded);
156 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeAuxiliary, test.upgraded); 155 expectUpgrade(test.original, WebURLRequest::RequestContextScript, WebURL Request::FrameTypeAuxiliary, test.upgraded);
157 } 156 }
158 } 157 }
159 158
160 TEST_F(FrameFetchContextUpgradeTest, DoNotUpgradeInsecureResourceRequests) 159 TEST_F(FrameFetchContextUpgradeTest, DoNotUpgradeInsecureResourceRequests)
161 { 160 {
162 document->setSecurityOrigin(secureOrigin); 161 document->setSecurityOrigin(secureOrigin);
163 document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsDoNotUp grade); 162 document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsDoNotUp grade);
164 163
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 expectHeader("http://www.example.com/1.gif", "RW", false, ""); 260 expectHeader("http://www.example.com/1.gif", "RW", false, "");
262 261
263 dummyPageHolder->frame().setShouldSendDPRHint(); 262 dummyPageHolder->frame().setShouldSendDPRHint();
264 dummyPageHolder->frame().setShouldSendRWHint(); 263 dummyPageHolder->frame().setShouldSendRWHint();
265 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); 264 expectHeader("http://www.example.com/1.gif", "DPR", true, "1");
266 expectHeader("http://www.example.com/1.gif", "RW", true, "500"); 265 expectHeader("http://www.example.com/1.gif", "RW", true, "500");
267 } 266 }
268 267
269 } // namespace 268 } // namespace
270 269
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698