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