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

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

Issue 1011083003: Upgrade: Add 'Upgraded' header, update 'Prefer' value. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
« no previous file with comments | « Source/core/loader/FrameFetchContext.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 fetchRequest.mutableResourceRequest().setFrameType(frameType); 78 fetchRequest.mutableResourceRequest().setFrameType(frameType);
79 79
80 fetchContext->upgradeInsecureRequest(fetchRequest); 80 fetchContext->upgradeInsecureRequest(fetchRequest);
81 81
82 EXPECT_STREQ(expectedURL.string().utf8().data(), fetchRequest.resourceRe quest().url().string().utf8().data()); 82 EXPECT_STREQ(expectedURL.string().utf8().data(), fetchRequest.resourceRe quest().url().string().utf8().data());
83 EXPECT_EQ(expectedURL.protocol(), fetchRequest.resourceRequest().url().p rotocol()); 83 EXPECT_EQ(expectedURL.protocol(), fetchRequest.resourceRequest().url().p rotocol());
84 EXPECT_EQ(expectedURL.host(), fetchRequest.resourceRequest().url().host( )); 84 EXPECT_EQ(expectedURL.host(), fetchRequest.resourceRequest().url().host( ));
85 EXPECT_EQ(expectedURL.port(), fetchRequest.resourceRequest().url().port( )); 85 EXPECT_EQ(expectedURL.port(), fetchRequest.resourceRequest().url().port( ));
86 EXPECT_EQ(expectedURL.hasPort(), fetchRequest.resourceRequest().url().ha sPort()); 86 EXPECT_EQ(expectedURL.hasPort(), fetchRequest.resourceRequest().url().ha sPort());
87 EXPECT_EQ(expectedURL.path(), fetchRequest.resourceRequest().url().path( )); 87 EXPECT_EQ(expectedURL.path(), fetchRequest.resourceRequest().url().path( ));
88
89 bool expectUpgrade = inputURL != expectedURL;
90
91 EXPECT_STREQ(expectUpgrade ? "1" : "",
92 fetchRequest.resourceRequest().httpHeaderField("Upgraded").utf8().da ta());
88 } 93 }
89 94
90 void expectPreferHeader(const char* input, WebURLRequest::FrameType frameTyp e, bool shouldPrefer) 95 void expectPreferHeader(const char* input, WebURLRequest::FrameType frameTyp e, bool shouldPrefer)
91 { 96 {
92 KURL inputURL(ParsedURLString, input); 97 KURL inputURL(ParsedURLString, input);
93 98
94 FetchRequest fetchRequest = FetchRequest(ResourceRequest(inputURL), Fetc hInitiatorInfo()); 99 FetchRequest fetchRequest = FetchRequest(ResourceRequest(inputURL), Fetc hInitiatorInfo());
95 fetchRequest.mutableResourceRequest().setRequestContext(WebURLRequest::R equestContextScript); 100 fetchRequest.mutableResourceRequest().setRequestContext(WebURLRequest::R equestContextScript);
96 fetchRequest.mutableResourceRequest().setFrameType(frameType); 101 fetchRequest.mutableResourceRequest().setFrameType(frameType);
97 102
98 fetchContext->upgradeInsecureRequest(fetchRequest); 103 fetchContext->upgradeInsecureRequest(fetchRequest);
99 104
100 EXPECT_STREQ(shouldPrefer ? "return=secure-representation" : "", 105 EXPECT_STREQ(shouldPrefer ? "tls" : "",
101 fetchRequest.resourceRequest().httpHeaderField("Prefer").utf8().data ()); 106 fetchRequest.resourceRequest().httpHeaderField("Prefer").utf8().data ());
102 } 107 }
103 108
104 KURL secureURL; 109 KURL secureURL;
105 RefPtr<SecurityOrigin> exampleOrigin; 110 RefPtr<SecurityOrigin> exampleOrigin;
106 RefPtr<SecurityOrigin> secureOrigin; 111 RefPtr<SecurityOrigin> secureOrigin;
107 112
108 OwnPtr<DummyPageHolder> dummyPageHolder; 113 OwnPtr<DummyPageHolder> dummyPageHolder;
109 // We don't use the DocumentLoader directly in any tests, but need to keep i t around as long 114 // We don't use the DocumentLoader directly in any tests, but need to keep i t around as long
110 // as the ResourceFetcher and Document live due to indirect usage. 115 // as the ResourceFetcher and Document live due to indirect usage.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 expectHeader("http://www.example.com/1.gif", "RW", false, ""); 266 expectHeader("http://www.example.com/1.gif", "RW", false, "");
262 267
263 dummyPageHolder->frame().setShouldSendDPRHint(); 268 dummyPageHolder->frame().setShouldSendDPRHint();
264 dummyPageHolder->frame().setShouldSendRWHint(); 269 dummyPageHolder->frame().setShouldSendRWHint();
265 expectHeader("http://www.example.com/1.gif", "DPR", true, "1"); 270 expectHeader("http://www.example.com/1.gif", "DPR", true, "1");
266 expectHeader("http://www.example.com/1.gif", "RW", true, "500"); 271 expectHeader("http://www.example.com/1.gif", "RW", true, "500");
267 } 272 }
268 273
269 } // namespace 274 } // namespace
270 275
OLDNEW
« 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