| OLD | NEW |
| 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 // This test creates a fake safebrowsing service, where we can inject known- | 5 // This test creates a fake safebrowsing service, where we can inject known- |
| 6 // threat urls. It then uses a real browser to go to these urls, and sends | 6 // threat urls. It then uses a real browser to go to these urls, and sends |
| 7 // "goback" or "proceed" commands and verifies they work. | 7 // "goback" or "proceed" commands and verifies they work. |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 content::RunMessageLoop(); | 259 content::RunMessageLoop(); |
| 260 EXPECT_TRUE(got_dom_); | 260 EXPECT_TRUE(got_dom_); |
| 261 } | 261 } |
| 262 | 262 |
| 263 private: | 263 private: |
| 264 ~FakeMalwareDetails() override {} | 264 ~FakeMalwareDetails() override {} |
| 265 | 265 |
| 266 void OnDOMDetailsDone() { | 266 void OnDOMDetailsDone() { |
| 267 got_dom_ = true; | 267 got_dom_ = true; |
| 268 if (waiting_) { | 268 if (waiting_) { |
| 269 base::MessageLoopForUI::current()->Quit(); | 269 base::MessageLoopForUI::current()->QuitWhenIdle(); |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 | 272 |
| 273 // Some logic to figure out if we should wait for the dom details or not. | 273 // Some logic to figure out if we should wait for the dom details or not. |
| 274 // These variables should only be accessed in the UI thread. | 274 // These variables should only be accessed in the UI thread. |
| 275 bool got_dom_; | 275 bool got_dom_; |
| 276 bool waiting_; | 276 bool waiting_; |
| 277 }; | 277 }; |
| 278 | 278 |
| 279 class TestMalwareDetailsFactory : public MalwareDetailsFactory { | 279 class TestMalwareDetailsFactory : public MalwareDetailsFactory { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 308 wait_for_delete_(false) { | 308 wait_for_delete_(false) { |
| 309 // Don't wait the whole 3 seconds for the browser test. | 309 // Don't wait the whole 3 seconds for the browser test. |
| 310 malware_details_proceed_delay_ms_ = 100; | 310 malware_details_proceed_delay_ms_ = 100; |
| 311 } | 311 } |
| 312 | 312 |
| 313 ~TestSafeBrowsingBlockingPage() override { | 313 ~TestSafeBrowsingBlockingPage() override { |
| 314 if (!wait_for_delete_) | 314 if (!wait_for_delete_) |
| 315 return; | 315 return; |
| 316 | 316 |
| 317 // Notify that we are gone | 317 // Notify that we are gone |
| 318 base::MessageLoopForUI::current()->Quit(); | 318 base::MessageLoopForUI::current()->QuitWhenIdle(); |
| 319 wait_for_delete_ = false; | 319 wait_for_delete_ = false; |
| 320 } | 320 } |
| 321 | 321 |
| 322 void WaitForDelete() { | 322 void WaitForDelete() { |
| 323 wait_for_delete_ = true; | 323 wait_for_delete_ = true; |
| 324 content::RunMessageLoop(); | 324 content::RunMessageLoop(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 // InterstitialPageDelegate methods: | 327 // InterstitialPageDelegate methods: |
| 328 void CommandReceived(const std::string& command) override { | 328 void CommandReceived(const std::string& command) override { |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, | 1013 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageIDNTest, |
| 1014 SafeBrowsingBlockingPageDecodesIDN) { | 1014 SafeBrowsingBlockingPageDecodesIDN) { |
| 1015 EXPECT_TRUE(VerifyIDNDecoded()); | 1015 EXPECT_TRUE(VerifyIDNDecoded()); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType, | 1018 INSTANTIATE_TEST_CASE_P(SafeBrowsingBlockingPageIDNTestWithThreatType, |
| 1019 SafeBrowsingBlockingPageIDNTest, | 1019 SafeBrowsingBlockingPageIDNTest, |
| 1020 testing::Values(SB_THREAT_TYPE_URL_MALWARE, | 1020 testing::Values(SB_THREAT_TYPE_URL_MALWARE, |
| 1021 SB_THREAT_TYPE_URL_PHISHING, | 1021 SB_THREAT_TYPE_URL_PHISHING, |
| 1022 SB_THREAT_TYPE_URL_UNWANTED)); | 1022 SB_THREAT_TYPE_URL_UNWANTED)); |
| OLD | NEW |