Chromium Code Reviews| Index: chrome/browser/safe_browsing/client_side_detection_host_unittest.cc |
| 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 9d9fc092b95e21136bab248272c8cc57b22b965d..b081c78b6ee1327d87e666d3d90ab67f02e0c9cb 100644 |
| --- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc |
| +++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc |
| @@ -415,7 +415,6 @@ class ClientSideDetectionHostTest : public ChromeRenderViewHostTestHarness { |
| EXPECT_NE(web_contents()->GetRenderViewHost()->GetRoutingID(), |
| pending_rvh()->GetRoutingID()); |
| } |
| - ASSERT_FALSE(csd_host_->DidShowSBInterstitial()); |
| content::WebContentsTester::For(web_contents())->CommitPendingNavigation(); |
| ASSERT_FALSE(csd_host_->DidShowSBInterstitial()); |
| @@ -748,6 +747,55 @@ TEST_F(ClientSideDetectionHostTest, |
| WaitAndCheckPreClassificationChecks(); |
| } |
| +TEST_F( |
| + ClientSideDetectionHostTest, |
| + OnPhishingDetectionDoneVerdictNotPhishingButSBMatchOnSubresourceWhileNavPending) { |
|
Charlie Reis
2015/12/11 05:39:24
That's a mouthful! Would a shorter name be worthw
mattm
2015/12/15 01:42:25
It's following the same convention as other tests
|
| + // When a malware hit happens on a committed page while a slow pending load is |
| + // in progress, the csd report should be sent for the committed page. |
| + |
| + // Do an initial navigation to a safe host. |
| + GURL start_url("http://safe.example.com/"); |
| + ExpectPreClassificationChecks( |
| + start_url, &kFalse, &kFalse, &kFalse, &kFalse, &kFalse, &kFalse, &kFalse, |
| + &kFalse); |
| + NavigateAndCommit(start_url); |
| + WaitAndCheckPreClassificationChecks(); |
| + |
| + // Now navigate to a different host which does not have a SB hit. |
| + GURL url("http://not-malware-not-phishing-but-malware-subresource.com/"); |
| + ClientPhishingRequest verdict; |
| + verdict.set_url(url.spec()); |
| + verdict.set_client_score(0.1f); |
| + verdict.set_is_phishing(false); |
| + |
| + ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, |
| + &kFalse, &kFalse, &kFalse, &kFalse); |
| + NavigateWithoutSBHitAndCommit(url); |
| + |
| + // Simulate a subresource malware hit on committed page. |
| + SetUnsafeSubResourceForCurrent(); |
| + |
| + // Create a pending navigation, but don't commit it. |
| + GURL pending_url("http://slow.example.com/"); |
| + content::WebContentsTester::For(web_contents())->StartNavigation(pending_url); |
| + |
| + WaitAndCheckPreClassificationChecks(); |
| + |
| + // Even though we have a pending navigation, the DidShowSBInterstitial check |
| + // should apply to the committed navigation, so we should get a report even |
| + // though the verdict has is_phishing = false. |
| + EXPECT_CALL(*csd_service_, |
| + SendClientReportPhishingRequest( |
| + Pointee(PartiallyEqualVerdict(verdict)), _, CallbackIsNull())) |
| + .WillOnce(DoAll(DeleteArg<0>(), QuitUIMessageLoop())); |
| + std::vector<GURL> redirect_chain; |
| + redirect_chain.push_back(url); |
| + SetRedirectChain(redirect_chain); |
| + OnPhishingDetectionDone(verdict.SerializeAsString()); |
| + base::MessageLoop::current()->Run(); |
| + EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get())); |
| +} |
| + |
| TEST_F(ClientSideDetectionHostTest, |
| DidStopLoadingShowMalwareInterstitial) { |
| // Case 9: client thinks the page match malware IP and so does the server. |