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

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

Issue 2100583002: Apply Referrer-Policy header when following redirects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update ios switch 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::MAX_REFERRER_POLICY:
168 FAIL();
169 break;
167 } 170 }
168 } 171 }
169 } 172 }
170 173
171 // Tests that all the strings corresponding to web::ReferrerPolicy values are 174 // Tests that all the strings corresponding to web::ReferrerPolicy values are
172 // correctly handled. 175 // correctly handled.
173 TEST(ReferrerUtilTest, PolicyFromString) { 176 TEST(ReferrerUtilTest, PolicyFromString) {
174 // The ordering here must match web::ReferrerPolicy; this makes the test 177 // 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. 178 // simpler, at the cost of needing to re-order if the enum is re-ordered.
176 const char* const kPolicyStrings[] = { 179 const char* const kPolicyStrings[] = {
(...skipping 23 matching lines...) Expand all
200 EXPECT_EQ(ReferrerPolicyNoReferrerWhenDowngrade, 203 EXPECT_EQ(ReferrerPolicyNoReferrerWhenDowngrade,
201 ReferrerPolicyFromString("default")); 204 ReferrerPolicyFromString("default"));
202 EXPECT_EQ(ReferrerPolicyAlways, ReferrerPolicyFromString("always")); 205 EXPECT_EQ(ReferrerPolicyAlways, ReferrerPolicyFromString("always"));
203 206
204 // Test that invalid values map to Never. 207 // Test that invalid values map to Never.
205 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("")); 208 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString(""));
206 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("made-up")); 209 EXPECT_EQ(ReferrerPolicyNever, ReferrerPolicyFromString("made-up"));
207 } 210 }
208 211
209 } // namespace web 212 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698