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

Side by Side Diff: third_party/WebKit/Source/platform/weborigin/SecurityPolicyTest.cpp

Issue 2809123002: ur_ls -> urls in platform/weborigin (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/SchemeRegistry.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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 << "'."; 175 << "'.";
176 } 176 }
177 EXPECT_EQ(test.policy == kReferrerPolicyDefault 177 EXPECT_EQ(test.policy == kReferrerPolicyDefault
178 ? kReferrerPolicyNoReferrerWhenDowngrade 178 ? kReferrerPolicyNoReferrerWhenDowngrade
179 : test.policy, 179 : test.policy,
180 result.referrer_policy); 180 result.referrer_policy);
181 } 181 }
182 } 182 }
183 183
184 TEST(SecurityPolicyTest, TrustworthyWhiteList) { 184 TEST(SecurityPolicyTest, TrustworthyWhiteList) {
185 const char* insecure_ur_ls[] = { 185 const char* insecure_urls[] = {
186 "http://a.test/path/to/file.html", "http://b.test/path/to/file.html", 186 "http://a.test/path/to/file.html", "http://b.test/path/to/file.html",
187 "blob:http://c.test/b3aae9c8-7f90-440d-8d7c-43aa20d72fde", 187 "blob:http://c.test/b3aae9c8-7f90-440d-8d7c-43aa20d72fde",
188 "filesystem:http://d.test/path/t/file.html", 188 "filesystem:http://d.test/path/t/file.html",
189 }; 189 };
190 190
191 for (const char* url : insecure_ur_ls) { 191 for (const char* url : insecure_urls) {
192 RefPtr<SecurityOrigin> origin = SecurityOrigin::CreateFromString(url); 192 RefPtr<SecurityOrigin> origin = SecurityOrigin::CreateFromString(url);
193 EXPECT_FALSE(origin->IsPotentiallyTrustworthy()); 193 EXPECT_FALSE(origin->IsPotentiallyTrustworthy());
194 SecurityPolicy::AddOriginTrustworthyWhiteList(origin); 194 SecurityPolicy::AddOriginTrustworthyWhiteList(origin);
195 EXPECT_TRUE(origin->IsPotentiallyTrustworthy()); 195 EXPECT_TRUE(origin->IsPotentiallyTrustworthy());
196 } 196 }
197 197
198 // Tests that adding URLs that have inner-urls to the whitelist 198 // Tests that adding URLs that have inner-urls to the whitelist
199 // takes effect on the origins of the inner-urls (and vice versa). 199 // takes effect on the origins of the inner-urls (and vice versa).
200 struct TestCase { 200 struct TestCase {
201 const char* url; 201 const char* url;
202 const char* another_url_in_origin; 202 const char* another_url_in_origin;
203 }; 203 };
204 TestCase insecure_ur_ls_with_inner_origin[] = { 204 TestCase insecure_urls_with_inner_origin[] = {
205 {"blob:http://e.test/b3aae9c8-7f90-440d-8d7c-43aa20d72fde", 205 {"blob:http://e.test/b3aae9c8-7f90-440d-8d7c-43aa20d72fde",
206 "http://e.test/foo.html"}, 206 "http://e.test/foo.html"},
207 {"filesystem:http://f.test/path/t/file.html", "http://f.test/bar.html"}, 207 {"filesystem:http://f.test/path/t/file.html", "http://f.test/bar.html"},
208 {"http://g.test/foo.html", 208 {"http://g.test/foo.html",
209 "blob:http://g.test/b3aae9c8-7f90-440d-8d7c-43aa20d72fde"}, 209 "blob:http://g.test/b3aae9c8-7f90-440d-8d7c-43aa20d72fde"},
210 {"http://h.test/bar.html", "filesystem:http://h.test/path/t/file.html"}, 210 {"http://h.test/bar.html", "filesystem:http://h.test/path/t/file.html"},
211 }; 211 };
212 for (const TestCase& test : insecure_ur_ls_with_inner_origin) { 212 for (const TestCase& test : insecure_urls_with_inner_origin) {
213 // Actually origins of both URLs should be same. 213 // Actually origins of both URLs should be same.
214 RefPtr<SecurityOrigin> origin1 = SecurityOrigin::CreateFromString(test.url); 214 RefPtr<SecurityOrigin> origin1 = SecurityOrigin::CreateFromString(test.url);
215 RefPtr<SecurityOrigin> origin2 = 215 RefPtr<SecurityOrigin> origin2 =
216 SecurityOrigin::CreateFromString(test.another_url_in_origin); 216 SecurityOrigin::CreateFromString(test.another_url_in_origin);
217 217
218 EXPECT_FALSE(origin1->IsPotentiallyTrustworthy()); 218 EXPECT_FALSE(origin1->IsPotentiallyTrustworthy());
219 EXPECT_FALSE(origin2->IsPotentiallyTrustworthy()); 219 EXPECT_FALSE(origin2->IsPotentiallyTrustworthy());
220 SecurityPolicy::AddOriginTrustworthyWhiteList(origin1); 220 SecurityPolicy::AddOriginTrustworthyWhiteList(origin1);
221 EXPECT_TRUE(origin1->IsPotentiallyTrustworthy()); 221 EXPECT_TRUE(origin1->IsPotentiallyTrustworthy());
222 EXPECT_TRUE(origin2->IsPotentiallyTrustworthy()); 222 EXPECT_TRUE(origin2->IsPotentiallyTrustworthy());
223 } 223 }
224 } 224 }
225 225
226 } // namespace blink 226 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/weborigin/SchemeRegistry.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698