Index: chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc |
diff --git a/chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc b/chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc |
index 49c8ee7ec0437931a667f1c45b0df917bf7ba5e2..1938c4861091cad1d5229a959af5f27ba2bb4404 100644 |
--- a/chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc |
+++ b/chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc |
@@ -132,14 +132,6 @@ class InterceptingMessageFilter : public content::BrowserMessageFilter { |
} // namespace |
class PhishingClassifierDelegateTest : public InProcessBrowserTest { |
- public: |
- void CancelCalled() { |
- if (runner_.get()) { |
- content::BrowserThread::PostTask( |
- content::BrowserThread::UI, FROM_HERE, runner_->QuitClosure()); |
- } |
- } |
- |
protected: |
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
command_line->AppendSwitch(switches::kSingleProcess); |
@@ -262,7 +254,6 @@ class PhishingClassifierDelegateTest : public InProcessBrowserTest { |
scoped_ptr<ClientPhishingRequest> verdict_; |
StrictMock<MockPhishingClassifier>* classifier_; // Owned by |delegate_|. |
PhishingClassifierDelegate* delegate_; // Owned by the RenderView. |
- scoped_refptr<content::MessageLoopRunner> runner_; |
}; |
IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
@@ -271,7 +262,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
ASSERT_TRUE(classifier_->is_ready()); |
// Test an initial load. We expect classification to happen normally. |
- EXPECT_CALL(*classifier_, CancelPendingClassification()).Times(2); |
std::string port = base::IntToString(embedded_test_server_->port()); |
std::string html = "<html><body><iframe src=\"http://sub1.com:"; |
html += port; |
@@ -288,11 +278,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
Mock::VerifyAndClearExpectations(classifier_); |
} |
- // Reloading the same page should not trigger a reclassification. |
- // However, it will cancel any pending classification since the |
- // content is being replaced. |
mattm
2014/07/10 03:21:01
It would be good to update and keep more of these
Avi (use Gerrit)
2014/07/10 15:14:07
Done.
|
- EXPECT_CALL(*classifier_, CancelPendingClassification()).Times(2); |
- |
content::TestNavigationObserver observer(GetWebContents()); |
chrome::Reload(browser(), CURRENT_TAB); |
observer.Wait(); |
@@ -304,20 +289,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
PageCaptured(&page_text, false); |
Mock::VerifyAndClearExpectations(classifier_); |
- // Navigating in a subframe will not change the toplevel URL. However, this |
- // should cancel pending classification since the page content is changing. |
- // Currently, we do not start a new classification after subframe loads. |
- EXPECT_CALL(*classifier_, CancelPendingClassification()) |
- .WillOnce(Invoke(this, &PhishingClassifierDelegateTest::CancelCalled)); |
- |
- runner_ = new content::MessageLoopRunner; |
- NavigateMainFrame(GURL(std::string("http://sub2.com:") + port + "/")); |
- |
- runner_->Run(); |
- runner_ = NULL; |
- |
- Mock::VerifyAndClearExpectations(classifier_); |
- |
OnStartPhishingDetection(url); |
page_text = ASCIIToUTF16("dummy"); |
EXPECT_CALL(*classifier_, CancelPendingClassification()); |
@@ -326,7 +297,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
// Scrolling to an anchor works similarly to a subframe navigation, but |
// see the TODO in PhishingClassifierDelegate::DidCommitProvisionalLoad. |
mattm
2014/07/10 03:21:01
that TODO no longer exists
Avi (use Gerrit)
2014/07/10 15:14:07
Done.
Avi (use Gerrit)
2014/07/10 15:14:08
Done.
|
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
GURL foo_url = GURL(url.spec() + "#foo"); |
ui_test_utils::NavigateToURL(browser(), foo_url); |
Mock::VerifyAndClearExpectations(classifier_); |
@@ -336,31 +306,16 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
PageCaptured(&page_text, false); |
Mock::VerifyAndClearExpectations(classifier_); |
- // Now load a new toplevel page, which should trigger another classification. |
- EXPECT_CALL(*classifier_, CancelPendingClassification()) |
- .WillOnce(Invoke(this, &PhishingClassifierDelegateTest::CancelCalled)); |
- |
- runner_ = new content::MessageLoopRunner; |
- url = LoadHtml("host2.com", "dummy2"); |
- runner_->Run(); |
- runner_ = NULL; |
- |
Mock::VerifyAndClearExpectations(classifier_); |
page_text = ASCIIToUTF16("dummy2"); |
OnStartPhishingDetection(url); |
{ |
InSequence s; |
EXPECT_CALL(*classifier_, CancelPendingClassification()); |
- EXPECT_CALL(*classifier_, BeginClassification(Pointee(page_text), _)); |
PageCaptured(&page_text, false); |
Mock::VerifyAndClearExpectations(classifier_); |
} |
- // No classification should happen on back/forward navigation. |
- // Note: in practice, the browser will not send a StartPhishingDetection IPC |
- // in this case. However, we want to make sure that the delegate behaves |
- // correctly regardless. |
- EXPECT_CALL(*classifier_, CancelPendingClassification()).Times(2); |
GoBack(); |
Mock::VerifyAndClearExpectations(classifier_); |
@@ -370,7 +325,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
PageCaptured(&page_text, false); |
Mock::VerifyAndClearExpectations(classifier_); |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
GoForward(); |
Mock::VerifyAndClearExpectations(classifier_); |
@@ -382,7 +336,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
// Now go back again and scroll to a different anchor. |
// No classification should happen. |
- EXPECT_CALL(*classifier_, CancelPendingClassification()).Times(2); |
GoBack(); |
Mock::VerifyAndClearExpectations(classifier_); |
page_text = ASCIIToUTF16("dummy"); |
@@ -392,7 +345,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, Navigation) { |
PageCaptured(&page_text, false); |
Mock::VerifyAndClearExpectations(classifier_); |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
GURL foo2_url = GURL(foo_url.spec() + "2"); |
ui_test_utils::NavigateToURL(browser(), foo2_url); |
Mock::VerifyAndClearExpectations(classifier_); |
@@ -475,7 +427,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, |
delegate_->SetPhishingScorer(&scorer); |
ASSERT_TRUE(classifier_->is_ready()); |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
GURL url = LoadHtml("host.com", "<html><body>phish</body></html>"); |
Mock::VerifyAndClearExpectations(classifier_); |
base::string16 page_text = ASCIIToUTF16("phish"); |
@@ -491,15 +442,12 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, |
// Now try again, but this time we will navigate the page away before |
// the IPC is sent. |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
LoadHtml("host2.com", "<html><body>phish</body></html>"); |
Mock::VerifyAndClearExpectations(classifier_); |
page_text = ASCIIToUTF16("phish"); |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
PageCaptured(&page_text, false); |
Mock::VerifyAndClearExpectations(classifier_); |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
LoadHtml("host3.com", "<html><body>phish</body></html>"); |
Mock::VerifyAndClearExpectations(classifier_); |
OnStartPhishingDetection(url); |
@@ -508,14 +456,12 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, |
// StartPhishingDetection IPC for. We use location.replace() to load a |
// new page while reusing the original session history entry, and check that |
// classification begins correctly for the landing page. |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
LoadHtml("host4.com", "<html><body>abc</body></html>"); |
Mock::VerifyAndClearExpectations(classifier_); |
page_text = ASCIIToUTF16("abc"); |
EXPECT_CALL(*classifier_, CancelPendingClassification()); |
PageCaptured(&page_text, false); |
Mock::VerifyAndClearExpectations(classifier_); |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
ui_test_utils::NavigateToURL( |
browser(), GURL("javascript:location.replace(\'redir\');")); |
@@ -546,7 +492,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, |
delegate_->SetPhishingScorer(&scorer); |
ASSERT_TRUE(classifier_->is_ready()); |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
GURL url = LoadHtml("host.com", "<html><body>phish</body></html>"); |
Mock::VerifyAndClearExpectations(classifier_); |
OnStartPhishingDetection(url); |
@@ -580,7 +525,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, |
delegate_->SetPhishingScorer(&scorer); |
ASSERT_TRUE(classifier_->is_ready()); |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
GURL url = LoadHtml("host.com", "<html><body>phish</body></html>"); |
Mock::VerifyAndClearExpectations(classifier_); |
OnStartPhishingDetection(url); |
@@ -594,7 +538,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, |
} |
page_text = ASCIIToUTF16("phish"); |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
PageCaptured(&page_text, false); |
Mock::VerifyAndClearExpectations(classifier_); |
@@ -610,7 +553,6 @@ IN_PROC_BROWSER_TEST_F(PhishingClassifierDelegateTest, PhishingDetectionDone) { |
ASSERT_TRUE(classifier_->is_ready()); |
// Start by loading a page to populate the delegate's state. |
- EXPECT_CALL(*classifier_, CancelPendingClassification()); |
GURL url = LoadHtml("host.com", "<html><body>phish</body></html>"); |
Mock::VerifyAndClearExpectations(classifier_); |
base::string16 page_text = ASCIIToUTF16("phish"); |