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/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("aBoUt:memory"))); | 167 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("aBoUt:memory"))); |
168 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:CrASh"))); | 168 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:CrASh"))); |
169 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("abOuT:cAChe"))); | 169 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("abOuT:cAChe"))); |
170 | 170 |
171 // Requests for about: pages should be denied. | 171 // Requests for about: pages should be denied. |
172 p->GrantRequestURL(kRendererID, GURL("about:crash")); | 172 p->GrantRequestURL(kRendererID, GURL("about:crash")); |
173 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:crash"))); | 173 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("about:crash"))); |
174 | 174 |
175 // These requests for chrome:// pages should be granted. | 175 // These requests for chrome:// pages should be granted. |
176 p->GrantRequestURL(kRendererID, GURL(chrome::kTestNewTabURL)); | 176 p->GrantRequestURL(kRendererID, GURL(content::kTestNewTabURL)); |
177 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(chrome::kTestNewTabURL))); | 177 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(content::kTestNewTabURL))); |
178 | 178 |
179 p->GrantRequestURL(kRendererID, GURL(chrome::kTestHistoryURL)); | 179 p->GrantRequestURL(kRendererID, GURL(content::kTestHistoryURL)); |
180 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(chrome::kTestHistoryURL))); | 180 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(content::kTestHistoryURL))); |
181 | 181 |
182 p->GrantRequestURL(kRendererID, GURL(chrome::kTestBookmarksURL)); | 182 p->GrantRequestURL(kRendererID, GURL(content::kTestBookmarksURL)); |
183 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(chrome::kTestBookmarksURL))); | 183 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(content::kTestBookmarksURL))); |
184 | 184 |
185 p->Remove(kRendererID); | 185 p->Remove(kRendererID); |
186 } | 186 } |
187 | 187 |
188 TEST_F(ChildProcessSecurityPolicyTest, JavaScriptTest) { | 188 TEST_F(ChildProcessSecurityPolicyTest, JavaScriptTest) { |
189 ChildProcessSecurityPolicyImpl* p = | 189 ChildProcessSecurityPolicyImpl* p = |
190 ChildProcessSecurityPolicyImpl::GetInstance(); | 190 ChildProcessSecurityPolicyImpl::GetInstance(); |
191 | 191 |
192 p->Add(kRendererID); | 192 p->Add(kRendererID); |
193 | 193 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 489 |
490 // Renderers are added and removed on the UI thread, but the policy can be | 490 // Renderers are added and removed on the UI thread, but the policy can be |
491 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be | 491 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be |
492 // prepared to answer policy questions about renderers who no longer exist. | 492 // prepared to answer policy questions about renderers who no longer exist. |
493 | 493 |
494 // In this case, we default to secure behavior. | 494 // In this case, we default to secure behavior. |
495 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); | 495 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); |
496 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); | 496 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); |
497 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); | 497 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); |
498 } | 498 } |
OLD | NEW |