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 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram_samples.h" | 8 #include "base/metrics/histogram_samples.h" |
9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 "document.getElementById('password_field').value = 'password';" | 335 "document.getElementById('password_field').value = 'password';" |
336 "document.getElementById('input_submit_button').click()"; | 336 "document.getElementById('input_submit_button').click()"; |
337 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 337 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
338 | 338 |
339 first_observer.Wait(); | 339 first_observer.Wait(); |
340 ASSERT_TRUE(first_observer.infobar_shown()); | 340 ASSERT_TRUE(first_observer.infobar_shown()); |
341 | 341 |
342 // Now navigate to a login form that has similar HTML markup. | 342 // Now navigate to a login form that has similar HTML markup. |
343 NavigateToFile("/password/password_form.html"); | 343 NavigateToFile("/password/password_form.html"); |
344 | 344 |
| 345 // Simulate a user click to force an autofill of the form's DOM value, not |
| 346 // just the suggested value. |
| 347 std::string click = "document.getElementById('testform_no_name').click()"; |
| 348 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), click)); |
| 349 |
345 // The form should be filled with the previously submitted username. | 350 // The form should be filled with the previously submitted username. |
346 std::string get_username = | 351 std::string get_username = |
347 "window.domAutomationController.send(" | 352 "window.domAutomationController.send(" |
348 "document.getElementById('username_field').value);"; | 353 "document.getElementById('username_field').value);"; |
349 std::string actual_username; | 354 std::string actual_username; |
350 ASSERT_TRUE(content::ExecuteScriptAndExtractString(RenderViewHost(), | 355 ASSERT_TRUE(content::ExecuteScriptAndExtractString(RenderViewHost(), |
351 get_username, | 356 get_username, |
352 &actual_username)); | 357 &actual_username)); |
353 ASSERT_EQ("my_username", actual_username); | 358 ASSERT_EQ("my_username", actual_username); |
354 | 359 |
355 // Submit the form and verify that there is no infobar (as the password | 360 // Submit the form and verify that there is no infobar (as the password |
356 // has already been saved). | 361 // has already been saved). |
357 NavigationObserver second_observer(WebContents()); | 362 NavigationObserver second_observer(WebContents()); |
358 std::string submit_form = | 363 std::string submit_form = |
359 "document.getElementById('input_submit_button').click()"; | 364 "document.getElementById('input_submit_button').click()"; |
360 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit_form)); | 365 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit_form)); |
361 second_observer.Wait(); | 366 second_observer.Wait(); |
362 EXPECT_FALSE(second_observer.infobar_shown()); | 367 EXPECT_FALSE(second_observer.infobar_shown()); |
363 | 368 |
364 // Verify that we sent a ping to Autofill saying that the original form | 369 // Verify that we sent a ping to Autofill saying that the original form |
365 // was likely an account creation form since it has more than 2 text input | 370 // was likely an account creation form since it has more than 2 text input |
366 // fields and was used for the first time on a different form. | 371 // fields and was used for the first time on a different form. |
367 base::HistogramBase* upload_histogram = | 372 base::HistogramBase* upload_histogram = |
368 base::StatisticsRecorder::FindHistogram( | 373 base::StatisticsRecorder::FindHistogram( |
369 "PasswordGeneration.UploadStarted"); | 374 "PasswordGeneration.UploadStarted"); |
| 375 ASSERT_TRUE(upload_histogram); |
370 scoped_ptr<base::HistogramSamples> snapshot = | 376 scoped_ptr<base::HistogramSamples> snapshot = |
371 upload_histogram->SnapshotSamples(); | 377 upload_histogram->SnapshotSamples(); |
372 EXPECT_EQ(0, snapshot->GetCount(0 /* failure */)); | 378 EXPECT_EQ(0, snapshot->GetCount(0 /* failure */)); |
373 EXPECT_EQ(1, snapshot->GetCount(1 /* success */)); | 379 EXPECT_EQ(1, snapshot->GetCount(1 /* success */)); |
374 } | 380 } |
375 | 381 |
376 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, PromptForSubmitFromIframe) { | 382 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, PromptForSubmitFromIframe) { |
377 NavigateToFile("/password/password_submit_from_iframe.html"); | 383 NavigateToFile("/password/password_submit_from_iframe.html"); |
378 | 384 |
379 // Submit a form in an iframe, then cause the whole page to navigate without a | 385 // Submit a form in an iframe, then cause the whole page to navigate without a |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 "document.getElementById('username_field').value = 'temp';" | 467 "document.getElementById('username_field').value = 'temp';" |
462 "document.getElementById('password_field').value = 'random';" | 468 "document.getElementById('password_field').value = 'random';" |
463 "document.getElementById('input_submit_button').click();" | 469 "document.getElementById('input_submit_button').click();" |
464 "window.location.href = 'done.html';"; | 470 "window.location.href = 'done.html';"; |
465 | 471 |
466 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), save_and_remove)); | 472 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), save_and_remove)); |
467 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); | 473 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); |
468 observer.Wait(); | 474 observer.Wait(); |
469 // The only thing we check here is that there is no use-after-free reported. | 475 // The only thing we check here is that there is no use-after-free reported. |
470 } | 476 } |
OLD | NEW |