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

Side by Side Diff: content/browser/child_process_security_policy_unittest.cc

Issue 10820056: Move the render process host tests in content to chrome. These test chrome specific behavior with t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(content::kTestNewTabURL)); 176 p->GrantRequestURL(kRendererID, GURL(content::kTestNewTabURL));
177 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(content::kTestNewTabURL))); 177 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(content::kTestNewTabURL)));
178 178
179 p->GrantRequestURL(kRendererID, GURL(content::kTestHistoryURL));
180 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(content::kTestHistoryURL)));
181
182 p->GrantRequestURL(kRendererID, GURL(content::kTestBookmarksURL));
183 EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL(content::kTestBookmarksURL)));
Charlie Reis 2012/07/27 19:51:09 Shouldn't we check these in a chrome test instead
jam 2012/07/27 19:54:45 I guess I didn't understand how this is different
Charlie Reis 2012/07/27 20:03:19 To be honest, I'm not sure why there are separate
msw 2012/07/27 20:59:05 I don't remember exactly why I added these checks.
Charlie Reis 2012/07/27 21:35:43 Ok. LGTM, then, but it might be good to get Tom's
184
185 p->Remove(kRendererID); 179 p->Remove(kRendererID);
186 } 180 }
187 181
188 TEST_F(ChildProcessSecurityPolicyTest, JavaScriptTest) { 182 TEST_F(ChildProcessSecurityPolicyTest, JavaScriptTest) {
189 ChildProcessSecurityPolicyImpl* p = 183 ChildProcessSecurityPolicyImpl* p =
190 ChildProcessSecurityPolicyImpl::GetInstance(); 184 ChildProcessSecurityPolicyImpl::GetInstance();
191 185
192 p->Add(kRendererID); 186 p->Add(kRendererID);
193 187
194 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("javascript:alert('xss')"))); 188 EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("javascript:alert('xss')")));
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 483
490 // Renderers are added and removed on the UI thread, but the policy can be 484 // 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 485 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be
492 // prepared to answer policy questions about renderers who no longer exist. 486 // prepared to answer policy questions about renderers who no longer exist.
493 487
494 // In this case, we default to secure behavior. 488 // In this case, we default to secure behavior.
495 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); 489 EXPECT_FALSE(p->CanRequestURL(kRendererID, url));
496 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); 490 EXPECT_FALSE(p->CanReadFile(kRendererID, file));
497 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); 491 EXPECT_FALSE(p->HasWebUIBindings(kRendererID));
498 } 492 }
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | content/browser/renderer_host/render_process_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698