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

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: Rebase + removed DCHECK 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
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_different_http_page() {
277 NavigateAndCommit(GURL("http://example2.test"));
278 }
279
276 private: 280 private:
277 ChromeSecurityStateModelClient* client_; 281 ChromeSecurityStateModelClient* client_;
278 DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClientHistogramTest); 282 DISALLOW_COPY_AND_ASSIGN(ChromeSecurityStateModelClientHistogramTest);
279 }; 283 };
280 284
281 // Tests that UMA logs the omnibox warning when security level is 285 // Tests that UMA logs the omnibox warning when security level is
282 // HTTP_SHOW_WARNING. 286 // HTTP_SHOW_WARNING.
283 TEST_F(ChromeSecurityStateModelClientHistogramTest, 287 TEST_F(ChromeSecurityStateModelClientHistogramTest,
284 HTTPOmniboxWarningHistogram) { 288 HTTPOmniboxWarningHistogram) {
285 // Show Warning Chip. 289 // Show Warning Chip.
286 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 290 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
287 security_state::switches::kMarkHttpAs, 291 security_state::switches::kMarkHttpAs,
288 security_state::switches::kMarkHttpWithPasswordsOrCcWithChip); 292 security_state::switches::kMarkHttpWithPasswordsOrCcWithChip);
289 293
290 base::HistogramTester histograms; 294 base::HistogramTester histograms;
291 signal_password(); 295 signal_password();
292 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1); 296 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1);
293 297
294 // Fire again and ensure no sample is recorded. 298 // Fire again and ensure no sample is recorded.
295 signal_password(); 299 signal_password();
296 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1); 300 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1);
297 301
298 // Navigate to a new page and ensure a sample is recorded. 302 // Navigate to a new page and ensure a sample is recorded.
299 navigate_to_http(); 303 navigate_to_different_http_page();
300 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1); 304 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 1);
301 signal_password(); 305 signal_password();
302 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 2); 306 histograms.ExpectUniqueSample(kHTTPBadHistogram, true, 2);
303 } 307 }
304 308
305 // Tests that UMA logs the console warning when security level is NONE. 309 // Tests that UMA logs the console warning when security level is NONE.
306 TEST_F(ChromeSecurityStateModelClientHistogramTest, 310 TEST_F(ChromeSecurityStateModelClientHistogramTest,
307 HTTPConsoleWarningHistogram) { 311 HTTPConsoleWarningHistogram) {
308 // Show Neutral for HTTP 312 // Show Neutral for HTTP
309 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 313 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
310 security_state::switches::kMarkHttpAs, 314 security_state::switches::kMarkHttpAs,
311 security_state::switches::kMarkHttpAsNeutral); 315 security_state::switches::kMarkHttpAsNeutral);
312 316
313 base::HistogramTester histograms; 317 base::HistogramTester histograms;
314 signal_password(); 318 signal_password();
315 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1); 319 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1);
316 320
317 // Fire again and ensure no sample is recorded. 321 // Fire again and ensure no sample is recorded.
318 signal_password(); 322 signal_password();
319 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1); 323 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1);
320 324
321 // Navigate to a new page and ensure a sample is recorded. 325 // Navigate to a new page and ensure a sample is recorded.
322 navigate_to_http(); 326 navigate_to_different_http_page();
323 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1); 327 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 1);
324 signal_password(); 328 signal_password();
325 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 2); 329 histograms.ExpectUniqueSample(kHTTPBadHistogram, false, 2);
326 } 330 }
327 331
328 } // namespace 332 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698