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

Unified Diff: content/browser/child_process_security_policy_unittest.cc

Issue 1917073002: Block webpages from navigating to view-source URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete layout tests Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/child_process_security_policy_unittest.cc
diff --git a/content/browser/child_process_security_policy_unittest.cc b/content/browser/child_process_security_policy_unittest.cc
index 455da447dd306ef0e36f1fb473535f8f3b856f77..24aa45bc21f050f00bea4642e7f5fe50674589a6 100644
--- a/content/browser/child_process_security_policy_unittest.cc
+++ b/content/browser/child_process_security_policy_unittest.cc
@@ -169,21 +169,19 @@ TEST_F(ChildProcessSecurityPolicyTest, StandardSchemesTest) {
EXPECT_TRUE(p->CanCommitURL(
kRendererID, GURL("filesystem:http://localhost/temporary/a.gif")));
- // Safe to request but not commit.
- EXPECT_TRUE(p->CanRequestURL(kRendererID,
- GURL("view-source:http://www.google.com/")));
- EXPECT_FALSE(p->CanCommitURL(kRendererID,
- GURL("view-source:http://www.google.com/")));
-
// Dangerous to request or commit.
EXPECT_FALSE(p->CanRequestURL(kRendererID,
GURL("file:///etc/passwd")));
EXPECT_FALSE(p->CanRequestURL(kRendererID,
GURL("chrome://foo/bar")));
+ EXPECT_FALSE(p->CanRequestURL(kRendererID,
+ GURL("view-source:http://www.google.com/")));
EXPECT_FALSE(p->CanCommitURL(kRendererID,
GURL("file:///etc/passwd")));
EXPECT_FALSE(p->CanCommitURL(kRendererID,
GURL("chrome://foo/bar")));
+ EXPECT_FALSE(
+ p->CanCommitURL(kRendererID, GURL("view-source:http://www.google.com/")));
p->Remove(kRendererID);
}
@@ -300,9 +298,9 @@ TEST_F(ChildProcessSecurityPolicyTest, ViewSource) {
p->Add(kRendererID);
- // View source is determined by the embedded scheme.
- EXPECT_TRUE(p->CanRequestURL(kRendererID,
- GURL("view-source:http://www.google.com/")));
+ // Child processes cannot request view source URLs.
+ EXPECT_FALSE(p->CanRequestURL(kRendererID,
+ GURL("view-source:http://www.google.com/")));
EXPECT_FALSE(p->CanRequestURL(kRendererID,
GURL("view-source:file:///etc/passwd")));
EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));
@@ -319,16 +317,13 @@ TEST_F(ChildProcessSecurityPolicyTest, ViewSource) {
EXPECT_FALSE(p->CanCommitURL(
kRendererID, GURL("view-source:view-source:http://www.google.com/")));
-
p->GrantRequestURL(kRendererID, GURL("view-source:file:///etc/passwd"));
- // View source needs to be able to request the embedded scheme.
- EXPECT_TRUE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));
- EXPECT_TRUE(p->CanCommitURL(kRendererID, GURL("file:///etc/passwd")));
- EXPECT_TRUE(p->CanRequestURL(kRendererID,
- GURL("view-source:file:///etc/passwd")));
+ EXPECT_FALSE(p->CanRequestURL(kRendererID, GURL("file:///etc/passwd")));
+ EXPECT_FALSE(p->CanCommitURL(kRendererID, GURL("file:///etc/passwd")));
+ EXPECT_FALSE(
+ p->CanRequestURL(kRendererID, GURL("view-source:file:///etc/passwd")));
EXPECT_FALSE(p->CanCommitURL(kRendererID,
GURL("view-source:file:///etc/passwd")));
-
p->Remove(kRendererID);
}
« no previous file with comments | « content/browser/child_process_security_policy_impl.cc ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698