| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| 9 #include "chrome/browser/safe_browsing/client_side_detection_host.h" | 10 #include "chrome/browser/safe_browsing/client_side_detection_host.h" |
| 10 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 11 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
| 11 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 13 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |
| 14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/safe_browsing/csd.pb.h" | 16 #include "chrome/common/safe_browsing/csd.pb.h" |
| 16 #include "chrome/common/safe_browsing/safebrowsing_messages.h" | 17 #include "chrome/common/safe_browsing/safebrowsing_messages.h" |
| 17 #include "chrome/test/testing_profile.h" | 18 #include "chrome/test/testing_profile.h" |
| 18 #include "chrome/test/ui_test_utils.h" | 19 #include "chrome/test/ui_test_utils.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 const bool kFalse = false; | 42 const bool kFalse = false; |
| 42 const bool kTrue = true; | 43 const bool kTrue = true; |
| 43 } | 44 } |
| 44 | 45 |
| 45 namespace safe_browsing { | 46 namespace safe_browsing { |
| 46 namespace { | 47 namespace { |
| 47 MATCHER_P(EqualsProto, other, "") { | 48 MATCHER_P(EqualsProto, other, "") { |
| 48 return other.SerializeAsString() == arg.SerializeAsString(); | 49 return other.SerializeAsString() == arg.SerializeAsString(); |
| 49 } | 50 } |
| 50 | 51 |
| 52 ACTION(QuitUIMessageLoop) { |
| 53 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 54 MessageLoopForUI::current()->Quit(); |
| 55 } |
| 56 |
| 51 class MockClientSideDetectionService : public ClientSideDetectionService { | 57 class MockClientSideDetectionService : public ClientSideDetectionService { |
| 52 public: | 58 public: |
| 53 MockClientSideDetectionService() : ClientSideDetectionService(NULL) {} | 59 MockClientSideDetectionService() : ClientSideDetectionService(NULL) {} |
| 54 virtual ~MockClientSideDetectionService() {}; | 60 virtual ~MockClientSideDetectionService() {}; |
| 55 | 61 |
| 56 MOCK_METHOD2(SendClientReportPhishingRequest, | 62 MOCK_METHOD2(SendClientReportPhishingRequest, |
| 57 void(ClientPhishingRequest*, | 63 void(ClientPhishingRequest*, |
| 58 ClientReportPhishingRequestCallback*)); | 64 ClientReportPhishingRequestCallback*)); |
| 59 MOCK_CONST_METHOD1(IsPrivateIPAddress, bool(const std::string&)); | 65 MOCK_CONST_METHOD1(IsPrivateIPAddress, bool(const std::string&)); |
| 60 MOCK_METHOD2(GetValidCachedResult, bool(const GURL&, bool*)); | 66 MOCK_METHOD2(GetValidCachedResult, bool(const GURL&, bool*)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 88 }; | 94 }; |
| 89 | 95 |
| 90 class MockTestingProfile : public TestingProfile { | 96 class MockTestingProfile : public TestingProfile { |
| 91 public: | 97 public: |
| 92 MockTestingProfile() {} | 98 MockTestingProfile() {} |
| 93 virtual ~MockTestingProfile() {} | 99 virtual ~MockTestingProfile() {} |
| 94 | 100 |
| 95 MOCK_METHOD0(IsOffTheRecord, bool()); | 101 MOCK_METHOD0(IsOffTheRecord, bool()); |
| 96 }; | 102 }; |
| 97 | 103 |
| 104 class MockBrowserFeatureExtractor : public BrowserFeatureExtractor { |
| 105 public: |
| 106 explicit MockBrowserFeatureExtractor(TabContents* tab) |
| 107 : BrowserFeatureExtractor(tab) {} |
| 108 virtual ~MockBrowserFeatureExtractor() {} |
| 109 |
| 110 MOCK_METHOD2(ExtractFeatures, void(ClientPhishingRequest*, |
| 111 BrowserFeatureExtractor::DoneCallback*)); |
| 112 }; |
| 113 |
| 98 // Helper function which quits the UI message loop from the IO message loop. | 114 // Helper function which quits the UI message loop from the IO message loop. |
| 99 void QuitUIMessageLoop() { | 115 void QuitUIMessageLoopFromIO() { |
| 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 101 BrowserThread::PostTask(BrowserThread::UI, | 117 BrowserThread::PostTask(BrowserThread::UI, |
| 102 FROM_HERE, | 118 FROM_HERE, |
| 103 new MessageLoop::QuitTask()); | 119 new MessageLoop::QuitTask()); |
| 104 } | 120 } |
| 105 } // namespace | 121 } // namespace |
| 106 | 122 |
| 107 class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness { | 123 class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness { |
| 108 public: | 124 public: |
| 109 virtual void SetUp() { | 125 virtual void SetUp() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 137 void OnDetectedPhishingSite(const std::string& verdict_str) { | 153 void OnDetectedPhishingSite(const std::string& verdict_str) { |
| 138 csd_host_->OnDetectedPhishingSite(verdict_str); | 154 csd_host_->OnDetectedPhishingSite(verdict_str); |
| 139 } | 155 } |
| 140 | 156 |
| 141 void FlushIOMessageLoop() { | 157 void FlushIOMessageLoop() { |
| 142 // If there was a message posted on the IO thread to display the | 158 // If there was a message posted on the IO thread to display the |
| 143 // interstitial page we know that it would have been posted before | 159 // interstitial page we know that it would have been posted before |
| 144 // we put the quit message there. | 160 // we put the quit message there. |
| 145 BrowserThread::PostTask(BrowserThread::IO, | 161 BrowserThread::PostTask(BrowserThread::IO, |
| 146 FROM_HERE, | 162 FROM_HERE, |
| 147 NewRunnableFunction(&QuitUIMessageLoop)); | 163 NewRunnableFunction(&QuitUIMessageLoopFromIO)); |
| 148 MessageLoop::current()->Run(); | 164 MessageLoop::current()->Run(); |
| 149 } | 165 } |
| 150 | 166 |
| 151 void ExpectPreClassificationChecks(const GURL& url, | 167 void ExpectPreClassificationChecks(const GURL& url, |
| 152 const bool* is_private, | 168 const bool* is_private, |
| 153 const bool* is_incognito, | 169 const bool* is_incognito, |
| 154 const bool* match_csd_whitelist, | 170 const bool* match_csd_whitelist, |
| 155 const bool* get_valid_cached_result, | 171 const bool* get_valid_cached_result, |
| 156 const bool* is_in_cache, | 172 const bool* is_in_cache, |
| 157 const bool* over_report_limit) { | 173 const bool* over_report_limit) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 184 void WaitAndCheckPreClassificationChecks() { | 200 void WaitAndCheckPreClassificationChecks() { |
| 185 // Wait for CheckCsdWhitelist to be called if at all. | 201 // Wait for CheckCsdWhitelist to be called if at all. |
| 186 FlushIOMessageLoop(); | 202 FlushIOMessageLoop(); |
| 187 // Checks for CheckCache() to be called if at all. | 203 // Checks for CheckCache() to be called if at all. |
| 188 MessageLoop::current()->RunAllPending(); | 204 MessageLoop::current()->RunAllPending(); |
| 189 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 205 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 190 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 206 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
| 191 EXPECT_TRUE(Mock::VerifyAndClear(mock_profile_)); | 207 EXPECT_TRUE(Mock::VerifyAndClear(mock_profile_)); |
| 192 } | 208 } |
| 193 | 209 |
| 210 void SetFeatureExtractor(BrowserFeatureExtractor* extractor) { |
| 211 csd_host_->feature_extractor_.reset(extractor); |
| 212 } |
| 213 |
| 194 protected: | 214 protected: |
| 195 ClientSideDetectionHost* csd_host_; | 215 ClientSideDetectionHost* csd_host_; |
| 196 scoped_ptr<StrictMock<MockClientSideDetectionService> > csd_service_; | 216 scoped_ptr<StrictMock<MockClientSideDetectionService> > csd_service_; |
| 197 scoped_refptr<StrictMock<MockSafeBrowsingService> > sb_service_; | 217 scoped_refptr<StrictMock<MockSafeBrowsingService> > sb_service_; |
| 198 MockTestingProfile* mock_profile_; // We don't own this object | 218 MockTestingProfile* mock_profile_; // We don't own this object |
| 199 | 219 |
| 200 private: | 220 private: |
| 201 scoped_ptr<BrowserThread> ui_thread_; | 221 scoped_ptr<BrowserThread> ui_thread_; |
| 202 scoped_ptr<BrowserThread> io_thread_; | 222 scoped_ptr<BrowserThread> io_thread_; |
| 203 }; | 223 }; |
| 204 | 224 |
| 205 TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteInvalidVerdict) { | 225 TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteInvalidVerdict) { |
| 206 // Case 0: renderer sends an invalid verdict string that we're unable to | 226 // Case 0: renderer sends an invalid verdict string that we're unable to |
| 207 // parse. | 227 // parse. |
| 208 EXPECT_CALL(*csd_service_, SendClientReportPhishingRequest(_, _)).Times(0); | 228 MockBrowserFeatureExtractor* mock_extractor = new MockBrowserFeatureExtractor( |
| 229 contents()); |
| 230 SetFeatureExtractor(mock_extractor); // The host class takes ownership. |
| 231 EXPECT_CALL(*mock_extractor, ExtractFeatures(_, _)).Times(0); |
| 209 OnDetectedPhishingSite("Invalid Protocol Buffer"); | 232 OnDetectedPhishingSite("Invalid Protocol Buffer"); |
| 210 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 233 EXPECT_TRUE(Mock::VerifyAndClear(mock_extractor)); |
| 211 } | 234 } |
| 212 | 235 |
| 213 TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteNotPhishing) { | 236 TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteNotPhishing) { |
| 214 // Case 1: client thinks the page is phishing. The server does not agree. | 237 // Case 1: client thinks the page is phishing. The server does not agree. |
| 215 // No interstitial is shown. | 238 // No interstitial is shown. |
| 216 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb; | 239 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb; |
| 217 ClientPhishingRequest verdict; | 240 ClientPhishingRequest verdict; |
| 218 verdict.set_url("http://phishingurl.com/"); | 241 verdict.set_url("http://phishingurl.com/"); |
| 219 verdict.set_client_score(1.0f); | 242 verdict.set_client_score(1.0f); |
| 220 verdict.set_is_phishing(true); | 243 verdict.set_is_phishing(true); |
| 221 | 244 |
| 222 EXPECT_CALL(*csd_service_, | 245 EXPECT_CALL(*csd_service_, |
| 223 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) | 246 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
| 224 .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb))); | 247 .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop())); |
| 225 OnDetectedPhishingSite(verdict.SerializeAsString()); | 248 OnDetectedPhishingSite(verdict.SerializeAsString()); |
| 249 MessageLoop::current()->Run(); |
| 226 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 250 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 227 ASSERT_TRUE(cb); | 251 ASSERT_TRUE(cb); |
| 228 | 252 |
| 229 // Make sure DoDisplayBlockingPage is not going to be called. | 253 // Make sure DoDisplayBlockingPage is not going to be called. |
| 230 EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_)).Times(0); | 254 EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_)).Times(0); |
| 231 cb->Run(GURL(verdict.url()), false); | 255 cb->Run(GURL(verdict.url()), false); |
| 232 delete cb; | 256 delete cb; |
| 233 MessageLoop::current()->RunAllPending(); | 257 MessageLoop::current()->RunAllPending(); |
| 234 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 258 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
| 235 } | 259 } |
| 236 | 260 |
| 237 TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteDisabled) { | 261 TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteDisabled) { |
| 238 // Case 2: client thinks the page is phishing and so does the server but | 262 // Case 2: client thinks the page is phishing and so does the server but |
| 239 // showing the interstitial is disabled => no interstitial is shown. | 263 // showing the interstitial is disabled => no interstitial is shown. |
| 240 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb; | 264 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb; |
| 241 ClientPhishingRequest verdict; | 265 ClientPhishingRequest verdict; |
| 242 verdict.set_url("http://phishingurl.com/"); | 266 verdict.set_url("http://phishingurl.com/"); |
| 243 verdict.set_client_score(1.0f); | 267 verdict.set_client_score(1.0f); |
| 244 verdict.set_is_phishing(true); | 268 verdict.set_is_phishing(true); |
| 245 | 269 |
| 246 EXPECT_CALL(*csd_service_, | 270 EXPECT_CALL(*csd_service_, |
| 247 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) | 271 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
| 248 .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb))); | 272 .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop())); |
| 249 OnDetectedPhishingSite(verdict.SerializeAsString()); | 273 OnDetectedPhishingSite(verdict.SerializeAsString()); |
| 274 MessageLoop::current()->Run(); |
| 250 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 275 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 251 ASSERT_TRUE(cb); | 276 ASSERT_TRUE(cb); |
| 252 | 277 |
| 253 // Make sure DoDisplayBlockingPage is not going to be called. | 278 // Make sure DoDisplayBlockingPage is not going to be called. |
| 254 EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_)).Times(0); | 279 EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_)).Times(0); |
| 255 cb->Run(GURL(verdict.url()), false); | 280 cb->Run(GURL(verdict.url()), false); |
| 256 delete cb; | 281 delete cb; |
| 257 MessageLoop::current()->RunAllPending(); | 282 MessageLoop::current()->RunAllPending(); |
| 258 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 283 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
| 259 } | 284 } |
| 260 | 285 |
| 261 TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteShowInterstitial) { | 286 TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteShowInterstitial) { |
| 262 // Case 3: client thinks the page is phishing and so does the server. | 287 // Case 3: client thinks the page is phishing and so does the server. |
| 263 // We show an interstitial. | 288 // We show an interstitial. |
| 264 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb; | 289 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb; |
| 265 GURL phishing_url("http://phishingurl.com/"); | 290 GURL phishing_url("http://phishingurl.com/"); |
| 266 ClientPhishingRequest verdict; | 291 ClientPhishingRequest verdict; |
| 267 verdict.set_url(phishing_url.spec()); | 292 verdict.set_url(phishing_url.spec()); |
| 268 verdict.set_client_score(1.0f); | 293 verdict.set_client_score(1.0f); |
| 269 verdict.set_is_phishing(true); | 294 verdict.set_is_phishing(true); |
| 270 | 295 |
| 271 EXPECT_CALL(*csd_service_, | 296 EXPECT_CALL(*csd_service_, |
| 272 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) | 297 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
| 273 .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb))); | 298 .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop())); |
| 274 OnDetectedPhishingSite(verdict.SerializeAsString()); | 299 OnDetectedPhishingSite(verdict.SerializeAsString()); |
| 300 MessageLoop::current()->Run(); |
| 275 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 301 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 276 ASSERT_TRUE(cb); | 302 ASSERT_TRUE(cb); |
| 277 | 303 |
| 278 SafeBrowsingService::UnsafeResource resource; | 304 SafeBrowsingService::UnsafeResource resource; |
| 279 EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_)) | 305 EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_)) |
| 280 .WillOnce(SaveArg<0>(&resource)); | 306 .WillOnce(SaveArg<0>(&resource)); |
| 281 cb->Run(phishing_url, true); | 307 cb->Run(phishing_url, true); |
| 282 delete cb; | 308 delete cb; |
| 283 | 309 |
| 284 MessageLoop::current()->RunAllPending(); | 310 MessageLoop::current()->RunAllPending(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 315 // a single interstitial is shown for the second URL. | 341 // a single interstitial is shown for the second URL. |
| 316 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb; | 342 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb; |
| 317 GURL phishing_url("http://phishingurl.com/"); | 343 GURL phishing_url("http://phishingurl.com/"); |
| 318 ClientPhishingRequest verdict; | 344 ClientPhishingRequest verdict; |
| 319 verdict.set_url(phishing_url.spec()); | 345 verdict.set_url(phishing_url.spec()); |
| 320 verdict.set_client_score(1.0f); | 346 verdict.set_client_score(1.0f); |
| 321 verdict.set_is_phishing(true); | 347 verdict.set_is_phishing(true); |
| 322 | 348 |
| 323 EXPECT_CALL(*csd_service_, | 349 EXPECT_CALL(*csd_service_, |
| 324 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) | 350 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
| 325 .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb))); | 351 .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop())); |
| 326 OnDetectedPhishingSite(verdict.SerializeAsString()); | 352 OnDetectedPhishingSite(verdict.SerializeAsString()); |
| 353 MessageLoop::current()->Run(); |
| 327 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 354 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 328 ASSERT_TRUE(cb); | 355 ASSERT_TRUE(cb); |
| 329 GURL other_phishing_url("http://other_phishing_url.com/bla"); | 356 GURL other_phishing_url("http://other_phishing_url.com/bla"); |
| 330 ExpectPreClassificationChecks(other_phishing_url, &kFalse, &kFalse, &kFalse, | 357 ExpectPreClassificationChecks(other_phishing_url, &kFalse, &kFalse, &kFalse, |
| 331 &kFalse, &kFalse, &kFalse); | 358 &kFalse, &kFalse, &kFalse); |
| 332 // We navigate away. The callback cb should be revoked. | 359 // We navigate away. The callback cb should be revoked. |
| 333 NavigateAndCommit(other_phishing_url); | 360 NavigateAndCommit(other_phishing_url); |
| 334 // Wait for the pre-classification checks to finish for other_phishing_url. | 361 // Wait for the pre-classification checks to finish for other_phishing_url. |
| 335 WaitAndCheckPreClassificationChecks(); | 362 WaitAndCheckPreClassificationChecks(); |
| 336 | 363 |
| 337 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb_other; | 364 ClientSideDetectionService::ClientReportPhishingRequestCallback* cb_other; |
| 338 verdict.set_url(other_phishing_url.spec()); | 365 verdict.set_url(other_phishing_url.spec()); |
| 339 verdict.set_client_score(0.8f); | 366 verdict.set_client_score(0.8f); |
| 340 EXPECT_CALL(*csd_service_, | 367 EXPECT_CALL(*csd_service_, |
| 341 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) | 368 SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
| 342 .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb_other))); | 369 .WillOnce(DoAll(DeleteArg<0>(), |
| 370 SaveArg<1>(&cb_other), |
| 371 QuitUIMessageLoop())); |
| 343 OnDetectedPhishingSite(verdict.SerializeAsString()); | 372 OnDetectedPhishingSite(verdict.SerializeAsString()); |
| 373 MessageLoop::current()->Run(); |
| 344 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); | 374 EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
| 345 ASSERT_TRUE(cb_other); | 375 ASSERT_TRUE(cb_other); |
| 346 | 376 |
| 347 // We expect that the interstitial is shown for the second phishing URL and | 377 // We expect that the interstitial is shown for the second phishing URL and |
| 348 // not for the first phishing URL. | 378 // not for the first phishing URL. |
| 349 SafeBrowsingService::UnsafeResource resource; | 379 SafeBrowsingService::UnsafeResource resource; |
| 350 EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_)) | 380 EXPECT_CALL(*sb_service_, DoDisplayBlockingPage(_)) |
| 351 .WillOnce(SaveArg<0>(&resource)); | 381 .WillOnce(SaveArg<0>(&resource)); |
| 352 | 382 |
| 353 cb->Run(phishing_url, true); // Should have no effect. | 383 cb->Run(phishing_url, true); // Should have no effect. |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); | 592 EXPECT_TRUE(Mock::VerifyAndClear(sb_service_.get())); |
| 563 EXPECT_EQ(url, resource.url); | 593 EXPECT_EQ(url, resource.url); |
| 564 EXPECT_EQ(url, resource.original_url); | 594 EXPECT_EQ(url, resource.original_url); |
| 565 delete resource.client; | 595 delete resource.client; |
| 566 msg = process()->sink().GetFirstMessageMatching( | 596 msg = process()->sink().GetFirstMessageMatching( |
| 567 SafeBrowsingMsg_StartPhishingDetection::ID); | 597 SafeBrowsingMsg_StartPhishingDetection::ID); |
| 568 ASSERT_FALSE(msg); | 598 ASSERT_FALSE(msg); |
| 569 } | 599 } |
| 570 | 600 |
| 571 } // namespace safe_browsing | 601 } // namespace safe_browsing |
| OLD | NEW |