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

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

Issue 2835933003: Notify PasswordAutofillAgent about dynamic forms after the document was parsed. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/test/data/password/between_parsing_and_rendering.html » ('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 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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 } 1253 }
1254 1254
1255 // Test that if a form gets dynamically added between the form parsing and 1255 // Test that if a form gets dynamically added between the form parsing and
1256 // rendering, and while the main frame still loads, it still is registered, and 1256 // rendering, and while the main frame still loads, it still is registered, and
1257 // thus saving passwords from it works. 1257 // thus saving passwords from it works.
1258 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 1258 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
1259 FormsAddedBetweenParsingAndRendering) { 1259 FormsAddedBetweenParsingAndRendering) {
1260 NavigateToFile("/password/between_parsing_and_rendering.html"); 1260 NavigateToFile("/password/between_parsing_and_rendering.html");
1261 1261
1262 NavigationObserver observer(WebContents()); 1262 NavigationObserver observer(WebContents());
1263 std::unique_ptr<BubbleObserver> prompt_observer(
1264 new BubbleObserver(WebContents()));
1265 std::string submit = 1263 std::string submit =
1266 "document.getElementById('username').value = 'temp';" 1264 "document.getElementById('username').value = 'temp';"
1267 "document.getElementById('password').value = 'random';" 1265 "document.getElementById('password').value = 'random';"
1268 "document.getElementById('submit-button').click();"; 1266 "document.getElementById('submit-button').click();";
1269 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); 1267 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
1270 observer.Wait(); 1268 observer.Wait();
1271 1269
1272 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); 1270 EXPECT_TRUE(BubbleObserver(WebContents()).IsShowingSavePrompt());
1271 }
1272
1273 // Test that if a hidden form gets dynamically added between the form parsing
1274 // and rendering, it still is registered, and autofilling works.
1275 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
1276 HiddenFormAddedBetweenParsingAndRendering) {
1277 // At first let us save a credential to the password store.
1278 scoped_refptr<password_manager::TestPasswordStore> password_store =
1279 static_cast<password_manager::TestPasswordStore*>(
1280 PasswordStoreFactory::GetForProfile(
1281 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
1282 .get());
1283 autofill::PasswordForm signin_form;
1284 signin_form.signon_realm = embedded_test_server()->base_url().spec();
1285 signin_form.origin = embedded_test_server()->base_url();
1286 signin_form.action = embedded_test_server()->base_url();
1287 signin_form.username_value = base::ASCIIToUTF16("admin");
1288 signin_form.password_value = base::ASCIIToUTF16("12345");
1289 password_store->AddLogin(signin_form);
1290
1291 NavigateToFile("/password/between_parsing_and_rendering.html?hidden");
1292
1293 std::string show_form =
1294 "document.getElementsByTagName('form')[0].style.display = 'block'";
1295 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), show_form));
1296
1297 // Wait until the username is filled, to make sure autofill kicked in.
1298 WaitForElementValue("username", "admin");
1299 CheckElementValue("password", "12345");
1273 } 1300 }
1274 1301
1275 // Test that if there was no previous page load then the PasswordManagerDriver 1302 // Test that if there was no previous page load then the PasswordManagerDriver
1276 // does not think that there were SSL errors on the current page. The test opens 1303 // does not think that there were SSL errors on the current page. The test opens
1277 // a new tab with a URL for which the embedded test server issues a basic auth 1304 // a new tab with a URL for which the embedded test server issues a basic auth
1278 // challenge. 1305 // challenge.
1279 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoLastLoadGoodLastLoad) { 1306 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoLastLoadGoodLastLoad) {
1280 // We must use a new test server here because embedded_test_server() is 1307 // We must use a new test server here because embedded_test_server() is
1281 // already started at this point and adding the request handler to it would 1308 // already started at this point and adding the request handler to it would
1282 // not be thread safe. 1309 // not be thread safe.
(...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after
3308 // Force a round-trip. 3335 // Force a round-trip.
3309 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(), 3336 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(),
3310 "var noop = 'noop';")); 3337 "var noop = 'noop';"));
3311 // Ensure the warning was not triggered. 3338 // Ensure the warning was not triggered.
3312 ASSERT_FALSE(observing_autofill_client->DidPopupAppear()); 3339 ASSERT_FALSE(observing_autofill_client->DidPopupAppear());
3313 // Ensure the histogram remains empty. 3340 // Ensure the histogram remains empty.
3314 histograms.ExpectTotalCount(kHistogram, 0); 3341 histograms.ExpectTotalCount(kHistogram, 0);
3315 } 3342 }
3316 3343
3317 } // namespace password_manager 3344 } // namespace password_manager
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/password/between_parsing_and_rendering.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698