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

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

Issue 2849653003: Password manager should autofill a dynamic form added and processed before the page was loaded. (Closed)
Patch Set: Created 3 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 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 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 1300
1301 std::string show_form = 1301 std::string show_form =
1302 "document.getElementsByTagName('form')[0].style.display = 'block'"; 1302 "document.getElementsByTagName('form')[0].style.display = 'block'";
1303 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), show_form)); 1303 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), show_form));
1304 1304
1305 // Wait until the username is filled, to make sure autofill kicked in. 1305 // Wait until the username is filled, to make sure autofill kicked in.
1306 WaitForElementValue("username", "admin"); 1306 WaitForElementValue("username", "admin");
1307 CheckElementValue("password", "12345"); 1307 CheckElementValue("password", "12345");
1308 } 1308 }
1309 1309
1310 // https://crbug.com/713645
1311 // Navigate to a page that can't load some of the subresources. Create a hidden
1312 // form when the body is loaded. Make the form visible. Chrome should autofill
1313 // the form.
1314 // The fact that the form is hidden isn't super important but reproduces the
1315 // actual bug.
1316 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, SlowPageFill) {
1317 // At first let us save a credential to the password store.
1318 scoped_refptr<password_manager::TestPasswordStore> password_store =
1319 static_cast<password_manager::TestPasswordStore*>(
1320 PasswordStoreFactory::GetForProfile(
1321 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
1322 .get());
1323 autofill::PasswordForm signin_form;
1324 signin_form.signon_realm = embedded_test_server()->base_url().spec();
1325 signin_form.origin = embedded_test_server()->base_url();
1326 signin_form.action = embedded_test_server()->base_url();
1327 signin_form.username_value = base::ASCIIToUTF16("admin");
1328 signin_form.password_value = base::ASCIIToUTF16("12345");
1329 password_store->AddLogin(signin_form);
1330
1331 GURL url =
1332 embedded_test_server()->GetURL("/password/infinite_password_form.html");
1333 ui_test_utils::NavigateToURLWithDisposition(
1334 browser(), url, WindowOpenDisposition::CURRENT_TAB,
1335 ui_test_utils::BROWSER_TEST_NONE);
1336
1337 // Wait for autofill.
1338 BubbleObserver bubble_observer(WebContents());
1339 bubble_observer.WaitForManagementState();
1340
1341 // Show the form and make sure that the password was autofilled.
1342 std::string show_form =
1343 "document.getElementsByTagName('form')[0].style.display = 'block'";
1344 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), show_form));
1345
1346 CheckElementValue("username", "admin");
1347 CheckElementValue("password", "12345");
1348 }
1349
1310 // Test that if there was no previous page load then the PasswordManagerDriver 1350 // Test that if there was no previous page load then the PasswordManagerDriver
1311 // does not think that there were SSL errors on the current page. The test opens 1351 // does not think that there were SSL errors on the current page. The test opens
1312 // a new tab with a URL for which the embedded test server issues a basic auth 1352 // a new tab with a URL for which the embedded test server issues a basic auth
1313 // challenge. 1353 // challenge.
1314 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoLastLoadGoodLastLoad) { 1354 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoLastLoadGoodLastLoad) {
1315 // We must use a new test server here because embedded_test_server() is 1355 // We must use a new test server here because embedded_test_server() is
1316 // already started at this point and adding the request handler to it would 1356 // already started at this point and adding the request handler to it would
1317 // not be thread safe. 1357 // not be thread safe.
1318 net::EmbeddedTestServer http_test_server; 1358 net::EmbeddedTestServer http_test_server;
1319 1359
(...skipping 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after
3334 // Force a round-trip. 3374 // Force a round-trip.
3335 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(), 3375 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(),
3336 "var noop = 'noop';")); 3376 "var noop = 'noop';"));
3337 // Ensure the warning was not triggered. 3377 // Ensure the warning was not triggered.
3338 ASSERT_FALSE(observing_autofill_client->DidPopupAppear()); 3378 ASSERT_FALSE(observing_autofill_client->DidPopupAppear());
3339 // Ensure the histogram remains empty. 3379 // Ensure the histogram remains empty.
3340 histograms.ExpectTotalCount(kHistogram, 0); 3380 histograms.ExpectTotalCount(kHistogram, 0);
3341 } 3381 }
3342 3382
3343 } // namespace password_manager 3383 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698