| 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 | 5 // This test creates a fake safebrowsing service, where we can inject |
| 6 // malware and phishing urls. It then uses a real browser to go to | 6 // malware and phishing urls. It then uses a real browser to go to |
| 7 // these urls, and sends "goback" or "proceed" commands and verifies | 7 // these urls, and sends "goback" or "proceed" commands and verifies |
| 8 // they work. | 8 // they work. |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 561 |
| 562 bool Click(const std::string& node_id) { | 562 bool Click(const std::string& node_id) { |
| 563 content::RenderViewHost* rvh = GetRenderViewHost(); | 563 content::RenderViewHost* rvh = GetRenderViewHost(); |
| 564 if (!rvh) | 564 if (!rvh) |
| 565 return false; | 565 return false; |
| 566 // We don't use ExecuteScriptAndGetValue for this one, since clicking | 566 // We don't use ExecuteScriptAndGetValue for this one, since clicking |
| 567 // the button/link may navigate away before the injected javascript can | 567 // the button/link may navigate away before the injected javascript can |
| 568 // reply, hanging the test. | 568 // reply, hanging the test. |
| 569 rvh->ExecuteJavascriptInWebFrame( | 569 rvh->ExecuteJavascriptInWebFrame( |
| 570 base::string16(), | 570 base::string16(), |
| 571 ASCIIToUTF16("document.getElementById('" + node_id + "').click();\n")); | 571 base::ASCIIToUTF16( |
| 572 "document.getElementById('" + node_id + "').click();\n")); |
| 572 return true; | 573 return true; |
| 573 } | 574 } |
| 574 | 575 |
| 575 bool ClickAndWaitForDetach(const std::string& node_id) { | 576 bool ClickAndWaitForDetach(const std::string& node_id) { |
| 576 // We wait for interstitial_detached rather than nav_entry_committed, as | 577 // We wait for interstitial_detached rather than nav_entry_committed, as |
| 577 // going back from a main-frame malware interstitial page will not cause a | 578 // going back from a main-frame malware interstitial page will not cause a |
| 578 // nav entry committed event. | 579 // nav entry committed event. |
| 579 scoped_refptr<content::MessageLoopRunner> loop_runner( | 580 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 580 new content::MessageLoopRunner); | 581 new content::MessageLoopRunner); |
| 581 InterstitialObserver observer( | 582 InterstitialObserver observer( |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); | 876 SetupWarningAndNavigate(SB_THREAT_TYPE_URL_PHISHING); |
| 876 | 877 |
| 877 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); | 878 EXPECT_TRUE(ClickAndWaitForDetach("learn-more-link")); |
| 878 AssertNoInterstitial(false); // Assert the interstitial is gone | 879 AssertNoInterstitial(false); // Assert the interstitial is gone |
| 879 | 880 |
| 880 // We are in the help page. | 881 // We are in the help page. |
| 881 EXPECT_EQ( | 882 EXPECT_EQ( |
| 882 "/goodtoknow/online-safety/phishing/", | 883 "/goodtoknow/online-safety/phishing/", |
| 883 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); | 884 browser()->tab_strip_model()->GetActiveWebContents()->GetURL().path()); |
| 884 } | 885 } |
| OLD | NEW |