diff options
author | bryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 19:19:52 +0000 |
---|---|---|
committer | bryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 19:19:52 +0000 |
commit | a3c8e9989cdc5a948818b2612e698fada2b66414 (patch) | |
tree | f4c87a45cb3c0f065029be8b0938977bdc181ff8 /chrome/browser/safe_browsing/client_side_detection_host_unittest.cc | |
parent | 31c7e3b5078faa1d42d8f895f18f408887a8f570 (diff) | |
download | chromium_src-a3c8e9989cdc5a948818b2612e698fada2b66414.zip chromium_src-a3c8e9989cdc5a948818b2612e698fada2b66414.tar.gz chromium_src-a3c8e9989cdc5a948818b2612e698fada2b66414.tar.bz2 |
Only run the phishing classifier on HTML and XHTML documents.
This also adds support to TestRenderViewHost for changing the MIME type that
it reports in the ViewHostMsg_FrameNavigate_Params.
BUG=none
TEST=ClientSideDetectionHostTest.ShouldClassifyUrl
Review URL: http://codereview.chromium.org/6691036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80505 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/client_side_detection_host_unittest.cc')
-rw-r--r-- | chrome/browser/safe_browsing/client_side_detection_host_unittest.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc index 0943535..e56f908 100644 --- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc +++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc @@ -433,6 +433,24 @@ TEST_F(ClientSideDetectionHostTest, ShouldClassifyUrl) { SafeBrowsingMsg_StartPhishingDetection::ID); ASSERT_FALSE(msg); + // Check that XHTML is supported, in addition to the default HTML type. + // Note: for this test to work correctly, the new URL must be on the + // same domain as the previous URL, otherwise it will create a new + // RenderViewHost that won't have the mime type set. + url = GURL("http://host.com/xhtml"); + rvh()->set_contents_mime_type("application/xhtml+xml"); + ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, + &kFalse, &kFalse); + NavigateAndCommit(url); + WaitAndCheckPreClassificationChecks(); + msg = process()->sink().GetFirstMessageMatching( + SafeBrowsingMsg_StartPhishingDetection::ID); + ASSERT_TRUE(msg); + SafeBrowsingMsg_StartPhishingDetection::Read(msg, &actual_url); + EXPECT_EQ(url, actual_url.a); + EXPECT_EQ(rvh()->routing_id(), msg->routing_id()); + process()->sink().ClearMessages(); + // Navigate to a new host, which should cause another IPC. url = GURL("http://host2.com/"); ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, @@ -447,6 +465,19 @@ TEST_F(ClientSideDetectionHostTest, ShouldClassifyUrl) { EXPECT_EQ(rvh()->routing_id(), msg->routing_id()); process()->sink().ClearMessages(); + // If the mime type is not one that we support, no IPC should be triggered. + // Note: for this test to work correctly, the new URL must be on the + // same domain as the previous URL, otherwise it will create a new + // RenderViewHost that won't have the mime type set. + url = GURL("http://host2.com/image.jpg"); + rvh()->set_contents_mime_type("image/jpeg"); + ExpectPreClassificationChecks(url, NULL, NULL, NULL, NULL, NULL, NULL); + NavigateAndCommit(url); + WaitAndCheckPreClassificationChecks(); + msg = process()->sink().GetFirstMessageMatching( + SafeBrowsingMsg_StartPhishingDetection::ID); + ASSERT_FALSE(msg); + // If IsPrivateIPAddress returns true, no IPC should be triggered. url = GURL("http://host3.com/"); ExpectPreClassificationChecks(url, &kTrue, NULL, NULL, NULL, NULL, NULL); |