OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "content/browser/child_process_security_policy_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 EXPECT_TRUE(p->CanCommitURL(kRendererID, url_foo1)); | 886 EXPECT_TRUE(p->CanCommitURL(kRendererID, url_foo1)); |
887 EXPECT_TRUE(p->CanCommitURL(kRendererID, url_foo2)); | 887 EXPECT_TRUE(p->CanCommitURL(kRendererID, url_foo2)); |
888 EXPECT_TRUE(p->CanCommitURL(kRendererID, url_bar)); | 888 EXPECT_TRUE(p->CanCommitURL(kRendererID, url_bar)); |
889 EXPECT_TRUE(p->CanSetAsOriginHeader(kRendererID, url_foo1)); | 889 EXPECT_TRUE(p->CanSetAsOriginHeader(kRendererID, url_foo1)); |
890 EXPECT_TRUE(p->CanSetAsOriginHeader(kRendererID, url_foo2)); | 890 EXPECT_TRUE(p->CanSetAsOriginHeader(kRendererID, url_foo2)); |
891 EXPECT_TRUE(p->CanSetAsOriginHeader(kRendererID, url_bar)); | 891 EXPECT_TRUE(p->CanSetAsOriginHeader(kRendererID, url_bar)); |
892 | 892 |
893 p->Remove(kRendererID); | 893 p->Remove(kRendererID); |
894 } | 894 } |
895 | 895 |
| 896 // Verifies parsing logic that extracts origins from --isolate-origins. |
| 897 TEST_F(ChildProcessSecurityPolicyTest, IsolateOriginsFromCommandLine) { |
| 898 // Invalid and unique origins are not permitted. |
| 899 auto* policy = ChildProcessSecurityPolicyImpl::GetInstance(); |
| 900 policy->AddIsolatedOriginsFromCommandLine("foo"); |
| 901 policy->AddIsolatedOriginsFromCommandLine(""); |
| 902 policy->AddIsolatedOriginsFromCommandLine("about:blank"); |
| 903 EXPECT_EQ(0U, policy->isolated_origins_.size()); |
| 904 |
| 905 policy->AddIsolatedOriginsFromCommandLine("http://isolated.foo.com"); |
| 906 EXPECT_EQ(1U, policy->isolated_origins_.size()); |
| 907 EXPECT_TRUE( |
| 908 policy->IsIsolatedOrigin(url::Origin(GURL("http://isolated.foo.com")))); |
| 909 |
| 910 policy->AddIsolatedOriginsFromCommandLine( |
| 911 "http://a.com,https://b.com,,https://c.com:8000"); |
| 912 EXPECT_EQ(4U, policy->isolated_origins_.size()); |
| 913 EXPECT_TRUE( |
| 914 policy->IsIsolatedOrigin(url::Origin(GURL("http://isolated.foo.com")))); |
| 915 EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(GURL("http://a.com")))); |
| 916 EXPECT_TRUE(policy->IsIsolatedOrigin(url::Origin(GURL("https://b.com")))); |
| 917 EXPECT_TRUE( |
| 918 policy->IsIsolatedOrigin(url::Origin(GURL("https://c.com:8000")))); |
| 919 } |
| 920 |
896 } // namespace content | 921 } // namespace content |
OLD | NEW |