OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/frame/csp/CSPSourceList.h" | 5 #include "core/frame/csp/CSPSourceList.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/frame/csp/CSPSource.h" | 8 #include "core/frame/csp/CSPSource.h" |
9 #include "core/frame/csp/ContentSecurityPolicy.h" | 9 #include "core/frame/csp/ContentSecurityPolicy.h" |
10 #include "platform/network/ResourceRequest.h" | 10 #include "platform/network/ResourceRequest.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example.com/"))); | 83 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example.com/"))); |
84 EXPECT_TRUE(sourceList.matches(KURL(base, "https://example.com/"))); | 84 EXPECT_TRUE(sourceList.matches(KURL(base, "https://example.com/"))); |
85 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example.com/bar"))); | 85 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example.com/bar"))); |
86 EXPECT_TRUE(sourceList.matches(KURL(base, "http://foo.example.com/"))); | 86 EXPECT_TRUE(sourceList.matches(KURL(base, "http://foo.example.com/"))); |
87 EXPECT_TRUE(sourceList.matches(KURL(base, "http://foo.example.com/bar"))); | 87 EXPECT_TRUE(sourceList.matches(KURL(base, "http://foo.example.com/bar"))); |
88 | 88 |
89 EXPECT_FALSE(sourceList.matches(KURL(base, "data:https://example.test/"))); | 89 EXPECT_FALSE(sourceList.matches(KURL(base, "data:https://example.test/"))); |
90 EXPECT_FALSE(sourceList.matches(KURL(base, "blob:https://example.test/"))); | 90 EXPECT_FALSE(sourceList.matches(KURL(base, "blob:https://example.test/"))); |
91 EXPECT_FALSE(sourceList.matches(KURL(base, "filesystem:https://example.test/
"))); | 91 EXPECT_FALSE(sourceList.matches(KURL(base, "filesystem:https://example.test/
"))); |
| 92 EXPECT_FALSE(sourceList.matches(KURL(base, "file:///etc/hosts"))); |
| 93 EXPECT_FALSE(sourceList.matches(KURL(base, "applewebdata://example.test/")))
; |
92 } | 94 } |
93 | 95 |
94 TEST_F(CSPSourceListTest, BasicMatchingSelf) | 96 TEST_F(CSPSourceListTest, BasicMatchingSelf) |
95 { | 97 { |
96 KURL base; | 98 KURL base; |
97 String sources = "'self'"; | 99 String sources = "'self'"; |
98 CSPSourceList sourceList(csp.get(), "script-src"); | 100 CSPSourceList sourceList(csp.get(), "script-src"); |
99 parseSourceList(sourceList, sources); | 101 parseSourceList(sourceList, sources); |
100 | 102 |
101 EXPECT_FALSE(sourceList.matches(KURL(base, "http://example.com/"))); | 103 EXPECT_FALSE(sourceList.matches(KURL(base, "http://example.com/"))); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example1.com/bar/"), Resou
rceRequest::RedirectStatus::FollowedRedirect)); | 194 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example1.com/bar/"), Resou
rceRequest::RedirectStatus::FollowedRedirect)); |
193 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example2.com/bar/"), Resou
rceRequest::RedirectStatus::FollowedRedirect)); | 195 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example2.com/bar/"), Resou
rceRequest::RedirectStatus::FollowedRedirect)); |
194 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example2.com/foo/"), Resou
rceRequest::RedirectStatus::FollowedRedirect)); | 196 EXPECT_TRUE(sourceList.matches(KURL(base, "http://example2.com/foo/"), Resou
rceRequest::RedirectStatus::FollowedRedirect)); |
195 EXPECT_TRUE(sourceList.matches(KURL(base, "https://example1.com/foo/"), Reso
urceRequest::RedirectStatus::FollowedRedirect)); | 197 EXPECT_TRUE(sourceList.matches(KURL(base, "https://example1.com/foo/"), Reso
urceRequest::RedirectStatus::FollowedRedirect)); |
196 EXPECT_TRUE(sourceList.matches(KURL(base, "https://example1.com/bar/"), Reso
urceRequest::RedirectStatus::FollowedRedirect)); | 198 EXPECT_TRUE(sourceList.matches(KURL(base, "https://example1.com/bar/"), Reso
urceRequest::RedirectStatus::FollowedRedirect)); |
197 | 199 |
198 EXPECT_FALSE(sourceList.matches(KURL(base, "http://example3.com/foo/"), Reso
urceRequest::RedirectStatus::FollowedRedirect)); | 200 EXPECT_FALSE(sourceList.matches(KURL(base, "http://example3.com/foo/"), Reso
urceRequest::RedirectStatus::FollowedRedirect)); |
199 } | 201 } |
200 | 202 |
201 } // namespace blink | 203 } // namespace blink |
OLD | NEW |