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

Side by Side Diff: chrome/browser/ssl/chrome_security_state_model_client_unittest.cc

Issue 2475693002: Do not reset NavigationHandle when navigating same-page (Closed)
Patch Set: Addressed comments Created 4 years, 1 month 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
« no previous file with comments | « no previous file | content/browser/frame_host/interstitial_page_navigator_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/browser/ssl/chrome_security_state_model_client.h" 5 #include "chrome/browser/ssl/chrome_security_state_model_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
10 #include "components/security_state/security_state_model.h" 10 #include "components/security_state/security_state_model.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 protected: 266 protected:
267 ChromeSecurityStateModelClient* client() { return client_; } 267 ChromeSecurityStateModelClient* client() { return client_; }
268 268
269 void signal_password() { 269 void signal_password() {
270 web_contents()->OnPasswordInputShownOnHttp(); 270 web_contents()->OnPasswordInputShownOnHttp();
271 client_->VisibleSecurityStateChanged(); 271 client_->VisibleSecurityStateChanged();
272 } 272 }
273 273
274 void navigate_to_http() { NavigateAndCommit(GURL("http://example.test")); } 274 void navigate_to_http() { NavigateAndCommit(GURL("http://example.test")); }
275 275
276 void navigate_to_http_2() { NavigateAndCommit(GURL("http://example2.test")); }
estark 2016/11/04 14:53:59 nit: could you rename this to navigate_to_differen
clamy 2016/11/04 15:47:25 Done.
277
276 private: 278 private:
277 ChromeSecurityStateModelClient* client_; 279 ChromeSecurityStateModelClient* client_;
278 DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClientHistogramTest); 280 DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClientHistogramTest);
279 }; 281 };
280 282
281 // Tests that UMA logs the omnibox warning when security level is 283 // Tests that UMA logs the omnibox warning when security level is
282 // HTTP_SHOW_WARNING. 284 // HTTP_SHOW_WARNING.
283 TEST_F(ChromeSecurityStateModelClientHistogramTest, 285 TEST_F(ChromeSecurityStateModelClientHistogramTest,
284 HTTPOmniboxWarningHistogram) { 286 HTTPOmniboxWarningHistogram) {
285 // Show Warning Chip. 287 // Show Warning Chip.
286 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 288 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
287 security_state::switches::kMarkHttpAs, 289 security_state::switches::kMarkHttpAs,
288 security_state::switches::kMarkHttpWithPasswordsOrCcWithChip); 290 security_state::switches::kMarkHttpWithPasswordsOrCcWithChip);
289 291
290 base::HistogramTester histograms; 292 base::HistogramTester histograms;
291 signal_password(); 293 signal_password();
292 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1); 294 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1);
293 295
294 // Fire again and ensure no sample is recorded. 296 // Fire again and ensure no sample is recorded.
295 signal_password(); 297 signal_password();
296 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1); 298 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1);
297 299
298 // Navigate to a new page and ensure a sample is recorded. 300 // Navigate to a new page and ensure a sample is recorded.
299 navigate_to_http(); 301 navigate_to_http_2();
300 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1); 302 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1);
301 signal_password(); 303 signal_password();
302 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 2); 304 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 2);
303 } 305 }
304 306
305 // Tests that UMA logs the console warning when security level is NONE. 307 // Tests that UMA logs the console warning when security level is NONE.
306 TEST_F(ChromeSecurityStateModelClientHistogramTest, 308 TEST_F(ChromeSecurityStateModelClientHistogramTest,
307 HTTPConsoleWarningHistogram) { 309 HTTPConsoleWarningHistogram) {
308 // Show Neutral for HTTP 310 // Show Neutral for HTTP
309 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 311 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
310 security_state::switches::kMarkHttpAs, 312 security_state::switches::kMarkHttpAs,
311 security_state::switches::kMarkHttpAsNeutral); 313 security_state::switches::kMarkHttpAsNeutral);
312 314
313 base::HistogramTester histograms; 315 base::HistogramTester histograms;
314 signal_password(); 316 signal_password();
315 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1); 317 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1);
316 318
317 // Fire again and ensure no sample is recorded. 319 // Fire again and ensure no sample is recorded.
318 signal_password(); 320 signal_password();
319 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1); 321 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1);
320 322
321 // Navigate to a new page and ensure a sample is recorded. 323 // Navigate to a new page and ensure a sample is recorded.
322 navigate_to_http(); 324 navigate_to_http_2();
323 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1); 325 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1);
324 signal_password(); 326 signal_password();
325 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 2); 327 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 2);
326 } 328 }
327 329
328 } // namespace 330 } // namespace
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/interstitial_page_navigator_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698