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

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

Issue 1286593003: [Password Manager] Store forms with field name and id attributes missing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed mac bot failure. Created 5 years, 3 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 | components/autofill/content/renderer/password_form_conversion_utils.cc » ('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 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 "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 std::string fill_and_submit = 890 std::string fill_and_submit =
891 "document.getElementsByName('username_field_no_id')[0].value = 'temp';" 891 "document.getElementsByName('username_field_no_id')[0].value = 'temp';"
892 "document.getElementsByName('password_field_no_id')[0].value = 'random';" 892 "document.getElementsByName('password_field_no_id')[0].value = 'random';"
893 "document.getElementsByName('input_submit_button_no_id')[0].click()"; 893 "document.getElementsByName('input_submit_button_no_id')[0].click()";
894 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 894 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
895 observer.Wait(); 895 observer.Wait();
896 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 896 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
897 } 897 }
898 898
899 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 899 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
900 NoPromptForInputElementWithoutIdAndName) { 900 PromptForInputElementWithoutIdAndName) {
901 // Check that no prompt is shown for forms where the input fields lack both 901 // Check that prompt is shown for forms where the input fields lack both
902 // the "id" and the "name" attributes. 902 // the "id" and the "name" attributes.
903 NavigateToFile("/password/password_form.html"); 903 NavigateToFile("/password/password_form.html");
904 904
905 NavigationObserver observer(WebContents()); 905 NavigationObserver observer(WebContents());
906 scoped_ptr<PromptObserver> prompt_observer( 906 scoped_ptr<PromptObserver> prompt_observer(
907 PromptObserver::Create(WebContents())); 907 PromptObserver::Create(WebContents()));
908 std::string fill_and_submit = 908 std::string fill_and_submit =
909 "var form = document.getElementById('testform_elements_no_id_no_name');" 909 "var form = document.getElementById('testform_elements_no_id_no_name');"
910 "var username = form.children[0];" 910 "var username = form.children[0];"
911 "username.value = 'temp';" 911 "username.value = 'temp';"
912 "var password = form.children[1];" 912 "var password = form.children[1];"
913 "password.value = 'random';" 913 "password.value = 'random';"
914 "form.children[2].click()"; // form.children[2] is the submit button. 914 "form.children[2].click()"; // form.children[2] is the submit button.
915 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 915 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
916 observer.Wait(); 916 observer.Wait();
917 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); 917 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
918 prompt_observer->Accept();
919
920 // Check that credentials are stored.
921 scoped_refptr<password_manager::TestPasswordStore> password_store =
922 static_cast<password_manager::TestPasswordStore*>(
923 PasswordStoreFactory::GetForProfile(
924 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS)
925 .get());
926
927 // Spin the message loop to make sure the password store had a chance to save
928 // the password.
929 base::RunLoop run_loop;
930 run_loop.RunUntilIdle();
931 EXPECT_FALSE(password_store->IsEmpty());
932
933 #if !defined(OS_MACOSX)
934 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
935 base::ASCIIToUTF16("random"));
936 #endif
918 } 937 }
919 938
920 // Test for checking that no prompt is shown for URLs with file: scheme. 939 // Test for checking that no prompt is shown for URLs with file: scheme.
921 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 940 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
922 NoPromptForFileSchemeURLs) { 941 NoPromptForFileSchemeURLs) {
923 GURL url = GetFileURL("password_form.html"); 942 GURL url = GetFileURL("password_form.html");
924 ui_test_utils::NavigateToURL(browser(), url); 943 ui_test_utils::NavigateToURL(browser(), url);
925 944
926 NavigationObserver observer(WebContents()); 945 NavigationObserver observer(WebContents());
927 scoped_ptr<PromptObserver> prompt_observer( 946 scoped_ptr<PromptObserver> prompt_observer(
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 observer.Wait(); 2112 observer.Wait();
2094 // The stored password "pw" was not overriden, so update prompt is not 2113 // The stored password "pw" was not overriden, so update prompt is not
2095 // expected. 2114 // expected.
2096 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); 2115 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt());
2097 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), 2116 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"),
2098 base::ASCIIToUTF16("pw")); 2117 base::ASCIIToUTF16("pw"));
2099 } 2118 }
2100 #endif 2119 #endif
2101 2120
2102 } // namespace password_manager 2121 } // namespace password_manager
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_form_conversion_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698