| 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 // Note: this test uses RenderViewFakeResourcesTest in order to set up a | 5 // Note: this test uses RenderViewFakeResourcesTest in order to set up a |
| 6 // real RenderThread to hold the phishing Scorer object. | 6 // real RenderThread to hold the phishing Scorer object. |
| 7 | 7 |
| 8 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" | 8 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 page_text = ASCIIToUTF16("dummy"); | 135 page_text = ASCIIToUTF16("dummy"); |
| 136 EXPECT_CALL(*classifier, CancelPendingClassification()); | 136 EXPECT_CALL(*classifier, CancelPendingClassification()); |
| 137 delegate->PageCaptured(&page_text, false); | 137 delegate->PageCaptured(&page_text, false); |
| 138 Mock::VerifyAndClearExpectations(classifier); | 138 Mock::VerifyAndClearExpectations(classifier); |
| 139 | 139 |
| 140 // Navigating in a subframe will not change the toplevel URL. However, this | 140 // Navigating in a subframe will not change the toplevel URL. However, this |
| 141 // should cancel pending classification since the page content is changing. | 141 // should cancel pending classification since the page content is changing. |
| 142 // Currently, we do not start a new classification after subframe loads. | 142 // Currently, we do not start a new classification after subframe loads. |
| 143 EXPECT_CALL(*classifier, CancelPendingClassification()); | 143 EXPECT_CALL(*classifier, CancelPendingClassification()); |
| 144 GetMainFrame()->firstChild()->loadRequest( | 144 GetMainFrame()->firstChild()->loadRequest( |
| 145 WebKit::WebURLRequest(GURL("http://sub2.com/"))); | 145 blink::WebURLRequest(GURL("http://sub2.com/"))); |
| 146 message_loop_.Run(); | 146 message_loop_.Run(); |
| 147 Mock::VerifyAndClearExpectations(classifier); | 147 Mock::VerifyAndClearExpectations(classifier); |
| 148 OnStartPhishingDetection(delegate, GURL("http://host.com/")); | 148 OnStartPhishingDetection(delegate, GURL("http://host.com/")); |
| 149 page_text = ASCIIToUTF16("dummy"); | 149 page_text = ASCIIToUTF16("dummy"); |
| 150 EXPECT_CALL(*classifier, CancelPendingClassification()); | 150 EXPECT_CALL(*classifier, CancelPendingClassification()); |
| 151 delegate->PageCaptured(&page_text, false); | 151 delegate->PageCaptured(&page_text, false); |
| 152 Mock::VerifyAndClearExpectations(classifier); | 152 Mock::VerifyAndClearExpectations(classifier); |
| 153 | 153 |
| 154 // Scrolling to an anchor works similarly to a subframe navigation, but | 154 // Scrolling to an anchor works similarly to a subframe navigation, but |
| 155 // see the TODO in PhishingClassifierDelegate::DidCommitProvisionalLoad. | 155 // see the TODO in PhishingClassifierDelegate::DidCommitProvisionalLoad. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 173 EXPECT_CALL(*classifier, CancelPendingClassification()); | 173 EXPECT_CALL(*classifier, CancelPendingClassification()); |
| 174 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)); | 174 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)); |
| 175 delegate->PageCaptured(&page_text, false); | 175 delegate->PageCaptured(&page_text, false); |
| 176 Mock::VerifyAndClearExpectations(classifier); | 176 Mock::VerifyAndClearExpectations(classifier); |
| 177 } | 177 } |
| 178 | 178 |
| 179 // No classification should happen on back/forward navigation. | 179 // No classification should happen on back/forward navigation. |
| 180 // Note: in practice, the browser will not send a StartPhishingDetection IPC | 180 // Note: in practice, the browser will not send a StartPhishingDetection IPC |
| 181 // in this case. However, we want to make sure that the delegate behaves | 181 // in this case. However, we want to make sure that the delegate behaves |
| 182 // correctly regardless. | 182 // correctly regardless. |
| 183 WebKit::WebHistoryItem forward_item = GetMainFrame()->currentHistoryItem(); | 183 blink::WebHistoryItem forward_item = GetMainFrame()->currentHistoryItem(); |
| 184 EXPECT_CALL(*classifier, CancelPendingClassification()); | 184 EXPECT_CALL(*classifier, CancelPendingClassification()); |
| 185 GoBack(); | 185 GoBack(); |
| 186 Mock::VerifyAndClearExpectations(classifier); | 186 Mock::VerifyAndClearExpectations(classifier); |
| 187 page_text = ASCIIToUTF16("dummy"); | 187 page_text = ASCIIToUTF16("dummy"); |
| 188 OnStartPhishingDetection(delegate, GURL("http://host.com/#foo")); | 188 OnStartPhishingDetection(delegate, GURL("http://host.com/#foo")); |
| 189 EXPECT_CALL(*classifier, CancelPendingClassification()); | 189 EXPECT_CALL(*classifier, CancelPendingClassification()); |
| 190 delegate->PageCaptured(&page_text, false); | 190 delegate->PageCaptured(&page_text, false); |
| 191 Mock::VerifyAndClearExpectations(classifier); | 191 Mock::VerifyAndClearExpectations(classifier); |
| 192 | 192 |
| 193 EXPECT_CALL(*classifier, CancelPendingClassification()); | 193 EXPECT_CALL(*classifier, CancelPendingClassification()); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 verdict.set_is_phishing(false); // Send IPC even if site is not phishing. | 464 verdict.set_is_phishing(false); // Send IPC even if site is not phishing. |
| 465 RunClassificationDone(delegate, verdict); | 465 RunClassificationDone(delegate, verdict); |
| 466 ASSERT_TRUE(verdict_.get()); | 466 ASSERT_TRUE(verdict_.get()); |
| 467 EXPECT_EQ(verdict.SerializeAsString(), verdict_->SerializeAsString()); | 467 EXPECT_EQ(verdict.SerializeAsString(), verdict_->SerializeAsString()); |
| 468 | 468 |
| 469 // The delegate will cancel pending classification on destruction. | 469 // The delegate will cancel pending classification on destruction. |
| 470 EXPECT_CALL(*classifier, CancelPendingClassification()); | 470 EXPECT_CALL(*classifier, CancelPendingClassification()); |
| 471 } | 471 } |
| 472 | 472 |
| 473 } // namespace safe_browsing | 473 } // namespace safe_browsing |
| OLD | NEW |