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

Side by Side Diff: ios/web/public/referrer_util_unittest.cc

Issue 2111623003: Reland of Apply Referrer-Policy header when following redirects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: initialize |read_handler| Created 4 years, 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ios/web/public/referrer_util.h" 5 #include "ios/web/public/referrer_util.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "ios/web/public/referrer.h" 8 #include "ios/web/public/referrer.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "url/gurl.h" 10 #include "url/gurl.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 policy == ReferrerPolicyNever || 157 policy == ReferrerPolicyNever ||
158 policy == ReferrerPolicyOrigin); 158 policy == ReferrerPolicyOrigin);
159 break; 159 break;
160 case net::URLRequest:: 160 case net::URLRequest::
161 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE: 161 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE:
162 // This corresponds directly to ReferrerPolicyNoReferrerWhenDowngrade, 162 // This corresponds directly to ReferrerPolicyNoReferrerWhenDowngrade,
163 // which is also how Default works on iOS. 163 // which is also how Default works on iOS.
164 EXPECT_TRUE(policy == ReferrerPolicyDefault || 164 EXPECT_TRUE(policy == ReferrerPolicyDefault ||
165 policy == ReferrerPolicyNoReferrerWhenDowngrade); 165 policy == ReferrerPolicyNoReferrerWhenDowngrade);
166 break; 166 break;
167 case net::URLRequest::ORIGIN:
168 EXPECT_TRUE(policy == ReferrerPolicyOrigin);
169 break;
170 case net::URLRequest::NO_REFERRER:
171 EXPECT_TRUE(policy == ReferrerPolicyNever);
172 break;
173 case net::URLRequest::MAX_REFERRER_POLICY:
174 FAIL();
175 break;
167 } 176 }
168 } 177 }
169 } 178 }
170 179
171 // Tests that all the strings corresponding to web::ReferrerPolicy values are 180 // Tests that all the strings corresponding to web::ReferrerPolicy values are
172 // correctly handled. 181 // correctly handled.
173 TEST(ReferrerUtilTest, PolicyFromString) { 182 TEST(ReferrerUtilTest, PolicyFromString) {
174 // The ordering here must match web::ReferrerPolicy; this makes the test 183 // The ordering here must match web::ReferrerPolicy; this makes the test
175 // simpler, at the cost of needing to re-order if the enum is re-ordered. 184 // simpler, at the cost of needing to re-order if the enum is re-ordered.
176 const char* const kPolicyStrings[] = { 185 const char* const kPolicyStrings[] = {
(...skipping 23 matching lines...) Expand all
200 EXPECT_EQ(ReferrerPolicyNoReferrerWhenDowngrade, 209 EXPECT_EQ(ReferrerPolicyNoReferrerWhenDowngrade,
201 ReferrerPolicyFromString("default")); 210 ReferrerPolicyFromString("default"));
202 EXPECT_EQ(ReferrerPolicyAlways, ReferrerPolicyFromString("always")); 211 EXPECT_EQ(ReferrerPolicyAlways, ReferrerPolicyFromString("always"));
203 212
204 // Test that invalid values map to Never. 213 // Test that invalid values map to Never.
205 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("")); 214 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString(""));
206 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("made-up")); 215 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("made-up"));
207 } 216 }
208 217
209 } // namespace web 218 } // namespace web
OLDNEW
« no previous file with comments | « content/shell/browser/shell_url_request_context_getter.cc ('k') | net/url_request/redirect_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698