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

Unified Diff: Source/core/loader/FrameFetchContextTest.cpp

Issue 1178093002: Correctly send the 'HTTPS' header for top-level navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tests. Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/loader/FrameFetchContext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/FrameFetchContextTest.cpp
diff --git a/Source/core/loader/FrameFetchContextTest.cpp b/Source/core/loader/FrameFetchContextTest.cpp
index 9f37bac8a0df0df1fc455846a834dd3a8605af79..208dce209fb684b7293ea7338fa4ab6572c44c84 100644
--- a/Source/core/loader/FrameFetchContextTest.cpp
+++ b/Source/core/loader/FrameFetchContextTest.cpp
@@ -132,9 +132,10 @@ TEST_F(FrameFetchContextUpgradeTest, UpgradeInsecureResourceRequests)
{ "ftp://example.test:1212/image.png", "ftp://example.test:1212/image.png" },
};
+ FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsUpgrade);
- for (auto test : tests) {
+ for (const auto& test : tests) {
document->insecureNavigationsToUpgrade()->clear();
// We always upgrade for FrameTypeNone and FrameTypeNested.
@@ -158,6 +159,7 @@ TEST_F(FrameFetchContextUpgradeTest, UpgradeInsecureResourceRequests)
TEST_F(FrameFetchContextUpgradeTest, DoNotUpgradeInsecureResourceRequests)
{
+ FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
document->setSecurityOrigin(secureOrigin);
document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsDoNotUpgrade);
@@ -174,7 +176,7 @@ TEST_F(FrameFetchContextUpgradeTest, DoNotUpgradeInsecureResourceRequests)
expectUpgrade("ftp://example.test:1212/image.png", "ftp://example.test:1212/image.png");
}
-TEST_F(FrameFetchContextUpgradeTest, SendPreferHeader)
+TEST_F(FrameFetchContextUpgradeTest, SendHTTPSHeader)
{
struct TestCase {
const char* toRequest;
@@ -191,7 +193,20 @@ TEST_F(FrameFetchContextUpgradeTest, SendPreferHeader)
{ "https://example.test/page.html", WebURLRequest::FrameTypeTopLevel, true }
};
- for (auto test : tests) {
+ // This should work correctly both when the FrameFetchContext has a Document, and
+ // when it doesn't (e.g. during main frame navigations), so run through the tests
+ // both before and after providing a document to the context.
+ for (const auto& test : tests) {
+ document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsDoNotUpgrade);
+ expectHTTPSHeader(test.toRequest, test.frameType, test.shouldPrefer);
+
+ document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsUpgrade);
+ expectHTTPSHeader(test.toRequest, test.frameType, test.shouldPrefer);
+ }
+
+ FrameFetchContext::provideDocumentToContext(*fetchContext, document.get());
+
+ for (const auto& test : tests) {
document->setInsecureRequestsPolicy(SecurityContext::InsecureRequestsDoNotUpgrade);
expectHTTPSHeader(test.toRequest, test.frameType, test.shouldPrefer);
« no previous file with comments | « Source/core/loader/FrameFetchContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698