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

Side by Side Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 2721663002: Move Credentials when migrating to HSTS page (Closed)
Patch Set: Code Deduplication Created 3 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 WaitForPasswordStore(); 1504 WaitForPasswordStore();
1505 1505
1506 // Let the user interact with the page, so that DOM gets modification events, 1506 // Let the user interact with the page, so that DOM gets modification events,
1507 // needed for autofilling fields. 1507 // needed for autofilling fields.
1508 content::SimulateMouseClickAt( 1508 content::SimulateMouseClickAt(
1509 WebContents(), 0, blink::WebMouseEvent::Button::Left, gfx::Point(1, 1)); 1509 WebContents(), 0, blink::WebMouseEvent::Button::Left, gfx::Point(1, 1));
1510 WaitForElementValue("username_field", "user"); 1510 WaitForElementValue("username_field", "user");
1511 CheckElementValue("password_field", "12345"); 1511 CheckElementValue("password_field", "12345");
1512 } 1512 }
1513 1513
1514 // Tests that obsolete HTTP credentials are moved when a site migrated to HTTPS
1515 // and has HSTS enabled.
1516 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
1517 ObsoleteHttpCredentialMovedOnMigrationToHstsSite) {
1518 // Add an http credential to the password store.
1519 GURL https_origin = https_test_server().base_url();
1520 ASSERT_TRUE(https_origin.SchemeIs(url::kHttpsScheme));
1521 GURL::Replacements rep;
1522 rep.SetSchemeStr(url::kHttpScheme);
1523 GURL http_origin = https_origin.ReplaceComponents(rep);
1524 autofill::PasswordForm http_form;
1525 http_form.signon_realm = http_origin.spec();
1526 http_form.origin = http_origin;
1527 // Assume that the previous action was already HTTPS one matching the current
1528 // page.
1529 http_form.action = https_origin;
1530 http_form.username_value = base::ASCIIToUTF16("user");
1531 http_form.password_value = base::ASCIIToUTF16("12345");
1532 scoped_refptr<password_manager::TestPasswordStore> password_store =
1533 static_cast<password_manager::TestPasswordStore*>(
1534 PasswordStoreFactory::GetForProfile(
1535 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
1536 .get());
1537 password_store->AddLogin(http_form);
1538
1539 // Treat the host of the HTTPS test server as HSTS.
1540 AddHSTSHost(https_test_server().host_port_pair().host());
1541
1542 // Navigate to HTTPS page and trigger the migration.
1543 NavigationObserver form_observer(WebContents());
1544 ui_test_utils::NavigateToURL(
1545 browser(), https_test_server().GetURL("/password/password_form.html"));
1546 form_observer.Wait();
1547 WaitForPasswordStore();
1548
1549 // Only HTTPS passwords should be present.
1550 EXPECT_TRUE(
1551 password_store->stored_passwords().at(http_origin.spec()).empty());
1552 EXPECT_FALSE(
1553 password_store->stored_passwords().at(https_origin.spec()).empty());
1554 }
1555
1514 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 1556 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
1515 PromptWhenPasswordFormWithoutUsernameFieldSubmitted) { 1557 PromptWhenPasswordFormWithoutUsernameFieldSubmitted) {
1516 scoped_refptr<password_manager::TestPasswordStore> password_store = 1558 scoped_refptr<password_manager::TestPasswordStore> password_store =
1517 static_cast<password_manager::TestPasswordStore*>( 1559 static_cast<password_manager::TestPasswordStore*>(
1518 PasswordStoreFactory::GetForProfile( 1560 PasswordStoreFactory::GetForProfile(
1519 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); 1561 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
1520 1562
1521 EXPECT_TRUE(password_store->IsEmpty()); 1563 EXPECT_TRUE(password_store->IsEmpty());
1522 1564
1523 NavigateToFile("/password/form_with_only_password_field.html"); 1565 NavigateToFile("/password/form_with_only_password_field.html");
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
3296 gfx::Point(left + 1, top + 1)); 3338 gfx::Point(left + 1, top + 1));
3297 // Force a round-trip. 3339 // Force a round-trip.
3298 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), "var noop = 'noop';")); 3340 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), "var noop = 'noop';"));
3299 // Ensure the warning was not triggered. 3341 // Ensure the warning was not triggered.
3300 ASSERT_FALSE(observing_autofill_client->DidPopupAppear()); 3342 ASSERT_FALSE(observing_autofill_client->DidPopupAppear());
3301 // Ensure the histogram remains empty. 3343 // Ensure the histogram remains empty.
3302 histograms.ExpectTotalCount(kHistogram, 0); 3344 histograms.ExpectTotalCount(kHistogram, 0);
3303 } 3345 }
3304 3346
3305 } // namespace password_manager 3347 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698