Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc

Issue 1976573002: Only use pending navigation params for browser-initiated navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: backward comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" 5 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/common/safe_browsing/csd.pb.h" 10 #include "chrome/common/safe_browsing/csd.pb.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 OnStartPhishingDetection(url); 180 OnStartPhishingDetection(url);
181 page_text = ASCIIToUTF16("dummy"); 181 page_text = ASCIIToUTF16("dummy");
182 EXPECT_CALL(*classifier_, CancelPendingClassification()); 182 EXPECT_CALL(*classifier_, CancelPendingClassification());
183 PageCaptured(&page_text, false, url); 183 PageCaptured(&page_text, false, url);
184 Mock::VerifyAndClearExpectations(classifier_); 184 Mock::VerifyAndClearExpectations(classifier_);
185 185
186 // Navigating within page works similarly to a subframe navigation, but 186 // Navigating within page works similarly to a subframe navigation, but
187 // see the TODO in PhishingClassifierDelegate::DidCommitProvisionalLoad. 187 // see the TODO in PhishingClassifierDelegate::DidCommitProvisionalLoad.
188 EXPECT_CALL(*classifier_, CancelPendingClassification()); 188 EXPECT_CALL(*classifier_, CancelPendingClassification());
189 DidNavigateWithinPage(GetMainFrame(), true); 189 DidNavigateWithinPage(GetMainFrame(), true, false);
190 Mock::VerifyAndClearExpectations(classifier_); 190 Mock::VerifyAndClearExpectations(classifier_);
191 191
192 OnStartPhishingDetection(url); 192 OnStartPhishingDetection(url);
193 page_text = ASCIIToUTF16("dummy"); 193 page_text = ASCIIToUTF16("dummy");
194 EXPECT_CALL(*classifier_, CancelPendingClassification()); 194 EXPECT_CALL(*classifier_, CancelPendingClassification());
195 PageCaptured(&page_text, false, url); 195 PageCaptured(&page_text, false, url);
196 Mock::VerifyAndClearExpectations(classifier_); 196 Mock::VerifyAndClearExpectations(classifier_);
197 197
198 // Now load a new toplevel page, which should trigger another classification. 198 // Now load a new toplevel page, which should trigger another classification.
199 EXPECT_CALL(*classifier_, CancelPendingClassification()); 199 EXPECT_CALL(*classifier_, CancelPendingClassification());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 Mock::VerifyAndClearExpectations(classifier_); 244 Mock::VerifyAndClearExpectations(classifier_);
245 245
246 page_text = ASCIIToUTF16("dummy"); 246 page_text = ASCIIToUTF16("dummy");
247 OnStartPhishingDetection(url); 247 OnStartPhishingDetection(url);
248 EXPECT_CALL(*classifier_, CancelPendingClassification()); 248 EXPECT_CALL(*classifier_, CancelPendingClassification());
249 PageCaptured(&page_text, false, url); 249 PageCaptured(&page_text, false, url);
250 Mock::VerifyAndClearExpectations(classifier_); 250 Mock::VerifyAndClearExpectations(classifier_);
251 251
252 EXPECT_CALL(*classifier_, CancelPendingClassification()); 252 EXPECT_CALL(*classifier_, CancelPendingClassification());
253 // In-page navigation. 253 // In-page navigation.
254 DidNavigateWithinPage(GetMainFrame(), true); 254 DidNavigateWithinPage(GetMainFrame(), true, false);
Charlie Reis 2016/05/12 20:51:47 Just curious, was there a reason this needed to be
Avi (use Gerrit) 2016/05/12 23:41:17 I kinda picked it arbitrarily.
255 Mock::VerifyAndClearExpectations(classifier_); 255 Mock::VerifyAndClearExpectations(classifier_);
256 256
257 OnStartPhishingDetection(url); 257 OnStartPhishingDetection(url);
258 page_text = ASCIIToUTF16("dummy"); 258 page_text = ASCIIToUTF16("dummy");
259 EXPECT_CALL(*classifier_, CancelPendingClassification()); 259 EXPECT_CALL(*classifier_, CancelPendingClassification());
260 PageCaptured(&page_text, false, url); 260 PageCaptured(&page_text, false, url);
261 Mock::VerifyAndClearExpectations(classifier_); 261 Mock::VerifyAndClearExpectations(classifier_);
262 262
263 // The delegate will cancel pending classification on destruction. 263 // The delegate will cancel pending classification on destruction.
264 EXPECT_CALL(*classifier_, CancelPendingClassification()); 264 EXPECT_CALL(*classifier_, CancelPendingClassification());
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 verdict.set_url(url.spec()); 496 verdict.set_url(url.spec());
497 verdict.set_client_score(0.8f); 497 verdict.set_client_score(0.8f);
498 verdict.set_is_phishing(false); // Send IPC even if site is not phishing. 498 verdict.set_is_phishing(false); // Send IPC even if site is not phishing.
499 RunAndVerifyClassificationDone(verdict); 499 RunAndVerifyClassificationDone(verdict);
500 500
501 // The delegate will cancel pending classification on destruction. 501 // The delegate will cancel pending classification on destruction.
502 EXPECT_CALL(*classifier_, CancelPendingClassification()); 502 EXPECT_CALL(*classifier_, CancelPendingClassification());
503 } 503 }
504 504
505 } // namespace safe_browsing 505 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698