| 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/metrics/histogram_samples.h" | 11 #include "base/metrics/histogram_samples.h" |
| 11 #include "base/metrics/statistics_recorder.h" | 12 #include "base/metrics/statistics_recorder.h" |
| 12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 20 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 base::FilePath path; | 81 base::FilePath path; |
| 81 PathService::Get(chrome::DIR_TEST_DATA, &path); | 82 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 82 path = path.AppendASCII("password").AppendASCII(filename); | 83 path = path.AppendASCII("password").AppendASCII(filename); |
| 83 CHECK(base::PathExists(path)); | 84 CHECK(base::PathExists(path)); |
| 84 return net::FilePathToFileURL(path); | 85 return net::FilePathToFileURL(path); |
| 85 } | 86 } |
| 86 | 87 |
| 87 // Handles |request| to "/basic_auth". If "Authorization" header is present, | 88 // Handles |request| to "/basic_auth". If "Authorization" header is present, |
| 88 // responds with a non-empty HTTP 200 page (regardless of its value). Otherwise | 89 // responds with a non-empty HTTP 200 page (regardless of its value). Otherwise |
| 89 // serves a Basic Auth challenge. | 90 // serves a Basic Auth challenge. |
| 90 scoped_ptr<net::test_server::HttpResponse> HandleTestAuthRequest( | 91 std::unique_ptr<net::test_server::HttpResponse> HandleTestAuthRequest( |
| 91 const net::test_server::HttpRequest& request) { | 92 const net::test_server::HttpRequest& request) { |
| 92 if (!base::StartsWith(request.relative_url, "/basic_auth", | 93 if (!base::StartsWith(request.relative_url, "/basic_auth", |
| 93 base::CompareCase::SENSITIVE)) | 94 base::CompareCase::SENSITIVE)) |
| 94 return scoped_ptr<net::test_server::HttpResponse>(); | 95 return std::unique_ptr<net::test_server::HttpResponse>(); |
| 95 | 96 |
| 96 if (ContainsKey(request.headers, "Authorization")) { | 97 if (ContainsKey(request.headers, "Authorization")) { |
| 97 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 98 std::unique_ptr<net::test_server::BasicHttpResponse> http_response( |
| 98 new net::test_server::BasicHttpResponse); | 99 new net::test_server::BasicHttpResponse); |
| 99 http_response->set_code(net::HTTP_OK); | 100 http_response->set_code(net::HTTP_OK); |
| 100 http_response->set_content("Success!"); | 101 http_response->set_content("Success!"); |
| 101 return std::move(http_response); | 102 return std::move(http_response); |
| 102 } else { | 103 } else { |
| 103 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 104 std::unique_ptr<net::test_server::BasicHttpResponse> http_response( |
| 104 new net::test_server::BasicHttpResponse); | 105 new net::test_server::BasicHttpResponse); |
| 105 http_response->set_code(net::HTTP_UNAUTHORIZED); | 106 http_response->set_code(net::HTTP_UNAUTHORIZED); |
| 106 http_response->AddCustomHeader("WWW-Authenticate", | 107 http_response->AddCustomHeader("WWW-Authenticate", |
| 107 "Basic realm=\"test realm\""); | 108 "Basic realm=\"test realm\""); |
| 108 return std::move(http_response); | 109 return std::move(http_response); |
| 109 } | 110 } |
| 110 } | 111 } |
| 111 | 112 |
| 112 class ObservingAutofillClient : public autofill::TestAutofillClient { | 113 class ObservingAutofillClient : public autofill::TestAutofillClient { |
| 113 public: | 114 public: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 144 EXPECT_EQ(username, form.username_value); | 145 EXPECT_EQ(username, form.username_value); |
| 145 EXPECT_EQ(password, form.password_value); | 146 EXPECT_EQ(password, form.password_value); |
| 146 } | 147 } |
| 147 | 148 |
| 148 void TestPromptNotShown(const char* failure_message, | 149 void TestPromptNotShown(const char* failure_message, |
| 149 content::WebContents* web_contents, | 150 content::WebContents* web_contents, |
| 150 content::RenderViewHost* rvh) { | 151 content::RenderViewHost* rvh) { |
| 151 SCOPED_TRACE(testing::Message(failure_message)); | 152 SCOPED_TRACE(testing::Message(failure_message)); |
| 152 | 153 |
| 153 NavigationObserver observer(web_contents); | 154 NavigationObserver observer(web_contents); |
| 154 scoped_ptr<PromptObserver> prompt_observer( | 155 std::unique_ptr<PromptObserver> prompt_observer( |
| 155 PromptObserver::Create(web_contents)); | 156 PromptObserver::Create(web_contents)); |
| 156 std::string fill_and_submit = | 157 std::string fill_and_submit = |
| 157 "document.getElementById('username_failed').value = 'temp';" | 158 "document.getElementById('username_failed').value = 'temp';" |
| 158 "document.getElementById('password_failed').value = 'random';" | 159 "document.getElementById('password_failed').value = 'random';" |
| 159 "document.getElementById('failed_form').submit()"; | 160 "document.getElementById('failed_form').submit()"; |
| 160 | 161 |
| 161 ASSERT_TRUE(content::ExecuteScript(rvh, fill_and_submit)); | 162 ASSERT_TRUE(content::ExecuteScript(rvh, fill_and_submit)); |
| 162 observer.Wait(); | 163 observer.Wait(); |
| 163 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 164 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 164 } | 165 } |
| 165 | 166 |
| 166 } // namespace | 167 } // namespace |
| 167 | 168 |
| 168 namespace password_manager { | 169 namespace password_manager { |
| 169 | 170 |
| 170 // Actual tests --------------------------------------------------------------- | 171 // Actual tests --------------------------------------------------------------- |
| 171 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForNormalSubmit) { | 172 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForNormalSubmit) { |
| 172 NavigateToFile("/password/password_form.html"); | 173 NavigateToFile("/password/password_form.html"); |
| 173 | 174 |
| 174 // Fill a form and submit through a <input type="submit"> button. Nothing | 175 // Fill a form and submit through a <input type="submit"> button. Nothing |
| 175 // special. | 176 // special. |
| 176 NavigationObserver observer(WebContents()); | 177 NavigationObserver observer(WebContents()); |
| 177 scoped_ptr<PromptObserver> prompt_observer( | 178 std::unique_ptr<PromptObserver> prompt_observer( |
| 178 PromptObserver::Create(WebContents())); | 179 PromptObserver::Create(WebContents())); |
| 179 std::string fill_and_submit = | 180 std::string fill_and_submit = |
| 180 "document.getElementById('username_field').value = 'temp';" | 181 "document.getElementById('username_field').value = 'temp';" |
| 181 "document.getElementById('password_field').value = 'random';" | 182 "document.getElementById('password_field').value = 'random';" |
| 182 "document.getElementById('input_submit_button').click()"; | 183 "document.getElementById('input_submit_button').click()"; |
| 183 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 184 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 184 observer.Wait(); | 185 observer.Wait(); |
| 185 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 186 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 186 } | 187 } |
| 187 | 188 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 204 RenderViewHost()); | 205 RenderViewHost()); |
| 205 } | 206 } |
| 206 | 207 |
| 207 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 208 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 208 PromptForSubmitWithInPageNavigation) { | 209 PromptForSubmitWithInPageNavigation) { |
| 209 NavigateToFile("/password/password_navigate_before_submit.html"); | 210 NavigateToFile("/password/password_navigate_before_submit.html"); |
| 210 | 211 |
| 211 // Fill a form and submit through a <input type="submit"> button. Nothing | 212 // Fill a form and submit through a <input type="submit"> button. Nothing |
| 212 // special. The form does an in-page navigation before submitting. | 213 // special. The form does an in-page navigation before submitting. |
| 213 NavigationObserver observer(WebContents()); | 214 NavigationObserver observer(WebContents()); |
| 214 scoped_ptr<PromptObserver> prompt_observer( | 215 std::unique_ptr<PromptObserver> prompt_observer( |
| 215 PromptObserver::Create(WebContents())); | 216 PromptObserver::Create(WebContents())); |
| 216 std::string fill_and_submit = | 217 std::string fill_and_submit = |
| 217 "document.getElementById('username_field').value = 'temp';" | 218 "document.getElementById('username_field').value = 'temp';" |
| 218 "document.getElementById('password_field').value = 'random';" | 219 "document.getElementById('password_field').value = 'random';" |
| 219 "document.getElementById('input_submit_button').click()"; | 220 "document.getElementById('input_submit_button').click()"; |
| 220 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 221 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 221 observer.Wait(); | 222 observer.Wait(); |
| 222 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 223 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 223 } | 224 } |
| 224 | 225 |
| 225 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 226 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 226 LoginSuccessWithUnrelatedForm) { | 227 LoginSuccessWithUnrelatedForm) { |
| 227 // Log in, see a form on the landing page. That form is not related to the | 228 // Log in, see a form on the landing page. That form is not related to the |
| 228 // login form (=has a different action), so we should offer saving the | 229 // login form (=has a different action), so we should offer saving the |
| 229 // password. | 230 // password. |
| 230 NavigateToFile("/password/password_form.html"); | 231 NavigateToFile("/password/password_form.html"); |
| 231 | 232 |
| 232 NavigationObserver observer(WebContents()); | 233 NavigationObserver observer(WebContents()); |
| 233 scoped_ptr<PromptObserver> prompt_observer( | 234 std::unique_ptr<PromptObserver> prompt_observer( |
| 234 PromptObserver::Create(WebContents())); | 235 PromptObserver::Create(WebContents())); |
| 235 std::string fill_and_submit = | 236 std::string fill_and_submit = |
| 236 "document.getElementById('username_unrelated').value = 'temp';" | 237 "document.getElementById('username_unrelated').value = 'temp';" |
| 237 "document.getElementById('password_unrelated').value = 'random';" | 238 "document.getElementById('password_unrelated').value = 'random';" |
| 238 "document.getElementById('submit_unrelated').click()"; | 239 "document.getElementById('submit_unrelated').click()"; |
| 239 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 240 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 240 observer.Wait(); | 241 observer.Wait(); |
| 241 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 242 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 242 } | 243 } |
| 243 | 244 |
| 244 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, LoginFailed) { | 245 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, LoginFailed) { |
| 245 // Log in, see a form on the landing page. That form is not related to the | 246 // Log in, see a form on the landing page. That form is not related to the |
| 246 // login form (=has a different action), so we should offer saving the | 247 // login form (=has a different action), so we should offer saving the |
| 247 // password. | 248 // password. |
| 248 NavigateToFile("/password/password_form.html"); | 249 NavigateToFile("/password/password_form.html"); |
| 249 | 250 |
| 250 NavigationObserver observer(WebContents()); | 251 NavigationObserver observer(WebContents()); |
| 251 scoped_ptr<PromptObserver> prompt_observer( | 252 std::unique_ptr<PromptObserver> prompt_observer( |
| 252 PromptObserver::Create(WebContents())); | 253 PromptObserver::Create(WebContents())); |
| 253 std::string fill_and_submit = | 254 std::string fill_and_submit = |
| 254 "document.getElementById('username_failed').value = 'temp';" | 255 "document.getElementById('username_failed').value = 'temp';" |
| 255 "document.getElementById('password_failed').value = 'random';" | 256 "document.getElementById('password_failed').value = 'random';" |
| 256 "document.getElementById('submit_failed').click()"; | 257 "document.getElementById('submit_failed').click()"; |
| 257 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 258 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 258 observer.Wait(); | 259 observer.Wait(); |
| 259 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 260 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 260 } | 261 } |
| 261 | 262 |
| 262 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, Redirects) { | 263 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, Redirects) { |
| 263 NavigateToFile("/password/password_form.html"); | 264 NavigateToFile("/password/password_form.html"); |
| 264 | 265 |
| 265 // Fill a form and submit through a <input type="submit"> button. The form | 266 // Fill a form and submit through a <input type="submit"> button. The form |
| 266 // points to a redirection page. | 267 // points to a redirection page. |
| 267 NavigationObserver observer(WebContents()); | 268 NavigationObserver observer(WebContents()); |
| 268 scoped_ptr<PromptObserver> prompt_observer( | 269 std::unique_ptr<PromptObserver> prompt_observer( |
| 269 PromptObserver::Create(WebContents())); | 270 PromptObserver::Create(WebContents())); |
| 270 std::string fill_and_submit = | 271 std::string fill_and_submit = |
| 271 "document.getElementById('username_redirect').value = 'temp';" | 272 "document.getElementById('username_redirect').value = 'temp';" |
| 272 "document.getElementById('password_redirect').value = 'random';" | 273 "document.getElementById('password_redirect').value = 'random';" |
| 273 "document.getElementById('submit_redirect').click()"; | 274 "document.getElementById('submit_redirect').click()"; |
| 274 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 275 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 275 observer.Wait(); | 276 observer.Wait(); |
| 276 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 277 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 277 | 278 |
| 278 // The redirection page now redirects via Javascript. We check that the | 279 // The redirection page now redirects via Javascript. We check that the |
| 279 // infobar stays. | 280 // infobar stays. |
| 280 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 281 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
| 281 "window.location.href = 'done.html';")); | 282 "window.location.href = 'done.html';")); |
| 282 observer.Wait(); | 283 observer.Wait(); |
| 283 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 284 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 284 } | 285 } |
| 285 | 286 |
| 286 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 287 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 287 PromptForSubmitUsingJavaScript) { | 288 PromptForSubmitUsingJavaScript) { |
| 288 NavigateToFile("/password/password_form.html"); | 289 NavigateToFile("/password/password_form.html"); |
| 289 | 290 |
| 290 // Fill a form and submit using <button> that calls submit() on the form. | 291 // Fill a form and submit using <button> that calls submit() on the form. |
| 291 // This should work regardless of the type of element, as long as submit() is | 292 // This should work regardless of the type of element, as long as submit() is |
| 292 // called. | 293 // called. |
| 293 NavigationObserver observer(WebContents()); | 294 NavigationObserver observer(WebContents()); |
| 294 scoped_ptr<PromptObserver> prompt_observer( | 295 std::unique_ptr<PromptObserver> prompt_observer( |
| 295 PromptObserver::Create(WebContents())); | 296 PromptObserver::Create(WebContents())); |
| 296 std::string fill_and_submit = | 297 std::string fill_and_submit = |
| 297 "document.getElementById('username_field').value = 'temp';" | 298 "document.getElementById('username_field').value = 'temp';" |
| 298 "document.getElementById('password_field').value = 'random';" | 299 "document.getElementById('password_field').value = 'random';" |
| 299 "document.getElementById('submit_button').click()"; | 300 "document.getElementById('submit_button').click()"; |
| 300 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 301 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 301 observer.Wait(); | 302 observer.Wait(); |
| 302 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 303 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 303 } | 304 } |
| 304 | 305 |
| 305 // Flaky: crbug.com/301547, observed on win and mac. Probably happens on all | 306 // Flaky: crbug.com/301547, observed on win and mac. Probably happens on all |
| 306 // platforms. | 307 // platforms. |
| 307 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 308 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 308 DISABLED_PromptForDynamicForm) { | 309 DISABLED_PromptForDynamicForm) { |
| 309 NavigateToFile("/password/dynamic_password_form.html"); | 310 NavigateToFile("/password/dynamic_password_form.html"); |
| 310 | 311 |
| 311 // Fill the dynamic password form and submit. | 312 // Fill the dynamic password form and submit. |
| 312 NavigationObserver observer(WebContents()); | 313 NavigationObserver observer(WebContents()); |
| 313 scoped_ptr<PromptObserver> prompt_observer( | 314 std::unique_ptr<PromptObserver> prompt_observer( |
| 314 PromptObserver::Create(WebContents())); | 315 PromptObserver::Create(WebContents())); |
| 315 std::string fill_and_submit = | 316 std::string fill_and_submit = |
| 316 "document.getElementById('create_form_button').click();" | 317 "document.getElementById('create_form_button').click();" |
| 317 "window.setTimeout(function() {" | 318 "window.setTimeout(function() {" |
| 318 " document.dynamic_form.username.value = 'tempro';" | 319 " document.dynamic_form.username.value = 'tempro';" |
| 319 " document.dynamic_form.password.value = 'random';" | 320 " document.dynamic_form.password.value = 'random';" |
| 320 " document.dynamic_form.submit();" | 321 " document.dynamic_form.submit();" |
| 321 "}, 0)"; | 322 "}, 0)"; |
| 322 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 323 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 323 observer.Wait(); | 324 observer.Wait(); |
| 324 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 325 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 325 } | 326 } |
| 326 | 327 |
| 327 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptForNavigation) { | 328 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptForNavigation) { |
| 328 NavigateToFile("/password/password_form.html"); | 329 NavigateToFile("/password/password_form.html"); |
| 329 | 330 |
| 330 // Don't fill the password form, just navigate away. Shouldn't prompt. | 331 // Don't fill the password form, just navigate away. Shouldn't prompt. |
| 331 NavigationObserver observer(WebContents()); | 332 NavigationObserver observer(WebContents()); |
| 332 scoped_ptr<PromptObserver> prompt_observer( | 333 std::unique_ptr<PromptObserver> prompt_observer( |
| 333 PromptObserver::Create(WebContents())); | 334 PromptObserver::Create(WebContents())); |
| 334 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 335 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
| 335 "window.location.href = 'done.html';")); | 336 "window.location.href = 'done.html';")); |
| 336 observer.Wait(); | 337 observer.Wait(); |
| 337 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 338 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 338 } | 339 } |
| 339 | 340 |
| 340 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 341 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 341 NoPromptForSubFrameNavigation) { | 342 NoPromptForSubFrameNavigation) { |
| 342 NavigateToFile("/password/multi_frames.html"); | 343 NavigateToFile("/password/multi_frames.html"); |
| 343 | 344 |
| 344 // If you are filling out a password form in one frame and a different frame | 345 // If you are filling out a password form in one frame and a different frame |
| 345 // navigates, this should not trigger the infobar. | 346 // navigates, this should not trigger the infobar. |
| 346 NavigationObserver observer(WebContents()); | 347 NavigationObserver observer(WebContents()); |
| 347 scoped_ptr<PromptObserver> prompt_observer( | 348 std::unique_ptr<PromptObserver> prompt_observer( |
| 348 PromptObserver::Create(WebContents())); | 349 PromptObserver::Create(WebContents())); |
| 349 observer.SetPathToWaitFor("/password/done.html"); | 350 observer.SetPathToWaitFor("/password/done.html"); |
| 350 std::string fill = | 351 std::string fill = |
| 351 "var first_frame = document.getElementById('first_frame');" | 352 "var first_frame = document.getElementById('first_frame');" |
| 352 "var frame_doc = first_frame.contentDocument;" | 353 "var frame_doc = first_frame.contentDocument;" |
| 353 "frame_doc.getElementById('username_field').value = 'temp';" | 354 "frame_doc.getElementById('username_field').value = 'temp';" |
| 354 "frame_doc.getElementById('password_field').value = 'random';"; | 355 "frame_doc.getElementById('password_field').value = 'random';"; |
| 355 std::string navigate_frame = | 356 std::string navigate_frame = |
| 356 "var second_iframe = document.getElementById('second_frame');" | 357 "var second_iframe = document.getElementById('second_frame');" |
| 357 "second_iframe.contentWindow.location.href = 'done.html';"; | 358 "second_iframe.contentWindow.location.href = 'done.html';"; |
| 358 | 359 |
| 359 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); | 360 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); |
| 360 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); | 361 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); |
| 361 observer.Wait(); | 362 observer.Wait(); |
| 362 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 363 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 363 } | 364 } |
| 364 | 365 |
| 365 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 366 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 366 PromptAfterSubmitWithSubFrameNavigation) { | 367 PromptAfterSubmitWithSubFrameNavigation) { |
| 367 NavigateToFile("/password/multi_frames.html"); | 368 NavigateToFile("/password/multi_frames.html"); |
| 368 | 369 |
| 369 // Make sure that we prompt to save password even if a sub-frame navigation | 370 // Make sure that we prompt to save password even if a sub-frame navigation |
| 370 // happens first. | 371 // happens first. |
| 371 NavigationObserver observer(WebContents()); | 372 NavigationObserver observer(WebContents()); |
| 372 scoped_ptr<PromptObserver> prompt_observer( | 373 std::unique_ptr<PromptObserver> prompt_observer( |
| 373 PromptObserver::Create(WebContents())); | 374 PromptObserver::Create(WebContents())); |
| 374 observer.SetPathToWaitFor("/password/done.html"); | 375 observer.SetPathToWaitFor("/password/done.html"); |
| 375 std::string navigate_frame = | 376 std::string navigate_frame = |
| 376 "var second_iframe = document.getElementById('second_frame');" | 377 "var second_iframe = document.getElementById('second_frame');" |
| 377 "second_iframe.contentWindow.location.href = 'other.html';"; | 378 "second_iframe.contentWindow.location.href = 'other.html';"; |
| 378 std::string fill_and_submit = | 379 std::string fill_and_submit = |
| 379 "var first_frame = document.getElementById('first_frame');" | 380 "var first_frame = document.getElementById('first_frame');" |
| 380 "var frame_doc = first_frame.contentDocument;" | 381 "var frame_doc = first_frame.contentDocument;" |
| 381 "frame_doc.getElementById('username_field').value = 'temp';" | 382 "frame_doc.getElementById('username_field').value = 'temp';" |
| 382 "frame_doc.getElementById('password_field').value = 'random';" | 383 "frame_doc.getElementById('password_field').value = 'random';" |
| 383 "frame_doc.getElementById('input_submit_button').click();"; | 384 "frame_doc.getElementById('input_submit_button').click();"; |
| 384 | 385 |
| 385 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); | 386 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); |
| 386 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 387 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 387 observer.Wait(); | 388 observer.Wait(); |
| 388 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 389 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 389 } | 390 } |
| 390 | 391 |
| 391 IN_PROC_BROWSER_TEST_F( | 392 IN_PROC_BROWSER_TEST_F( |
| 392 PasswordManagerBrowserTestBase, | 393 PasswordManagerBrowserTestBase, |
| 393 NoPromptForFailedLoginFromMainFrameWithMultiFramesInPage) { | 394 NoPromptForFailedLoginFromMainFrameWithMultiFramesInPage) { |
| 394 NavigateToFile("/password/multi_frames.html"); | 395 NavigateToFile("/password/multi_frames.html"); |
| 395 | 396 |
| 396 // Make sure that we don't prompt to save the password for a failed login | 397 // Make sure that we don't prompt to save the password for a failed login |
| 397 // from the main frame with multiple frames in the same page. | 398 // from the main frame with multiple frames in the same page. |
| 398 NavigationObserver observer(WebContents()); | 399 NavigationObserver observer(WebContents()); |
| 399 scoped_ptr<PromptObserver> prompt_observer( | 400 std::unique_ptr<PromptObserver> prompt_observer( |
| 400 PromptObserver::Create(WebContents())); | 401 PromptObserver::Create(WebContents())); |
| 401 std::string fill_and_submit = | 402 std::string fill_and_submit = |
| 402 "document.getElementById('username_failed').value = 'temp';" | 403 "document.getElementById('username_failed').value = 'temp';" |
| 403 "document.getElementById('password_failed').value = 'random';" | 404 "document.getElementById('password_failed').value = 'random';" |
| 404 "document.getElementById('submit_failed').click();"; | 405 "document.getElementById('submit_failed').click();"; |
| 405 | 406 |
| 406 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 407 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 407 observer.Wait(); | 408 observer.Wait(); |
| 408 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 409 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 409 } | 410 } |
| 410 | 411 |
| 411 IN_PROC_BROWSER_TEST_F( | 412 IN_PROC_BROWSER_TEST_F( |
| 412 PasswordManagerBrowserTestBase, | 413 PasswordManagerBrowserTestBase, |
| 413 NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage) { | 414 NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage) { |
| 414 NavigateToFile("/password/multi_frames.html"); | 415 NavigateToFile("/password/multi_frames.html"); |
| 415 | 416 |
| 416 // Make sure that we don't prompt to save the password for a failed login | 417 // Make sure that we don't prompt to save the password for a failed login |
| 417 // from a sub-frame with multiple frames in the same page. | 418 // from a sub-frame with multiple frames in the same page. |
| 418 NavigationObserver observer(WebContents()); | 419 NavigationObserver observer(WebContents()); |
| 419 scoped_ptr<PromptObserver> prompt_observer( | 420 std::unique_ptr<PromptObserver> prompt_observer( |
| 420 PromptObserver::Create(WebContents())); | 421 PromptObserver::Create(WebContents())); |
| 421 std::string fill_and_submit = | 422 std::string fill_and_submit = |
| 422 "var first_frame = document.getElementById('first_frame');" | 423 "var first_frame = document.getElementById('first_frame');" |
| 423 "var frame_doc = first_frame.contentDocument;" | 424 "var frame_doc = first_frame.contentDocument;" |
| 424 "frame_doc.getElementById('username_failed').value = 'temp';" | 425 "frame_doc.getElementById('username_failed').value = 'temp';" |
| 425 "frame_doc.getElementById('password_failed').value = 'random';" | 426 "frame_doc.getElementById('password_failed').value = 'random';" |
| 426 "frame_doc.getElementById('submit_failed').click();"; | 427 "frame_doc.getElementById('submit_failed').click();"; |
| 427 | 428 |
| 428 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 429 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 429 observer.SetPathToWaitFor("/password/failed.html"); | 430 observer.SetPathToWaitFor("/password/failed.html"); |
| 430 observer.Wait(); | 431 observer.Wait(); |
| 431 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 432 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 432 } | 433 } |
| 433 | 434 |
| 434 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForXHRSubmit) { | 435 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForXHRSubmit) { |
| 435 #if defined(OS_WIN) && defined(USE_ASH) | 436 #if defined(OS_WIN) && defined(USE_ASH) |
| 436 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 437 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 437 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 438 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 438 ::switches::kAshBrowserTests)) | 439 ::switches::kAshBrowserTests)) |
| 439 return; | 440 return; |
| 440 #endif | 441 #endif |
| 441 NavigateToFile("/password/password_xhr_submit.html"); | 442 NavigateToFile("/password/password_xhr_submit.html"); |
| 442 | 443 |
| 443 // Verify that we show the save password prompt if a form returns false | 444 // Verify that we show the save password prompt if a form returns false |
| 444 // in its onsubmit handler but instead logs in/navigates via XHR. | 445 // in its onsubmit handler but instead logs in/navigates via XHR. |
| 445 // Note that calling 'submit()' on a form with javascript doesn't call | 446 // Note that calling 'submit()' on a form with javascript doesn't call |
| 446 // the onsubmit handler, so we click the submit button instead. | 447 // the onsubmit handler, so we click the submit button instead. |
| 447 NavigationObserver observer(WebContents()); | 448 NavigationObserver observer(WebContents()); |
| 448 scoped_ptr<PromptObserver> prompt_observer( | 449 std::unique_ptr<PromptObserver> prompt_observer( |
| 449 PromptObserver::Create(WebContents())); | 450 PromptObserver::Create(WebContents())); |
| 450 std::string fill_and_submit = | 451 std::string fill_and_submit = |
| 451 "document.getElementById('username_field').value = 'temp';" | 452 "document.getElementById('username_field').value = 'temp';" |
| 452 "document.getElementById('password_field').value = 'random';" | 453 "document.getElementById('password_field').value = 'random';" |
| 453 "document.getElementById('submit_button').click()"; | 454 "document.getElementById('submit_button').click()"; |
| 454 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 455 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 455 observer.Wait(); | 456 observer.Wait(); |
| 456 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 457 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 457 } | 458 } |
| 458 | 459 |
| 459 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 460 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 460 PromptForXHRWithoutOnSubmit) { | 461 PromptForXHRWithoutOnSubmit) { |
| 461 NavigateToFile("/password/password_xhr_submit.html"); | 462 NavigateToFile("/password/password_xhr_submit.html"); |
| 462 | 463 |
| 463 // Verify that if XHR navigation occurs and the form is properly filled out, | 464 // Verify that if XHR navigation occurs and the form is properly filled out, |
| 464 // we try and save the password even though onsubmit hasn't been called. | 465 // we try and save the password even though onsubmit hasn't been called. |
| 465 NavigationObserver observer(WebContents()); | 466 NavigationObserver observer(WebContents()); |
| 466 scoped_ptr<PromptObserver> prompt_observer( | 467 std::unique_ptr<PromptObserver> prompt_observer( |
| 467 PromptObserver::Create(WebContents())); | 468 PromptObserver::Create(WebContents())); |
| 468 std::string fill_and_navigate = | 469 std::string fill_and_navigate = |
| 469 "document.getElementById('username_field').value = 'temp';" | 470 "document.getElementById('username_field').value = 'temp';" |
| 470 "document.getElementById('password_field').value = 'random';" | 471 "document.getElementById('password_field').value = 'random';" |
| 471 "send_xhr()"; | 472 "send_xhr()"; |
| 472 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 473 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
| 473 observer.Wait(); | 474 observer.Wait(); |
| 474 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 475 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 475 } | 476 } |
| 476 | 477 |
| 477 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 478 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 478 PromptForXHRWithNewPasswordsWithoutOnSubmit) { | 479 PromptForXHRWithNewPasswordsWithoutOnSubmit) { |
| 479 NavigateToFile("/password/password_xhr_submit.html"); | 480 NavigateToFile("/password/password_xhr_submit.html"); |
| 480 | 481 |
| 481 // Verify that if XHR navigation occurs and the form is properly filled out, | 482 // Verify that if XHR navigation occurs and the form is properly filled out, |
| 482 // we try and save the password even though onsubmit hasn't been called. | 483 // we try and save the password even though onsubmit hasn't been called. |
| 483 // Specifically verify that the password form saving new passwords is treated | 484 // Specifically verify that the password form saving new passwords is treated |
| 484 // the same as a login form. | 485 // the same as a login form. |
| 485 NavigationObserver observer(WebContents()); | 486 NavigationObserver observer(WebContents()); |
| 486 scoped_ptr<PromptObserver> prompt_observer( | 487 std::unique_ptr<PromptObserver> prompt_observer( |
| 487 PromptObserver::Create(WebContents())); | 488 PromptObserver::Create(WebContents())); |
| 488 std::string fill_and_navigate = | 489 std::string fill_and_navigate = |
| 489 "document.getElementById('signup_username_field').value = 'temp';" | 490 "document.getElementById('signup_username_field').value = 'temp';" |
| 490 "document.getElementById('signup_password_field').value = 'random';" | 491 "document.getElementById('signup_password_field').value = 'random';" |
| 491 "document.getElementById('confirmation_password_field').value = 'random';" | 492 "document.getElementById('confirmation_password_field').value = 'random';" |
| 492 "send_xhr()"; | 493 "send_xhr()"; |
| 493 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 494 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
| 494 observer.Wait(); | 495 observer.Wait(); |
| 495 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 496 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 496 } | 497 } |
| 497 | 498 |
| 498 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 499 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 499 PromptForXHRSubmitWithoutNavigation) { | 500 PromptForXHRSubmitWithoutNavigation) { |
| 500 NavigateToFile("/password/password_xhr_submit.html"); | 501 NavigateToFile("/password/password_xhr_submit.html"); |
| 501 | 502 |
| 502 // Need to pay attention for a message that XHR has finished since there | 503 // Need to pay attention for a message that XHR has finished since there |
| 503 // is no navigation to wait for. | 504 // is no navigation to wait for. |
| 504 content::DOMMessageQueue message_queue; | 505 content::DOMMessageQueue message_queue; |
| 505 | 506 |
| 506 // Verify that if XHR without navigation occurs and the form has been filled | 507 // Verify that if XHR without navigation occurs and the form has been filled |
| 507 // out we try and save the password. Note that in general the submission | 508 // out we try and save the password. Note that in general the submission |
| 508 // doesn't need to be via form.submit(), but for testing purposes it's | 509 // doesn't need to be via form.submit(), but for testing purposes it's |
| 509 // necessary since we otherwise ignore changes made to the value of these | 510 // necessary since we otherwise ignore changes made to the value of these |
| 510 // fields by script. | 511 // fields by script. |
| 511 scoped_ptr<PromptObserver> prompt_observer( | 512 std::unique_ptr<PromptObserver> prompt_observer( |
| 512 PromptObserver::Create(WebContents())); | 513 PromptObserver::Create(WebContents())); |
| 513 std::string fill_and_submit = | 514 std::string fill_and_submit = |
| 514 "navigate = false;" | 515 "navigate = false;" |
| 515 "document.getElementById('username_field').value = 'temp';" | 516 "document.getElementById('username_field').value = 'temp';" |
| 516 "document.getElementById('password_field').value = 'random';" | 517 "document.getElementById('password_field').value = 'random';" |
| 517 "document.getElementById('submit_button').click();"; | 518 "document.getElementById('submit_button').click();"; |
| 518 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 519 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 519 std::string message; | 520 std::string message; |
| 520 while (message_queue.WaitForMessage(&message)) { | 521 while (message_queue.WaitForMessage(&message)) { |
| 521 if (message == "\"XHR_FINISHED\"") | 522 if (message == "\"XHR_FINISHED\"") |
| 522 break; | 523 break; |
| 523 } | 524 } |
| 524 | 525 |
| 525 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 526 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 526 } | 527 } |
| 527 | 528 |
| 528 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 529 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 529 PromptForXHRSubmitWithoutNavigation_SignupForm) { | 530 PromptForXHRSubmitWithoutNavigation_SignupForm) { |
| 530 NavigateToFile("/password/password_xhr_submit.html"); | 531 NavigateToFile("/password/password_xhr_submit.html"); |
| 531 | 532 |
| 532 // Need to pay attention for a message that XHR has finished since there | 533 // Need to pay attention for a message that XHR has finished since there |
| 533 // is no navigation to wait for. | 534 // is no navigation to wait for. |
| 534 content::DOMMessageQueue message_queue; | 535 content::DOMMessageQueue message_queue; |
| 535 | 536 |
| 536 // Verify that if XHR without navigation occurs and the form has been filled | 537 // Verify that if XHR without navigation occurs and the form has been filled |
| 537 // out we try and save the password. Note that in general the submission | 538 // out we try and save the password. Note that in general the submission |
| 538 // doesn't need to be via form.submit(), but for testing purposes it's | 539 // doesn't need to be via form.submit(), but for testing purposes it's |
| 539 // necessary since we otherwise ignore changes made to the value of these | 540 // necessary since we otherwise ignore changes made to the value of these |
| 540 // fields by script. | 541 // fields by script. |
| 541 scoped_ptr<PromptObserver> prompt_observer( | 542 std::unique_ptr<PromptObserver> prompt_observer( |
| 542 PromptObserver::Create(WebContents())); | 543 PromptObserver::Create(WebContents())); |
| 543 std::string fill_and_submit = | 544 std::string fill_and_submit = |
| 544 "navigate = false;" | 545 "navigate = false;" |
| 545 "document.getElementById('signup_username_field').value = 'temp';" | 546 "document.getElementById('signup_username_field').value = 'temp';" |
| 546 "document.getElementById('signup_password_field').value = 'random';" | 547 "document.getElementById('signup_password_field').value = 'random';" |
| 547 "document.getElementById('confirmation_password_field').value = 'random';" | 548 "document.getElementById('confirmation_password_field').value = 'random';" |
| 548 "document.getElementById('signup_submit_button').click();"; | 549 "document.getElementById('signup_submit_button').click();"; |
| 549 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 550 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 550 std::string message; | 551 std::string message; |
| 551 while (message_queue.WaitForMessage(&message)) { | 552 while (message_queue.WaitForMessage(&message)) { |
| 552 if (message == "\"XHR_FINISHED\"") | 553 if (message == "\"XHR_FINISHED\"") |
| 553 break; | 554 break; |
| 554 } | 555 } |
| 555 | 556 |
| 556 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 557 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 557 } | 558 } |
| 558 | 559 |
| 559 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 560 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 560 NoPromptForXHRSubmitWithoutNavigationWithUnfilledForm) { | 561 NoPromptForXHRSubmitWithoutNavigationWithUnfilledForm) { |
| 561 NavigateToFile("/password/password_xhr_submit.html"); | 562 NavigateToFile("/password/password_xhr_submit.html"); |
| 562 | 563 |
| 563 // Need to pay attention for a message that XHR has finished since there | 564 // Need to pay attention for a message that XHR has finished since there |
| 564 // is no navigation to wait for. | 565 // is no navigation to wait for. |
| 565 content::DOMMessageQueue message_queue; | 566 content::DOMMessageQueue message_queue; |
| 566 | 567 |
| 567 // Verify that if XHR without navigation occurs and the form has NOT been | 568 // Verify that if XHR without navigation occurs and the form has NOT been |
| 568 // filled out we don't prompt. | 569 // filled out we don't prompt. |
| 569 scoped_ptr<PromptObserver> prompt_observer( | 570 std::unique_ptr<PromptObserver> prompt_observer( |
| 570 PromptObserver::Create(WebContents())); | 571 PromptObserver::Create(WebContents())); |
| 571 std::string fill_and_submit = | 572 std::string fill_and_submit = |
| 572 "navigate = false;" | 573 "navigate = false;" |
| 573 "document.getElementById('username_field').value = 'temp';" | 574 "document.getElementById('username_field').value = 'temp';" |
| 574 "document.getElementById('submit_button').click();"; | 575 "document.getElementById('submit_button').click();"; |
| 575 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 576 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 576 std::string message; | 577 std::string message; |
| 577 while (message_queue.WaitForMessage(&message)) { | 578 while (message_queue.WaitForMessage(&message)) { |
| 578 if (message == "\"XHR_FINISHED\"") | 579 if (message == "\"XHR_FINISHED\"") |
| 579 break; | 580 break; |
| 580 } | 581 } |
| 581 | 582 |
| 582 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 583 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 583 } | 584 } |
| 584 | 585 |
| 585 IN_PROC_BROWSER_TEST_F( | 586 IN_PROC_BROWSER_TEST_F( |
| 586 PasswordManagerBrowserTestBase, | 587 PasswordManagerBrowserTestBase, |
| 587 NoPromptForXHRSubmitWithoutNavigationWithUnfilledForm_SignupForm) { | 588 NoPromptForXHRSubmitWithoutNavigationWithUnfilledForm_SignupForm) { |
| 588 NavigateToFile("/password/password_xhr_submit.html"); | 589 NavigateToFile("/password/password_xhr_submit.html"); |
| 589 | 590 |
| 590 // Need to pay attention for a message that XHR has finished since there | 591 // Need to pay attention for a message that XHR has finished since there |
| 591 // is no navigation to wait for. | 592 // is no navigation to wait for. |
| 592 content::DOMMessageQueue message_queue; | 593 content::DOMMessageQueue message_queue; |
| 593 | 594 |
| 594 // Verify that if XHR without navigation occurs and the form has NOT been | 595 // Verify that if XHR without navigation occurs and the form has NOT been |
| 595 // filled out we don't prompt. | 596 // filled out we don't prompt. |
| 596 scoped_ptr<PromptObserver> prompt_observer( | 597 std::unique_ptr<PromptObserver> prompt_observer( |
| 597 PromptObserver::Create(WebContents())); | 598 PromptObserver::Create(WebContents())); |
| 598 std::string fill_and_submit = | 599 std::string fill_and_submit = |
| 599 "navigate = false;" | 600 "navigate = false;" |
| 600 "document.getElementById('signup_username_field').value = 'temp';" | 601 "document.getElementById('signup_username_field').value = 'temp';" |
| 601 "document.getElementById('signup_submit_button').click();"; | 602 "document.getElementById('signup_submit_button').click();"; |
| 602 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 603 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 603 std::string message; | 604 std::string message; |
| 604 while (message_queue.WaitForMessage(&message)) { | 605 while (message_queue.WaitForMessage(&message)) { |
| 605 if (message == "\"XHR_FINISHED\"") | 606 if (message == "\"XHR_FINISHED\"") |
| 606 break; | 607 break; |
| 607 } | 608 } |
| 608 | 609 |
| 609 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 610 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 610 } | 611 } |
| 611 | 612 |
| 612 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForFetchSubmit) { | 613 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForFetchSubmit) { |
| 613 #if defined(OS_WIN) && defined(USE_ASH) | 614 #if defined(OS_WIN) && defined(USE_ASH) |
| 614 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 615 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 615 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 616 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 616 ::switches::kAshBrowserTests)) | 617 ::switches::kAshBrowserTests)) |
| 617 return; | 618 return; |
| 618 #endif | 619 #endif |
| 619 NavigateToFile("/password/password_fetch_submit.html"); | 620 NavigateToFile("/password/password_fetch_submit.html"); |
| 620 | 621 |
| 621 // Verify that we show the save password prompt if a form returns false | 622 // Verify that we show the save password prompt if a form returns false |
| 622 // in its onsubmit handler but instead logs in/navigates via Fetch. | 623 // in its onsubmit handler but instead logs in/navigates via Fetch. |
| 623 // Note that calling 'submit()' on a form with javascript doesn't call | 624 // Note that calling 'submit()' on a form with javascript doesn't call |
| 624 // the onsubmit handler, so we click the submit button instead. | 625 // the onsubmit handler, so we click the submit button instead. |
| 625 NavigationObserver observer(WebContents()); | 626 NavigationObserver observer(WebContents()); |
| 626 scoped_ptr<PromptObserver> prompt_observer( | 627 std::unique_ptr<PromptObserver> prompt_observer( |
| 627 PromptObserver::Create(WebContents())); | 628 PromptObserver::Create(WebContents())); |
| 628 std::string fill_and_submit = | 629 std::string fill_and_submit = |
| 629 "document.getElementById('username_field').value = 'temp';" | 630 "document.getElementById('username_field').value = 'temp';" |
| 630 "document.getElementById('password_field').value = 'random';" | 631 "document.getElementById('password_field').value = 'random';" |
| 631 "document.getElementById('submit_button').click()"; | 632 "document.getElementById('submit_button').click()"; |
| 632 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 633 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 633 observer.Wait(); | 634 observer.Wait(); |
| 634 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 635 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 635 } | 636 } |
| 636 | 637 |
| 637 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 638 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 638 PromptForFetchWithoutOnSubmit) { | 639 PromptForFetchWithoutOnSubmit) { |
| 639 NavigateToFile("/password/password_fetch_submit.html"); | 640 NavigateToFile("/password/password_fetch_submit.html"); |
| 640 | 641 |
| 641 // Verify that if Fetch navigation occurs and the form is properly filled out, | 642 // Verify that if Fetch navigation occurs and the form is properly filled out, |
| 642 // we try and save the password even though onsubmit hasn't been called. | 643 // we try and save the password even though onsubmit hasn't been called. |
| 643 NavigationObserver observer(WebContents()); | 644 NavigationObserver observer(WebContents()); |
| 644 scoped_ptr<PromptObserver> prompt_observer( | 645 std::unique_ptr<PromptObserver> prompt_observer( |
| 645 PromptObserver::Create(WebContents())); | 646 PromptObserver::Create(WebContents())); |
| 646 std::string fill_and_navigate = | 647 std::string fill_and_navigate = |
| 647 "document.getElementById('username_field').value = 'temp';" | 648 "document.getElementById('username_field').value = 'temp';" |
| 648 "document.getElementById('password_field').value = 'random';" | 649 "document.getElementById('password_field').value = 'random';" |
| 649 "send_fetch()"; | 650 "send_fetch()"; |
| 650 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 651 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
| 651 observer.Wait(); | 652 observer.Wait(); |
| 652 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 653 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 653 } | 654 } |
| 654 | 655 |
| 655 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 656 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 656 PromptForFetchWithNewPasswordsWithoutOnSubmit) { | 657 PromptForFetchWithNewPasswordsWithoutOnSubmit) { |
| 657 NavigateToFile("/password/password_fetch_submit.html"); | 658 NavigateToFile("/password/password_fetch_submit.html"); |
| 658 | 659 |
| 659 // Verify that if Fetch navigation occurs and the form is properly filled out, | 660 // Verify that if Fetch navigation occurs and the form is properly filled out, |
| 660 // we try and save the password even though onsubmit hasn't been called. | 661 // we try and save the password even though onsubmit hasn't been called. |
| 661 // Specifically verify that the password form saving new passwords is treated | 662 // Specifically verify that the password form saving new passwords is treated |
| 662 // the same as a login form. | 663 // the same as a login form. |
| 663 NavigationObserver observer(WebContents()); | 664 NavigationObserver observer(WebContents()); |
| 664 scoped_ptr<PromptObserver> prompt_observer( | 665 std::unique_ptr<PromptObserver> prompt_observer( |
| 665 PromptObserver::Create(WebContents())); | 666 PromptObserver::Create(WebContents())); |
| 666 std::string fill_and_navigate = | 667 std::string fill_and_navigate = |
| 667 "document.getElementById('signup_username_field').value = 'temp';" | 668 "document.getElementById('signup_username_field').value = 'temp';" |
| 668 "document.getElementById('signup_password_field').value = 'random';" | 669 "document.getElementById('signup_password_field').value = 'random';" |
| 669 "document.getElementById('confirmation_password_field').value = 'random';" | 670 "document.getElementById('confirmation_password_field').value = 'random';" |
| 670 "send_fetch()"; | 671 "send_fetch()"; |
| 671 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 672 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
| 672 observer.Wait(); | 673 observer.Wait(); |
| 673 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 674 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 674 } | 675 } |
| 675 | 676 |
| 676 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 677 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 677 PromptForFetchSubmitWithoutNavigation) { | 678 PromptForFetchSubmitWithoutNavigation) { |
| 678 NavigateToFile("/password/password_fetch_submit.html"); | 679 NavigateToFile("/password/password_fetch_submit.html"); |
| 679 | 680 |
| 680 // Need to pay attention for a message that XHR has finished since there | 681 // Need to pay attention for a message that XHR has finished since there |
| 681 // is no navigation to wait for. | 682 // is no navigation to wait for. |
| 682 content::DOMMessageQueue message_queue; | 683 content::DOMMessageQueue message_queue; |
| 683 | 684 |
| 684 // Verify that if XHR without navigation occurs and the form has been filled | 685 // Verify that if XHR without navigation occurs and the form has been filled |
| 685 // out we try and save the password. Note that in general the submission | 686 // out we try and save the password. Note that in general the submission |
| 686 // doesn't need to be via form.submit(), but for testing purposes it's | 687 // doesn't need to be via form.submit(), but for testing purposes it's |
| 687 // necessary since we otherwise ignore changes made to the value of these | 688 // necessary since we otherwise ignore changes made to the value of these |
| 688 // fields by script. | 689 // fields by script. |
| 689 scoped_ptr<PromptObserver> prompt_observer( | 690 std::unique_ptr<PromptObserver> prompt_observer( |
| 690 PromptObserver::Create(WebContents())); | 691 PromptObserver::Create(WebContents())); |
| 691 std::string fill_and_submit = | 692 std::string fill_and_submit = |
| 692 "navigate = false;" | 693 "navigate = false;" |
| 693 "document.getElementById('username_field').value = 'temp';" | 694 "document.getElementById('username_field').value = 'temp';" |
| 694 "document.getElementById('password_field').value = 'random';" | 695 "document.getElementById('password_field').value = 'random';" |
| 695 "document.getElementById('submit_button').click();"; | 696 "document.getElementById('submit_button').click();"; |
| 696 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 697 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 697 std::string message; | 698 std::string message; |
| 698 while (message_queue.WaitForMessage(&message)) { | 699 while (message_queue.WaitForMessage(&message)) { |
| 699 if (message == "\"FETCH_FINISHED\"") | 700 if (message == "\"FETCH_FINISHED\"") |
| 700 break; | 701 break; |
| 701 } | 702 } |
| 702 | 703 |
| 703 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 704 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 704 } | 705 } |
| 705 | 706 |
| 706 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 707 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 707 PromptForFetchSubmitWithoutNavigation_SignupForm) { | 708 PromptForFetchSubmitWithoutNavigation_SignupForm) { |
| 708 NavigateToFile("/password/password_fetch_submit.html"); | 709 NavigateToFile("/password/password_fetch_submit.html"); |
| 709 | 710 |
| 710 // Need to pay attention for a message that Fetch has finished since there | 711 // Need to pay attention for a message that Fetch has finished since there |
| 711 // is no navigation to wait for. | 712 // is no navigation to wait for. |
| 712 content::DOMMessageQueue message_queue; | 713 content::DOMMessageQueue message_queue; |
| 713 | 714 |
| 714 // Verify that if Fetch without navigation occurs and the form has been filled | 715 // Verify that if Fetch without navigation occurs and the form has been filled |
| 715 // out we try and save the password. Note that in general the submission | 716 // out we try and save the password. Note that in general the submission |
| 716 // doesn't need to be via form.submit(), but for testing purposes it's | 717 // doesn't need to be via form.submit(), but for testing purposes it's |
| 717 // necessary since we otherwise ignore changes made to the value of these | 718 // necessary since we otherwise ignore changes made to the value of these |
| 718 // fields by script. | 719 // fields by script. |
| 719 scoped_ptr<PromptObserver> prompt_observer( | 720 std::unique_ptr<PromptObserver> prompt_observer( |
| 720 PromptObserver::Create(WebContents())); | 721 PromptObserver::Create(WebContents())); |
| 721 std::string fill_and_submit = | 722 std::string fill_and_submit = |
| 722 "navigate = false;" | 723 "navigate = false;" |
| 723 "document.getElementById('signup_username_field').value = 'temp';" | 724 "document.getElementById('signup_username_field').value = 'temp';" |
| 724 "document.getElementById('signup_password_field').value = 'random';" | 725 "document.getElementById('signup_password_field').value = 'random';" |
| 725 "document.getElementById('confirmation_password_field').value = 'random';" | 726 "document.getElementById('confirmation_password_field').value = 'random';" |
| 726 "document.getElementById('signup_submit_button').click();"; | 727 "document.getElementById('signup_submit_button').click();"; |
| 727 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 728 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 728 std::string message; | 729 std::string message; |
| 729 while (message_queue.WaitForMessage(&message)) { | 730 while (message_queue.WaitForMessage(&message)) { |
| 730 if (message == "\"FETCH_FINISHED\"") | 731 if (message == "\"FETCH_FINISHED\"") |
| 731 break; | 732 break; |
| 732 } | 733 } |
| 733 | 734 |
| 734 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 735 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 735 } | 736 } |
| 736 | 737 |
| 737 IN_PROC_BROWSER_TEST_F( | 738 IN_PROC_BROWSER_TEST_F( |
| 738 PasswordManagerBrowserTestBase, | 739 PasswordManagerBrowserTestBase, |
| 739 NoPromptForFetchSubmitWithoutNavigationWithUnfilledForm) { | 740 NoPromptForFetchSubmitWithoutNavigationWithUnfilledForm) { |
| 740 NavigateToFile("/password/password_fetch_submit.html"); | 741 NavigateToFile("/password/password_fetch_submit.html"); |
| 741 | 742 |
| 742 // Need to pay attention for a message that Fetch has finished since there | 743 // Need to pay attention for a message that Fetch has finished since there |
| 743 // is no navigation to wait for. | 744 // is no navigation to wait for. |
| 744 content::DOMMessageQueue message_queue; | 745 content::DOMMessageQueue message_queue; |
| 745 | 746 |
| 746 // Verify that if Fetch without navigation occurs and the form has NOT been | 747 // Verify that if Fetch without navigation occurs and the form has NOT been |
| 747 // filled out we don't prompt. | 748 // filled out we don't prompt. |
| 748 scoped_ptr<PromptObserver> prompt_observer( | 749 std::unique_ptr<PromptObserver> prompt_observer( |
| 749 PromptObserver::Create(WebContents())); | 750 PromptObserver::Create(WebContents())); |
| 750 std::string fill_and_submit = | 751 std::string fill_and_submit = |
| 751 "navigate = false;" | 752 "navigate = false;" |
| 752 "document.getElementById('username_field').value = 'temp';" | 753 "document.getElementById('username_field').value = 'temp';" |
| 753 "document.getElementById('submit_button').click();"; | 754 "document.getElementById('submit_button').click();"; |
| 754 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 755 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 755 std::string message; | 756 std::string message; |
| 756 while (message_queue.WaitForMessage(&message)) { | 757 while (message_queue.WaitForMessage(&message)) { |
| 757 if (message == "\"FETCH_FINISHED\"") | 758 if (message == "\"FETCH_FINISHED\"") |
| 758 break; | 759 break; |
| 759 } | 760 } |
| 760 | 761 |
| 761 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 762 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 762 } | 763 } |
| 763 | 764 |
| 764 IN_PROC_BROWSER_TEST_F( | 765 IN_PROC_BROWSER_TEST_F( |
| 765 PasswordManagerBrowserTestBase, | 766 PasswordManagerBrowserTestBase, |
| 766 NoPromptForFetchSubmitWithoutNavigationWithUnfilledForm_SignupForm) { | 767 NoPromptForFetchSubmitWithoutNavigationWithUnfilledForm_SignupForm) { |
| 767 NavigateToFile("/password/password_fetch_submit.html"); | 768 NavigateToFile("/password/password_fetch_submit.html"); |
| 768 | 769 |
| 769 // Need to pay attention for a message that Fetch has finished since there | 770 // Need to pay attention for a message that Fetch has finished since there |
| 770 // is no navigation to wait for. | 771 // is no navigation to wait for. |
| 771 content::DOMMessageQueue message_queue; | 772 content::DOMMessageQueue message_queue; |
| 772 | 773 |
| 773 // Verify that if Fetch without navigation occurs and the form has NOT been | 774 // Verify that if Fetch without navigation occurs and the form has NOT been |
| 774 // filled out we don't prompt. | 775 // filled out we don't prompt. |
| 775 scoped_ptr<PromptObserver> prompt_observer( | 776 std::unique_ptr<PromptObserver> prompt_observer( |
| 776 PromptObserver::Create(WebContents())); | 777 PromptObserver::Create(WebContents())); |
| 777 std::string fill_and_submit = | 778 std::string fill_and_submit = |
| 778 "navigate = false;" | 779 "navigate = false;" |
| 779 "document.getElementById('signup_username_field').value = 'temp';" | 780 "document.getElementById('signup_username_field').value = 'temp';" |
| 780 "document.getElementById('signup_submit_button').click();"; | 781 "document.getElementById('signup_submit_button').click();"; |
| 781 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 782 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 782 std::string message; | 783 std::string message; |
| 783 while (message_queue.WaitForMessage(&message)) { | 784 while (message_queue.WaitForMessage(&message)) { |
| 784 if (message == "\"FETCH_FINISHED\"") | 785 if (message == "\"FETCH_FINISHED\"") |
| 785 break; | 786 break; |
| 786 } | 787 } |
| 787 | 788 |
| 788 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 789 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 789 } | 790 } |
| 790 | 791 |
| 791 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptIfLinkClicked) { | 792 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptIfLinkClicked) { |
| 792 NavigateToFile("/password/password_form.html"); | 793 NavigateToFile("/password/password_form.html"); |
| 793 | 794 |
| 794 // Verify that if the user takes a direct action to leave the page, we don't | 795 // Verify that if the user takes a direct action to leave the page, we don't |
| 795 // prompt to save the password even if the form is already filled out. | 796 // prompt to save the password even if the form is already filled out. |
| 796 NavigationObserver observer(WebContents()); | 797 NavigationObserver observer(WebContents()); |
| 797 scoped_ptr<PromptObserver> prompt_observer( | 798 std::unique_ptr<PromptObserver> prompt_observer( |
| 798 PromptObserver::Create(WebContents())); | 799 PromptObserver::Create(WebContents())); |
| 799 std::string fill_and_click_link = | 800 std::string fill_and_click_link = |
| 800 "document.getElementById('username_field').value = 'temp';" | 801 "document.getElementById('username_field').value = 'temp';" |
| 801 "document.getElementById('password_field').value = 'random';" | 802 "document.getElementById('password_field').value = 'random';" |
| 802 "document.getElementById('link').click();"; | 803 "document.getElementById('link').click();"; |
| 803 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_click_link)); | 804 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_click_link)); |
| 804 observer.Wait(); | 805 observer.Wait(); |
| 805 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 806 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 806 } | 807 } |
| 807 | 808 |
| 808 // TODO(jam): http://crbug.com/350550 | 809 // TODO(jam): http://crbug.com/350550 |
| 809 #if !defined(OS_WIN) | 810 #if !defined(OS_WIN) |
| 810 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 811 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 811 VerifyPasswordGenerationUpload) { | 812 VerifyPasswordGenerationUpload) { |
| 812 // Prevent Autofill requests from actually going over the wire. | 813 // Prevent Autofill requests from actually going over the wire. |
| 813 net::TestURLFetcherFactory factory; | 814 net::TestURLFetcherFactory factory; |
| 814 // Disable Autofill requesting access to AddressBook data. This causes | 815 // Disable Autofill requesting access to AddressBook data. This causes |
| 815 // the test to hang on Mac. | 816 // the test to hang on Mac. |
| 816 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs()); | 817 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs()); |
| 817 | 818 |
| 818 // Visit a signup form. | 819 // Visit a signup form. |
| 819 NavigateToFile("/password/signup_form.html"); | 820 NavigateToFile("/password/signup_form.html"); |
| 820 | 821 |
| 821 // Enter a password and save it. | 822 // Enter a password and save it. |
| 822 NavigationObserver first_observer(WebContents()); | 823 NavigationObserver first_observer(WebContents()); |
| 823 scoped_ptr<PromptObserver> prompt_observer( | 824 std::unique_ptr<PromptObserver> prompt_observer( |
| 824 PromptObserver::Create(WebContents())); | 825 PromptObserver::Create(WebContents())); |
| 825 std::string fill_and_submit = | 826 std::string fill_and_submit = |
| 826 "document.getElementById('other_info').value = 'stuff';" | 827 "document.getElementById('other_info').value = 'stuff';" |
| 827 "document.getElementById('username_field').value = 'my_username';" | 828 "document.getElementById('username_field').value = 'my_username';" |
| 828 "document.getElementById('password_field').value = 'password';" | 829 "document.getElementById('password_field').value = 'password';" |
| 829 "document.getElementById('input_submit_button').click()"; | 830 "document.getElementById('input_submit_button').click()"; |
| 830 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 831 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 831 | 832 |
| 832 first_observer.Wait(); | 833 first_observer.Wait(); |
| 833 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 834 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 847 "document.getElementById('username_field').value);"; | 848 "document.getElementById('username_field').value);"; |
| 848 std::string actual_username; | 849 std::string actual_username; |
| 849 ASSERT_TRUE(content::ExecuteScriptAndExtractString(RenderViewHost(), | 850 ASSERT_TRUE(content::ExecuteScriptAndExtractString(RenderViewHost(), |
| 850 get_username, | 851 get_username, |
| 851 &actual_username)); | 852 &actual_username)); |
| 852 ASSERT_EQ("my_username", actual_username); | 853 ASSERT_EQ("my_username", actual_username); |
| 853 | 854 |
| 854 // Submit the form and verify that there is no infobar (as the password | 855 // Submit the form and verify that there is no infobar (as the password |
| 855 // has already been saved). | 856 // has already been saved). |
| 856 NavigationObserver second_observer(WebContents()); | 857 NavigationObserver second_observer(WebContents()); |
| 857 scoped_ptr<PromptObserver> second_prompt_observer( | 858 std::unique_ptr<PromptObserver> second_prompt_observer( |
| 858 PromptObserver::Create(WebContents())); | 859 PromptObserver::Create(WebContents())); |
| 859 std::string submit_form = | 860 std::string submit_form = |
| 860 "document.getElementById('input_submit_button').click()"; | 861 "document.getElementById('input_submit_button').click()"; |
| 861 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit_form)); | 862 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit_form)); |
| 862 second_observer.Wait(); | 863 second_observer.Wait(); |
| 863 EXPECT_FALSE(second_prompt_observer->IsShowingPrompt()); | 864 EXPECT_FALSE(second_prompt_observer->IsShowingPrompt()); |
| 864 | 865 |
| 865 // Verify that we sent two pings to Autofill. One vote for of PASSWORD for | 866 // Verify that we sent two pings to Autofill. One vote for of PASSWORD for |
| 866 // the current form, and one vote for ACCOUNT_CREATION_PASSWORD on the | 867 // the current form, and one vote for ACCOUNT_CREATION_PASSWORD on the |
| 867 // original form since it has more than 2 text input fields and was used for | 868 // original form since it has more than 2 text input fields and was used for |
| 868 // the first time on a different form. | 869 // the first time on a different form. |
| 869 base::HistogramBase* upload_histogram = | 870 base::HistogramBase* upload_histogram = |
| 870 base::StatisticsRecorder::FindHistogram( | 871 base::StatisticsRecorder::FindHistogram( |
| 871 "PasswordGeneration.UploadStarted"); | 872 "PasswordGeneration.UploadStarted"); |
| 872 ASSERT_TRUE(upload_histogram); | 873 ASSERT_TRUE(upload_histogram); |
| 873 scoped_ptr<base::HistogramSamples> snapshot = | 874 std::unique_ptr<base::HistogramSamples> snapshot = |
| 874 upload_histogram->SnapshotSamples(); | 875 upload_histogram->SnapshotSamples(); |
| 875 EXPECT_EQ(0, snapshot->GetCount(0 /* failure */)); | 876 EXPECT_EQ(0, snapshot->GetCount(0 /* failure */)); |
| 876 EXPECT_EQ(2, snapshot->GetCount(1 /* success */)); | 877 EXPECT_EQ(2, snapshot->GetCount(1 /* success */)); |
| 877 } | 878 } |
| 878 #endif | 879 #endif |
| 879 | 880 |
| 880 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 881 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 881 PromptForSubmitFromIframe) { | 882 PromptForSubmitFromIframe) { |
| 882 NavigateToFile("/password/password_submit_from_iframe.html"); | 883 NavigateToFile("/password/password_submit_from_iframe.html"); |
| 883 | 884 |
| 884 // Submit a form in an iframe, then cause the whole page to navigate without a | 885 // Submit a form in an iframe, then cause the whole page to navigate without a |
| 885 // user gesture. We expect the save password prompt to be shown here, because | 886 // user gesture. We expect the save password prompt to be shown here, because |
| 886 // some pages use such iframes for login forms. | 887 // some pages use such iframes for login forms. |
| 887 NavigationObserver observer(WebContents()); | 888 NavigationObserver observer(WebContents()); |
| 888 scoped_ptr<PromptObserver> prompt_observer( | 889 std::unique_ptr<PromptObserver> prompt_observer( |
| 889 PromptObserver::Create(WebContents())); | 890 PromptObserver::Create(WebContents())); |
| 890 std::string fill_and_submit = | 891 std::string fill_and_submit = |
| 891 "var iframe = document.getElementById('test_iframe');" | 892 "var iframe = document.getElementById('test_iframe');" |
| 892 "var iframe_doc = iframe.contentDocument;" | 893 "var iframe_doc = iframe.contentDocument;" |
| 893 "iframe_doc.getElementById('username_field').value = 'temp';" | 894 "iframe_doc.getElementById('username_field').value = 'temp';" |
| 894 "iframe_doc.getElementById('password_field').value = 'random';" | 895 "iframe_doc.getElementById('password_field').value = 'random';" |
| 895 "iframe_doc.getElementById('submit_button').click()"; | 896 "iframe_doc.getElementById('submit_button').click()"; |
| 896 | 897 |
| 897 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 898 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 898 observer.Wait(); | 899 observer.Wait(); |
| 899 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 900 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 900 } | 901 } |
| 901 | 902 |
| 902 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 903 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 903 PromptForInputElementWithoutName) { | 904 PromptForInputElementWithoutName) { |
| 904 // Check that the prompt is shown for forms where input elements lack the | 905 // Check that the prompt is shown for forms where input elements lack the |
| 905 // "name" attribute but the "id" is present. | 906 // "name" attribute but the "id" is present. |
| 906 NavigateToFile("/password/password_form.html"); | 907 NavigateToFile("/password/password_form.html"); |
| 907 | 908 |
| 908 NavigationObserver observer(WebContents()); | 909 NavigationObserver observer(WebContents()); |
| 909 scoped_ptr<PromptObserver> prompt_observer( | 910 std::unique_ptr<PromptObserver> prompt_observer( |
| 910 PromptObserver::Create(WebContents())); | 911 PromptObserver::Create(WebContents())); |
| 911 std::string fill_and_submit = | 912 std::string fill_and_submit = |
| 912 "document.getElementById('username_field_no_name').value = 'temp';" | 913 "document.getElementById('username_field_no_name').value = 'temp';" |
| 913 "document.getElementById('password_field_no_name').value = 'random';" | 914 "document.getElementById('password_field_no_name').value = 'random';" |
| 914 "document.getElementById('input_submit_button_no_name').click()"; | 915 "document.getElementById('input_submit_button_no_name').click()"; |
| 915 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 916 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 916 observer.Wait(); | 917 observer.Wait(); |
| 917 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 918 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 918 } | 919 } |
| 919 | 920 |
| 920 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 921 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 921 PromptForInputElementWithoutId) { | 922 PromptForInputElementWithoutId) { |
| 922 // Check that the prompt is shown for forms where input elements lack the | 923 // Check that the prompt is shown for forms where input elements lack the |
| 923 // "id" attribute but the "name" attribute is present. | 924 // "id" attribute but the "name" attribute is present. |
| 924 NavigateToFile("/password/password_form.html"); | 925 NavigateToFile("/password/password_form.html"); |
| 925 | 926 |
| 926 NavigationObserver observer(WebContents()); | 927 NavigationObserver observer(WebContents()); |
| 927 scoped_ptr<PromptObserver> prompt_observer( | 928 std::unique_ptr<PromptObserver> prompt_observer( |
| 928 PromptObserver::Create(WebContents())); | 929 PromptObserver::Create(WebContents())); |
| 929 std::string fill_and_submit = | 930 std::string fill_and_submit = |
| 930 "document.getElementsByName('username_field_no_id')[0].value = 'temp';" | 931 "document.getElementsByName('username_field_no_id')[0].value = 'temp';" |
| 931 "document.getElementsByName('password_field_no_id')[0].value = 'random';" | 932 "document.getElementsByName('password_field_no_id')[0].value = 'random';" |
| 932 "document.getElementsByName('input_submit_button_no_id')[0].click()"; | 933 "document.getElementsByName('input_submit_button_no_id')[0].click()"; |
| 933 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 934 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 934 observer.Wait(); | 935 observer.Wait(); |
| 935 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 936 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 936 } | 937 } |
| 937 | 938 |
| 938 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 939 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 939 PromptForInputElementWithoutIdAndName) { | 940 PromptForInputElementWithoutIdAndName) { |
| 940 // Check that prompt is shown for forms where the input fields lack both | 941 // Check that prompt is shown for forms where the input fields lack both |
| 941 // the "id" and the "name" attributes. | 942 // the "id" and the "name" attributes. |
| 942 NavigateToFile("/password/password_form.html"); | 943 NavigateToFile("/password/password_form.html"); |
| 943 | 944 |
| 944 NavigationObserver observer(WebContents()); | 945 NavigationObserver observer(WebContents()); |
| 945 scoped_ptr<PromptObserver> prompt_observer( | 946 std::unique_ptr<PromptObserver> prompt_observer( |
| 946 PromptObserver::Create(WebContents())); | 947 PromptObserver::Create(WebContents())); |
| 947 std::string fill_and_submit = | 948 std::string fill_and_submit = |
| 948 "var form = document.getElementById('testform_elements_no_id_no_name');" | 949 "var form = document.getElementById('testform_elements_no_id_no_name');" |
| 949 "var username = form.children[0];" | 950 "var username = form.children[0];" |
| 950 "username.value = 'temp';" | 951 "username.value = 'temp';" |
| 951 "var password = form.children[1];" | 952 "var password = form.children[1];" |
| 952 "password.value = 'random';" | 953 "password.value = 'random';" |
| 953 "form.children[2].click()"; // form.children[2] is the submit button. | 954 "form.children[2].click()"; // form.children[2] is the submit button. |
| 954 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 955 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 955 observer.Wait(); | 956 observer.Wait(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 973 base::ASCIIToUTF16("random")); | 974 base::ASCIIToUTF16("random")); |
| 974 } | 975 } |
| 975 | 976 |
| 976 // Test for checking that no prompt is shown for URLs with file: scheme. | 977 // Test for checking that no prompt is shown for URLs with file: scheme. |
| 977 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 978 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 978 NoPromptForFileSchemeURLs) { | 979 NoPromptForFileSchemeURLs) { |
| 979 GURL url = GetFileURL("password_form.html"); | 980 GURL url = GetFileURL("password_form.html"); |
| 980 ui_test_utils::NavigateToURL(browser(), url); | 981 ui_test_utils::NavigateToURL(browser(), url); |
| 981 | 982 |
| 982 NavigationObserver observer(WebContents()); | 983 NavigationObserver observer(WebContents()); |
| 983 scoped_ptr<PromptObserver> prompt_observer( | 984 std::unique_ptr<PromptObserver> prompt_observer( |
| 984 PromptObserver::Create(WebContents())); | 985 PromptObserver::Create(WebContents())); |
| 985 std::string fill_and_submit = | 986 std::string fill_and_submit = |
| 986 "document.getElementById('username_field').value = 'temp';" | 987 "document.getElementById('username_field').value = 'temp';" |
| 987 "document.getElementById('password_field').value = 'random';" | 988 "document.getElementById('password_field').value = 'random';" |
| 988 "document.getElementById('input_submit_button').click();"; | 989 "document.getElementById('input_submit_button').click();"; |
| 989 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 990 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 990 observer.Wait(); | 991 observer.Wait(); |
| 991 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 992 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 992 } | 993 } |
| 993 | 994 |
| 994 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 995 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 995 NoPromptForLandingPageWithHTTPErrorStatusCode) { | 996 NoPromptForLandingPageWithHTTPErrorStatusCode) { |
| 996 // Check that no prompt is shown for forms where the landing page has | 997 // Check that no prompt is shown for forms where the landing page has |
| 997 // HTTP status 404. | 998 // HTTP status 404. |
| 998 NavigateToFile("/password/password_form.html"); | 999 NavigateToFile("/password/password_form.html"); |
| 999 | 1000 |
| 1000 NavigationObserver observer(WebContents()); | 1001 NavigationObserver observer(WebContents()); |
| 1001 scoped_ptr<PromptObserver> prompt_observer( | 1002 std::unique_ptr<PromptObserver> prompt_observer( |
| 1002 PromptObserver::Create(WebContents())); | 1003 PromptObserver::Create(WebContents())); |
| 1003 std::string fill_and_submit = | 1004 std::string fill_and_submit = |
| 1004 "document.getElementById('username_field_http_error').value = 'temp';" | 1005 "document.getElementById('username_field_http_error').value = 'temp';" |
| 1005 "document.getElementById('password_field_http_error').value = 'random';" | 1006 "document.getElementById('password_field_http_error').value = 'random';" |
| 1006 "document.getElementById('input_submit_button_http_error').click()"; | 1007 "document.getElementById('input_submit_button_http_error').click()"; |
| 1007 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1008 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1008 observer.Wait(); | 1009 observer.Wait(); |
| 1009 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1010 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1010 } | 1011 } |
| 1011 | 1012 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 // Click on a link to open a new tab, then switch back to the first one. | 1050 // Click on a link to open a new tab, then switch back to the first one. |
| 1050 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 1051 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 1051 std::string click = | 1052 std::string click = |
| 1052 "document.getElementById('testlink').click();"; | 1053 "document.getElementById('testlink').click();"; |
| 1053 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), click)); | 1054 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), click)); |
| 1054 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 1055 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 1055 browser()->tab_strip_model()->ActivateTabAt(0, false); | 1056 browser()->tab_strip_model()->ActivateTabAt(0, false); |
| 1056 | 1057 |
| 1057 // Fill in the credentials, and make sure they are saved. | 1058 // Fill in the credentials, and make sure they are saved. |
| 1058 NavigationObserver form_submit_observer(WebContents()); | 1059 NavigationObserver form_submit_observer(WebContents()); |
| 1059 scoped_ptr<PromptObserver> prompt_observer( | 1060 std::unique_ptr<PromptObserver> prompt_observer( |
| 1060 PromptObserver::Create(WebContents())); | 1061 PromptObserver::Create(WebContents())); |
| 1061 std::string fill_and_submit = | 1062 std::string fill_and_submit = |
| 1062 "document.getElementById('username_field').value = 'temp';" | 1063 "document.getElementById('username_field').value = 'temp';" |
| 1063 "document.getElementById('password_field').value = 'random';" | 1064 "document.getElementById('password_field').value = 'random';" |
| 1064 "document.getElementById('input_submit_button').click();"; | 1065 "document.getElementById('input_submit_button').click();"; |
| 1065 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1066 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1066 form_submit_observer.Wait(); | 1067 form_submit_observer.Wait(); |
| 1067 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1068 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1068 prompt_observer->Accept(); | 1069 prompt_observer->Accept(); |
| 1069 | 1070 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1091 // ProcessAckedTouchEvent is what triggers the translation of touch events to | 1092 // ProcessAckedTouchEvent is what triggers the translation of touch events to |
| 1092 // gesture events. | 1093 // gesture events. |
| 1093 // Disabled: http://crbug.com/346297 | 1094 // Disabled: http://crbug.com/346297 |
| 1094 #if defined(USE_AURA) | 1095 #if defined(USE_AURA) |
| 1095 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1096 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1096 DISABLED_PasswordValueAccessibleOnSubmit) { | 1097 DISABLED_PasswordValueAccessibleOnSubmit) { |
| 1097 NavigateToFile("/password/form_and_link.html"); | 1098 NavigateToFile("/password/form_and_link.html"); |
| 1098 | 1099 |
| 1099 // Fill in the credentials, and make sure they are saved. | 1100 // Fill in the credentials, and make sure they are saved. |
| 1100 NavigationObserver form_submit_observer(WebContents()); | 1101 NavigationObserver form_submit_observer(WebContents()); |
| 1101 scoped_ptr<PromptObserver> prompt_observer( | 1102 std::unique_ptr<PromptObserver> prompt_observer( |
| 1102 PromptObserver::Create(WebContents())); | 1103 PromptObserver::Create(WebContents())); |
| 1103 std::string fill_and_submit = | 1104 std::string fill_and_submit = |
| 1104 "document.getElementById('username_field').value = 'temp';" | 1105 "document.getElementById('username_field').value = 'temp';" |
| 1105 "document.getElementById('password_field').value = 'random_secret';" | 1106 "document.getElementById('password_field').value = 'random_secret';" |
| 1106 "document.getElementById('input_submit_button').click();"; | 1107 "document.getElementById('input_submit_button').click();"; |
| 1107 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1108 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1108 form_submit_observer.Wait(); | 1109 form_submit_observer.Wait(); |
| 1109 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1110 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1110 prompt_observer->Accept(); | 1111 prompt_observer->Accept(); |
| 1111 | 1112 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1125 #endif | 1126 #endif |
| 1126 | 1127 |
| 1127 // Test fix for crbug.com/338650. | 1128 // Test fix for crbug.com/338650. |
| 1128 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1129 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1129 DontPromptForPasswordFormWithDefaultValue) { | 1130 DontPromptForPasswordFormWithDefaultValue) { |
| 1130 NavigateToFile("/password/password_form_with_default_value.html"); | 1131 NavigateToFile("/password/password_form_with_default_value.html"); |
| 1131 | 1132 |
| 1132 // Don't prompt if we navigate away even if there is a password value since | 1133 // Don't prompt if we navigate away even if there is a password value since |
| 1133 // it's not coming from the user. | 1134 // it's not coming from the user. |
| 1134 NavigationObserver observer(WebContents()); | 1135 NavigationObserver observer(WebContents()); |
| 1135 scoped_ptr<PromptObserver> prompt_observer( | 1136 std::unique_ptr<PromptObserver> prompt_observer( |
| 1136 PromptObserver::Create(WebContents())); | 1137 PromptObserver::Create(WebContents())); |
| 1137 NavigateToFile("/password/done.html"); | 1138 NavigateToFile("/password/done.html"); |
| 1138 observer.Wait(); | 1139 observer.Wait(); |
| 1139 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1140 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1140 } | 1141 } |
| 1141 | 1142 |
| 1142 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1143 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1143 DontPromptForPasswordFormWithReadonlyPasswordField) { | 1144 DontPromptForPasswordFormWithReadonlyPasswordField) { |
| 1144 NavigateToFile("/password/password_form_with_password_readonly.html"); | 1145 NavigateToFile("/password/password_form_with_password_readonly.html"); |
| 1145 | 1146 |
| 1146 // Fill a form and submit through a <input type="submit"> button. Nothing | 1147 // Fill a form and submit through a <input type="submit"> button. Nothing |
| 1147 // special. | 1148 // special. |
| 1148 NavigationObserver observer(WebContents()); | 1149 NavigationObserver observer(WebContents()); |
| 1149 scoped_ptr<PromptObserver> prompt_observer( | 1150 std::unique_ptr<PromptObserver> prompt_observer( |
| 1150 PromptObserver::Create(WebContents())); | 1151 PromptObserver::Create(WebContents())); |
| 1151 std::string fill_and_submit = | 1152 std::string fill_and_submit = |
| 1152 "document.getElementById('username_field').value = 'temp';" | 1153 "document.getElementById('username_field').value = 'temp';" |
| 1153 "document.getElementById('password_field').value = 'random';" | 1154 "document.getElementById('password_field').value = 'random';" |
| 1154 "document.getElementById('input_submit_button').click()"; | 1155 "document.getElementById('input_submit_button').click()"; |
| 1155 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1156 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1156 observer.Wait(); | 1157 observer.Wait(); |
| 1157 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1158 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1158 } | 1159 } |
| 1159 | 1160 |
| 1160 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1161 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1161 PromptWhenEnableAutomaticPasswordSavingSwitchIsNotSet) { | 1162 PromptWhenEnableAutomaticPasswordSavingSwitchIsNotSet) { |
| 1162 NavigateToFile("/password/password_form.html"); | 1163 NavigateToFile("/password/password_form.html"); |
| 1163 | 1164 |
| 1164 // Fill a form and submit through a <input type="submit"> button. | 1165 // Fill a form and submit through a <input type="submit"> button. |
| 1165 NavigationObserver observer(WebContents()); | 1166 NavigationObserver observer(WebContents()); |
| 1166 scoped_ptr<PromptObserver> prompt_observer( | 1167 std::unique_ptr<PromptObserver> prompt_observer( |
| 1167 PromptObserver::Create(WebContents())); | 1168 PromptObserver::Create(WebContents())); |
| 1168 std::string fill_and_submit = | 1169 std::string fill_and_submit = |
| 1169 "document.getElementById('username_field').value = 'temp';" | 1170 "document.getElementById('username_field').value = 'temp';" |
| 1170 "document.getElementById('password_field').value = 'random';" | 1171 "document.getElementById('password_field').value = 'random';" |
| 1171 "document.getElementById('input_submit_button').click()"; | 1172 "document.getElementById('input_submit_button').click()"; |
| 1172 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1173 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1173 observer.Wait(); | 1174 observer.Wait(); |
| 1174 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1175 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1175 } | 1176 } |
| 1176 | 1177 |
| 1177 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1178 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1178 DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) { | 1179 DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) { |
| 1179 scoped_refptr<password_manager::TestPasswordStore> password_store = | 1180 scoped_refptr<password_manager::TestPasswordStore> password_store = |
| 1180 static_cast<password_manager::TestPasswordStore*>( | 1181 static_cast<password_manager::TestPasswordStore*>( |
| 1181 PasswordStoreFactory::GetForProfile( | 1182 PasswordStoreFactory::GetForProfile( |
| 1182 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); | 1183 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); |
| 1183 | 1184 |
| 1184 EXPECT_TRUE(password_store->IsEmpty()); | 1185 EXPECT_TRUE(password_store->IsEmpty()); |
| 1185 | 1186 |
| 1186 NavigateToFile("/password/password_form.html"); | 1187 NavigateToFile("/password/password_form.html"); |
| 1187 | 1188 |
| 1188 // Add the enable-automatic-password-saving feature. | 1189 // Add the enable-automatic-password-saving feature. |
| 1189 base::FeatureList::ClearInstanceForTesting(); | 1190 base::FeatureList::ClearInstanceForTesting(); |
| 1190 scoped_ptr<base::FeatureList> feature_list(new base::FeatureList); | 1191 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); |
| 1191 feature_list->InitializeFromCommandLine( | 1192 feature_list->InitializeFromCommandLine( |
| 1192 password_manager::features::kEnableAutomaticPasswordSaving.name, ""); | 1193 password_manager::features::kEnableAutomaticPasswordSaving.name, ""); |
| 1193 base::FeatureList::SetInstance(std::move(feature_list)); | 1194 base::FeatureList::SetInstance(std::move(feature_list)); |
| 1194 | 1195 |
| 1195 // Fill a form and submit through a <input type="submit"> button. | 1196 // Fill a form and submit through a <input type="submit"> button. |
| 1196 NavigationObserver observer(WebContents()); | 1197 NavigationObserver observer(WebContents()); |
| 1197 scoped_ptr<PromptObserver> prompt_observer( | 1198 std::unique_ptr<PromptObserver> prompt_observer( |
| 1198 PromptObserver::Create(WebContents())); | 1199 PromptObserver::Create(WebContents())); |
| 1199 // Make sure that the only passwords saved are the auto-saved ones. | 1200 // Make sure that the only passwords saved are the auto-saved ones. |
| 1200 std::string fill_and_submit = | 1201 std::string fill_and_submit = |
| 1201 "document.getElementById('username_field').value = 'temp';" | 1202 "document.getElementById('username_field').value = 'temp';" |
| 1202 "document.getElementById('password_field').value = 'random';" | 1203 "document.getElementById('password_field').value = 'random';" |
| 1203 "document.getElementById('input_submit_button').click()"; | 1204 "document.getElementById('input_submit_button').click()"; |
| 1204 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1205 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1205 observer.Wait(); | 1206 observer.Wait(); |
| 1206 if (chrome::GetChannel() == version_info::Channel::UNKNOWN) { | 1207 if (chrome::GetChannel() == version_info::Channel::UNKNOWN) { |
| 1207 // Passwords getting auto-saved, no prompt. | 1208 // Passwords getting auto-saved, no prompt. |
| 1208 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1209 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1209 EXPECT_FALSE(password_store->IsEmpty()); | 1210 EXPECT_FALSE(password_store->IsEmpty()); |
| 1210 } else { | 1211 } else { |
| 1211 // Prompt shown, and no passwords saved automatically. | 1212 // Prompt shown, and no passwords saved automatically. |
| 1212 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1213 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1213 EXPECT_TRUE(password_store->IsEmpty()); | 1214 EXPECT_TRUE(password_store->IsEmpty()); |
| 1214 } | 1215 } |
| 1215 } | 1216 } |
| 1216 | 1217 |
| 1217 // Test fix for crbug.com/368690. | 1218 // Test fix for crbug.com/368690. |
| 1218 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptWhenReloading) { | 1219 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptWhenReloading) { |
| 1219 NavigateToFile("/password/password_form.html"); | 1220 NavigateToFile("/password/password_form.html"); |
| 1220 | 1221 |
| 1221 std::string fill = | 1222 std::string fill = |
| 1222 "document.getElementById('username_redirect').value = 'temp';" | 1223 "document.getElementById('username_redirect').value = 'temp';" |
| 1223 "document.getElementById('password_redirect').value = 'random';"; | 1224 "document.getElementById('password_redirect').value = 'random';"; |
| 1224 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); | 1225 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); |
| 1225 | 1226 |
| 1226 NavigationObserver observer(WebContents()); | 1227 NavigationObserver observer(WebContents()); |
| 1227 scoped_ptr<PromptObserver> prompt_observer( | 1228 std::unique_ptr<PromptObserver> prompt_observer( |
| 1228 PromptObserver::Create(WebContents())); | 1229 PromptObserver::Create(WebContents())); |
| 1229 GURL url = embedded_test_server()->GetURL("/password/password_form.html"); | 1230 GURL url = embedded_test_server()->GetURL("/password/password_form.html"); |
| 1230 chrome::NavigateParams params(browser(), url, ::ui::PAGE_TRANSITION_RELOAD); | 1231 chrome::NavigateParams params(browser(), url, ::ui::PAGE_TRANSITION_RELOAD); |
| 1231 ui_test_utils::NavigateToURL(¶ms); | 1232 ui_test_utils::NavigateToURL(¶ms); |
| 1232 observer.Wait(); | 1233 observer.Wait(); |
| 1233 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1234 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1234 } | 1235 } |
| 1235 | 1236 |
| 1236 // Test that if a form gets dynamically added between the form parsing and | 1237 // Test that if a form gets dynamically added between the form parsing and |
| 1237 // rendering, and while the main frame still loads, it still is registered, and | 1238 // rendering, and while the main frame still loads, it still is registered, and |
| 1238 // thus saving passwords from it works. | 1239 // thus saving passwords from it works. |
| 1239 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1240 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1240 FormsAddedBetweenParsingAndRendering) { | 1241 FormsAddedBetweenParsingAndRendering) { |
| 1241 NavigateToFile("/password/between_parsing_and_rendering.html"); | 1242 NavigateToFile("/password/between_parsing_and_rendering.html"); |
| 1242 | 1243 |
| 1243 NavigationObserver observer(WebContents()); | 1244 NavigationObserver observer(WebContents()); |
| 1244 scoped_ptr<PromptObserver> prompt_observer( | 1245 std::unique_ptr<PromptObserver> prompt_observer( |
| 1245 PromptObserver::Create(WebContents())); | 1246 PromptObserver::Create(WebContents())); |
| 1246 std::string submit = | 1247 std::string submit = |
| 1247 "document.getElementById('username').value = 'temp';" | 1248 "document.getElementById('username').value = 'temp';" |
| 1248 "document.getElementById('password').value = 'random';" | 1249 "document.getElementById('password').value = 'random';" |
| 1249 "document.getElementById('submit-button').click();"; | 1250 "document.getElementById('submit-button').click();"; |
| 1250 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 1251 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
| 1251 observer.Wait(); | 1252 observer.Wait(); |
| 1252 | 1253 |
| 1253 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1254 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1254 } | 1255 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1279 // authentication. | 1280 // authentication. |
| 1280 ui_test_utils::NavigateToURLWithDisposition( | 1281 ui_test_utils::NavigateToURLWithDisposition( |
| 1281 browser(), | 1282 browser(), |
| 1282 embedded_test_server()->GetURL("/basic_auth"), | 1283 embedded_test_server()->GetURL("/basic_auth"), |
| 1283 NEW_FOREGROUND_TAB, | 1284 NEW_FOREGROUND_TAB, |
| 1284 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 1285 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 1285 | 1286 |
| 1286 content::NavigationController* nav_controller = | 1287 content::NavigationController* nav_controller = |
| 1287 &WebContents()->GetController(); | 1288 &WebContents()->GetController(); |
| 1288 NavigationObserver nav_observer(WebContents()); | 1289 NavigationObserver nav_observer(WebContents()); |
| 1289 scoped_ptr<PromptObserver> prompt_observer( | 1290 std::unique_ptr<PromptObserver> prompt_observer( |
| 1290 PromptObserver::Create(WebContents())); | 1291 PromptObserver::Create(WebContents())); |
| 1291 WindowedAuthNeededObserver auth_needed_observer(nav_controller); | 1292 WindowedAuthNeededObserver auth_needed_observer(nav_controller); |
| 1292 auth_needed_observer.Wait(); | 1293 auth_needed_observer.Wait(); |
| 1293 | 1294 |
| 1294 WindowedAuthSuppliedObserver auth_supplied_observer(nav_controller); | 1295 WindowedAuthSuppliedObserver auth_supplied_observer(nav_controller); |
| 1295 // Offer valid credentials on the auth challenge. | 1296 // Offer valid credentials on the auth challenge. |
| 1296 ASSERT_EQ(1u, login_observer.handlers().size()); | 1297 ASSERT_EQ(1u, login_observer.handlers().size()); |
| 1297 LoginHandler* handler = *login_observer.handlers().begin(); | 1298 LoginHandler* handler = *login_observer.handlers().begin(); |
| 1298 ASSERT_TRUE(handler); | 1299 ASSERT_TRUE(handler); |
| 1299 // Any username/password will work. | 1300 // Any username/password will work. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1325 DISABLED_PreferPasswordFormManagerWhichFinishedMatching | 1326 DISABLED_PreferPasswordFormManagerWhichFinishedMatching |
| 1326 #else | 1327 #else |
| 1327 #define MAYBE_PreferPasswordFormManagerWhichFinishedMatching \ | 1328 #define MAYBE_PreferPasswordFormManagerWhichFinishedMatching \ |
| 1328 PreferPasswordFormManagerWhichFinishedMatching | 1329 PreferPasswordFormManagerWhichFinishedMatching |
| 1329 #endif | 1330 #endif |
| 1330 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1331 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1331 MAYBE_PreferPasswordFormManagerWhichFinishedMatching) { | 1332 MAYBE_PreferPasswordFormManagerWhichFinishedMatching) { |
| 1332 NavigateToFile("/password/create_form_copy_on_submit.html"); | 1333 NavigateToFile("/password/create_form_copy_on_submit.html"); |
| 1333 | 1334 |
| 1334 NavigationObserver observer(WebContents()); | 1335 NavigationObserver observer(WebContents()); |
| 1335 scoped_ptr<PromptObserver> prompt_observer( | 1336 std::unique_ptr<PromptObserver> prompt_observer( |
| 1336 PromptObserver::Create(WebContents())); | 1337 PromptObserver::Create(WebContents())); |
| 1337 std::string submit = | 1338 std::string submit = |
| 1338 "document.getElementById('username').value = 'overwrite_me';" | 1339 "document.getElementById('username').value = 'overwrite_me';" |
| 1339 "document.getElementById('password').value = 'random';" | 1340 "document.getElementById('password').value = 'random';" |
| 1340 "document.getElementById('non-form-button').click();"; | 1341 "document.getElementById('non-form-button').click();"; |
| 1341 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 1342 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
| 1342 observer.Wait(); | 1343 observer.Wait(); |
| 1343 | 1344 |
| 1344 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1345 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1345 } | 1346 } |
| 1346 | 1347 |
| 1347 // Test that if login fails and content server pushes a different login form | 1348 // Test that if login fails and content server pushes a different login form |
| 1348 // with action URL having different schemes. Heuristic shall be able | 1349 // with action URL having different schemes. Heuristic shall be able |
| 1349 // identify such cases and *shall not* prompt to save incorrect password. | 1350 // identify such cases and *shall not* prompt to save incorrect password. |
| 1350 IN_PROC_BROWSER_TEST_F( | 1351 IN_PROC_BROWSER_TEST_F( |
| 1351 PasswordManagerBrowserTestBase, | 1352 PasswordManagerBrowserTestBase, |
| 1352 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpToHttps) { | 1353 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpToHttps) { |
| 1353 std::string path = | 1354 std::string path = |
| 1354 "/password/separate_login_form_with_onload_submit_script.html"; | 1355 "/password/separate_login_form_with_onload_submit_script.html"; |
| 1355 GURL http_url(embedded_test_server()->GetURL(path)); | 1356 GURL http_url(embedded_test_server()->GetURL(path)); |
| 1356 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); | 1357 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); |
| 1357 | 1358 |
| 1358 NavigationObserver observer(WebContents()); | 1359 NavigationObserver observer(WebContents()); |
| 1359 scoped_ptr<PromptObserver> prompt_observer( | 1360 std::unique_ptr<PromptObserver> prompt_observer( |
| 1360 PromptObserver::Create(WebContents())); | 1361 PromptObserver::Create(WebContents())); |
| 1361 ui_test_utils::NavigateToURL(browser(), http_url); | 1362 ui_test_utils::NavigateToURL(browser(), http_url); |
| 1362 | 1363 |
| 1363 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); | 1364 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); |
| 1364 observer.Wait(); | 1365 observer.Wait(); |
| 1365 | 1366 |
| 1366 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1367 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1367 } | 1368 } |
| 1368 | 1369 |
| 1369 IN_PROC_BROWSER_TEST_F( | 1370 IN_PROC_BROWSER_TEST_F( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1382 | 1383 |
| 1383 // This test case cannot inject the scripts via content::ExecuteScript() in | 1384 // This test case cannot inject the scripts via content::ExecuteScript() in |
| 1384 // files served through HTTPS. Therefore the scripts are made part of the HTML | 1385 // files served through HTTPS. Therefore the scripts are made part of the HTML |
| 1385 // site and executed on load. | 1386 // site and executed on load. |
| 1386 std::string path = | 1387 std::string path = |
| 1387 "/password/separate_login_form_with_onload_submit_script.html"; | 1388 "/password/separate_login_form_with_onload_submit_script.html"; |
| 1388 GURL https_url(https_test_server.GetURL(path)); | 1389 GURL https_url(https_test_server.GetURL(path)); |
| 1389 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme)); | 1390 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme)); |
| 1390 | 1391 |
| 1391 NavigationObserver observer(WebContents()); | 1392 NavigationObserver observer(WebContents()); |
| 1392 scoped_ptr<PromptObserver> prompt_observer( | 1393 std::unique_ptr<PromptObserver> prompt_observer( |
| 1393 PromptObserver::Create(WebContents())); | 1394 PromptObserver::Create(WebContents())); |
| 1394 ui_test_utils::NavigateToURL(browser(), https_url); | 1395 ui_test_utils::NavigateToURL(browser(), https_url); |
| 1395 | 1396 |
| 1396 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); | 1397 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); |
| 1397 observer.Wait(); | 1398 observer.Wait(); |
| 1398 | 1399 |
| 1399 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1400 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1400 } | 1401 } |
| 1401 | 1402 |
| 1402 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1403 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1403 PromptWhenPasswordFormWithoutUsernameFieldSubmitted) { | 1404 PromptWhenPasswordFormWithoutUsernameFieldSubmitted) { |
| 1404 scoped_refptr<password_manager::TestPasswordStore> password_store = | 1405 scoped_refptr<password_manager::TestPasswordStore> password_store = |
| 1405 static_cast<password_manager::TestPasswordStore*>( | 1406 static_cast<password_manager::TestPasswordStore*>( |
| 1406 PasswordStoreFactory::GetForProfile( | 1407 PasswordStoreFactory::GetForProfile( |
| 1407 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); | 1408 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); |
| 1408 | 1409 |
| 1409 EXPECT_TRUE(password_store->IsEmpty()); | 1410 EXPECT_TRUE(password_store->IsEmpty()); |
| 1410 | 1411 |
| 1411 NavigateToFile("/password/form_with_only_password_field.html"); | 1412 NavigateToFile("/password/form_with_only_password_field.html"); |
| 1412 | 1413 |
| 1413 NavigationObserver observer(WebContents()); | 1414 NavigationObserver observer(WebContents()); |
| 1414 scoped_ptr<PromptObserver> prompt_observer( | 1415 std::unique_ptr<PromptObserver> prompt_observer( |
| 1415 PromptObserver::Create(WebContents())); | 1416 PromptObserver::Create(WebContents())); |
| 1416 std::string submit = | 1417 std::string submit = |
| 1417 "document.getElementById('password').value = 'password';" | 1418 "document.getElementById('password').value = 'password';" |
| 1418 "document.getElementById('submit-button').click();"; | 1419 "document.getElementById('submit-button').click();"; |
| 1419 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 1420 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
| 1420 observer.Wait(); | 1421 observer.Wait(); |
| 1421 | 1422 |
| 1422 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1423 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1423 prompt_observer->Accept(); | 1424 prompt_observer->Accept(); |
| 1424 | 1425 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1440 | 1441 |
| 1441 // Test that if a form gets autofilled, then it gets autofilled on re-creation | 1442 // Test that if a form gets autofilled, then it gets autofilled on re-creation |
| 1442 // as well. | 1443 // as well. |
| 1443 // TODO(vabr): This is flaky everywhere. http://crbug.com/442704 | 1444 // TODO(vabr): This is flaky everywhere. http://crbug.com/442704 |
| 1444 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1445 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1445 DISABLED_ReCreatedFormsGetFilled) { | 1446 DISABLED_ReCreatedFormsGetFilled) { |
| 1446 NavigateToFile("/password/dynamic_password_form.html"); | 1447 NavigateToFile("/password/dynamic_password_form.html"); |
| 1447 | 1448 |
| 1448 // Fill in the credentials, and make sure they are saved. | 1449 // Fill in the credentials, and make sure they are saved. |
| 1449 NavigationObserver form_submit_observer(WebContents()); | 1450 NavigationObserver form_submit_observer(WebContents()); |
| 1450 scoped_ptr<PromptObserver> prompt_observer( | 1451 std::unique_ptr<PromptObserver> prompt_observer( |
| 1451 PromptObserver::Create(WebContents())); | 1452 PromptObserver::Create(WebContents())); |
| 1452 std::string create_fill_and_submit = | 1453 std::string create_fill_and_submit = |
| 1453 "document.getElementById('create_form_button').click();" | 1454 "document.getElementById('create_form_button').click();" |
| 1454 "window.setTimeout(function() {" | 1455 "window.setTimeout(function() {" |
| 1455 " var form = document.getElementById('dynamic_form_id');" | 1456 " var form = document.getElementById('dynamic_form_id');" |
| 1456 " form.username.value = 'temp';" | 1457 " form.username.value = 'temp';" |
| 1457 " form.password.value = 'random';" | 1458 " form.password.value = 'random';" |
| 1458 " form.submit();" | 1459 " form.submit();" |
| 1459 "}, 0)"; | 1460 "}, 0)"; |
| 1460 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_fill_and_submit)); | 1461 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_fill_and_submit)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1488 | 1489 |
| 1489 // Verify that we show the save password prompt if 'history.pushState()' | 1490 // Verify that we show the save password prompt if 'history.pushState()' |
| 1490 // is called after form submission is suppressed by, for example, calling | 1491 // is called after form submission is suppressed by, for example, calling |
| 1491 // preventDefault() in a form's submit event handler. | 1492 // preventDefault() in a form's submit event handler. |
| 1492 // Note that calling 'submit()' on a form with javascript doesn't call | 1493 // Note that calling 'submit()' on a form with javascript doesn't call |
| 1493 // the onsubmit handler, so we click the submit button instead. | 1494 // the onsubmit handler, so we click the submit button instead. |
| 1494 // Also note that the prompt will only show up if the form disappers | 1495 // Also note that the prompt will only show up if the form disappers |
| 1495 // after submission | 1496 // after submission |
| 1496 NavigationObserver observer(WebContents()); | 1497 NavigationObserver observer(WebContents()); |
| 1497 observer.set_quit_on_entry_committed(true); | 1498 observer.set_quit_on_entry_committed(true); |
| 1498 scoped_ptr<PromptObserver> prompt_observer( | 1499 std::unique_ptr<PromptObserver> prompt_observer( |
| 1499 PromptObserver::Create(WebContents())); | 1500 PromptObserver::Create(WebContents())); |
| 1500 std::string fill_and_submit = | 1501 std::string fill_and_submit = |
| 1501 "document.getElementById('username_field').value = 'temp';" | 1502 "document.getElementById('username_field').value = 'temp';" |
| 1502 "document.getElementById('password_field').value = 'random';" | 1503 "document.getElementById('password_field').value = 'random';" |
| 1503 "document.getElementById('submit_button').click()"; | 1504 "document.getElementById('submit_button').click()"; |
| 1504 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1505 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1505 observer.Wait(); | 1506 observer.Wait(); |
| 1506 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1507 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1507 } | 1508 } |
| 1508 | 1509 |
| 1509 // Similar to the case above, but this time the form persists after | 1510 // Similar to the case above, but this time the form persists after |
| 1510 // 'history.pushState()'. And save password prompt should not show up | 1511 // 'history.pushState()'. And save password prompt should not show up |
| 1511 // in this case. | 1512 // in this case. |
| 1512 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1513 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1513 NoPromptForPushStateWhenFormPersists) { | 1514 NoPromptForPushStateWhenFormPersists) { |
| 1514 NavigateToFile("/password/password_push_state.html"); | 1515 NavigateToFile("/password/password_push_state.html"); |
| 1515 | 1516 |
| 1516 // Set |should_delete_testform| to false to keep submitted form visible after | 1517 // Set |should_delete_testform| to false to keep submitted form visible after |
| 1517 // history.pushsTate(); | 1518 // history.pushsTate(); |
| 1518 NavigationObserver observer(WebContents()); | 1519 NavigationObserver observer(WebContents()); |
| 1519 observer.set_quit_on_entry_committed(true); | 1520 observer.set_quit_on_entry_committed(true); |
| 1520 scoped_ptr<PromptObserver> prompt_observer( | 1521 std::unique_ptr<PromptObserver> prompt_observer( |
| 1521 PromptObserver::Create(WebContents())); | 1522 PromptObserver::Create(WebContents())); |
| 1522 std::string fill_and_submit = | 1523 std::string fill_and_submit = |
| 1523 "should_delete_testform = false;" | 1524 "should_delete_testform = false;" |
| 1524 "document.getElementById('username_field').value = 'temp';" | 1525 "document.getElementById('username_field').value = 'temp';" |
| 1525 "document.getElementById('password_field').value = 'random';" | 1526 "document.getElementById('password_field').value = 'random';" |
| 1526 "document.getElementById('submit_button').click()"; | 1527 "document.getElementById('submit_button').click()"; |
| 1527 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1528 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1528 observer.Wait(); | 1529 observer.Wait(); |
| 1529 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1530 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1530 } | 1531 } |
| 1531 | 1532 |
| 1532 // The password manager should distinguish forms with empty actions. After | 1533 // The password manager should distinguish forms with empty actions. After |
| 1533 // successful login, the login form disappears, but the another one shouldn't be | 1534 // successful login, the login form disappears, but the another one shouldn't be |
| 1534 // recognized as the login form. The save prompt should appear. | 1535 // recognized as the login form. The save prompt should appear. |
| 1535 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1536 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1536 PromptForPushStateWhenFormWithEmptyActionDisappears) { | 1537 PromptForPushStateWhenFormWithEmptyActionDisappears) { |
| 1537 NavigateToFile("/password/password_push_state.html"); | 1538 NavigateToFile("/password/password_push_state.html"); |
| 1538 | 1539 |
| 1539 NavigationObserver observer(WebContents()); | 1540 NavigationObserver observer(WebContents()); |
| 1540 observer.set_quit_on_entry_committed(true); | 1541 observer.set_quit_on_entry_committed(true); |
| 1541 scoped_ptr<PromptObserver> prompt_observer( | 1542 std::unique_ptr<PromptObserver> prompt_observer( |
| 1542 PromptObserver::Create(WebContents())); | 1543 PromptObserver::Create(WebContents())); |
| 1543 std::string fill_and_submit = | 1544 std::string fill_and_submit = |
| 1544 "document.getElementById('ea_username_field').value = 'temp';" | 1545 "document.getElementById('ea_username_field').value = 'temp';" |
| 1545 "document.getElementById('ea_password_field').value = 'random';" | 1546 "document.getElementById('ea_password_field').value = 'random';" |
| 1546 "document.getElementById('ea_submit_button').click()"; | 1547 "document.getElementById('ea_submit_button').click()"; |
| 1547 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1548 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1548 observer.Wait(); | 1549 observer.Wait(); |
| 1549 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1550 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1550 } | 1551 } |
| 1551 | 1552 |
| 1552 // Similar to the case above, but this time the form persists after | 1553 // Similar to the case above, but this time the form persists after |
| 1553 // 'history.pushState()'. The password manager should find the login form even | 1554 // 'history.pushState()'. The password manager should find the login form even |
| 1554 // if the action of the form is empty. Save password prompt should not show up. | 1555 // if the action of the form is empty. Save password prompt should not show up. |
| 1555 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1556 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1556 PromptForPushStateWhenFormWithEmptyActionPersists) { | 1557 PromptForPushStateWhenFormWithEmptyActionPersists) { |
| 1557 NavigateToFile("/password/password_push_state.html"); | 1558 NavigateToFile("/password/password_push_state.html"); |
| 1558 | 1559 |
| 1559 NavigationObserver observer(WebContents()); | 1560 NavigationObserver observer(WebContents()); |
| 1560 observer.set_quit_on_entry_committed(true); | 1561 observer.set_quit_on_entry_committed(true); |
| 1561 scoped_ptr<PromptObserver> prompt_observer( | 1562 std::unique_ptr<PromptObserver> prompt_observer( |
| 1562 PromptObserver::Create(WebContents())); | 1563 PromptObserver::Create(WebContents())); |
| 1563 std::string fill_and_submit = | 1564 std::string fill_and_submit = |
| 1564 "should_delete_testform = false;" | 1565 "should_delete_testform = false;" |
| 1565 "document.getElementById('ea_username_field').value = 'temp';" | 1566 "document.getElementById('ea_username_field').value = 'temp';" |
| 1566 "document.getElementById('ea_password_field').value = 'random';" | 1567 "document.getElementById('ea_password_field').value = 'random';" |
| 1567 "document.getElementById('ea_submit_button').click()"; | 1568 "document.getElementById('ea_submit_button').click()"; |
| 1568 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1569 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1569 observer.Wait(); | 1570 observer.Wait(); |
| 1570 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1571 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1571 } | 1572 } |
| 1572 | 1573 |
| 1573 // Current and target URLs contain different parameters and references. This | 1574 // Current and target URLs contain different parameters and references. This |
| 1574 // test checks that parameters and references in origins are ignored for | 1575 // test checks that parameters and references in origins are ignored for |
| 1575 // form origin comparison. | 1576 // form origin comparison. |
| 1576 IN_PROC_BROWSER_TEST_F( | 1577 IN_PROC_BROWSER_TEST_F( |
| 1577 PasswordManagerBrowserTestBase, | 1578 PasswordManagerBrowserTestBase, |
| 1578 PromptForPushStateWhenFormDisappears_ParametersInOrigins) { | 1579 PromptForPushStateWhenFormDisappears_ParametersInOrigins) { |
| 1579 NavigateToFile("/password/password_push_state.html?login#r"); | 1580 NavigateToFile("/password/password_push_state.html?login#r"); |
| 1580 | 1581 |
| 1581 NavigationObserver observer(WebContents()); | 1582 NavigationObserver observer(WebContents()); |
| 1582 observer.set_quit_on_entry_committed(true); | 1583 observer.set_quit_on_entry_committed(true); |
| 1583 scoped_ptr<PromptObserver> prompt_observer( | 1584 std::unique_ptr<PromptObserver> prompt_observer( |
| 1584 PromptObserver::Create(WebContents())); | 1585 PromptObserver::Create(WebContents())); |
| 1585 std::string fill_and_submit = | 1586 std::string fill_and_submit = |
| 1586 "add_parameters_to_target_url = true;" | 1587 "add_parameters_to_target_url = true;" |
| 1587 "document.getElementById('pa_username_field').value = 'temp';" | 1588 "document.getElementById('pa_username_field').value = 'temp';" |
| 1588 "document.getElementById('pa_password_field').value = 'random';" | 1589 "document.getElementById('pa_password_field').value = 'random';" |
| 1589 "document.getElementById('pa_submit_button').click()"; | 1590 "document.getElementById('pa_submit_button').click()"; |
| 1590 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1591 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1591 observer.Wait(); | 1592 observer.Wait(); |
| 1592 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1593 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1593 } | 1594 } |
| 1594 | 1595 |
| 1595 // Similar to the case above, but this time the form persists after | 1596 // Similar to the case above, but this time the form persists after |
| 1596 // 'history.pushState()'. The password manager should find the login form even | 1597 // 'history.pushState()'. The password manager should find the login form even |
| 1597 // if target and current URLs contain different parameters or references. | 1598 // if target and current URLs contain different parameters or references. |
| 1598 // Save password prompt should not show up. | 1599 // Save password prompt should not show up. |
| 1599 IN_PROC_BROWSER_TEST_F( | 1600 IN_PROC_BROWSER_TEST_F( |
| 1600 PasswordManagerBrowserTestBase, | 1601 PasswordManagerBrowserTestBase, |
| 1601 PromptForPushStateWhenFormPersists_ParametersInOrigins) { | 1602 PromptForPushStateWhenFormPersists_ParametersInOrigins) { |
| 1602 NavigateToFile("/password/password_push_state.html?login#r"); | 1603 NavigateToFile("/password/password_push_state.html?login#r"); |
| 1603 | 1604 |
| 1604 NavigationObserver observer(WebContents()); | 1605 NavigationObserver observer(WebContents()); |
| 1605 observer.set_quit_on_entry_committed(true); | 1606 observer.set_quit_on_entry_committed(true); |
| 1606 scoped_ptr<PromptObserver> prompt_observer( | 1607 std::unique_ptr<PromptObserver> prompt_observer( |
| 1607 PromptObserver::Create(WebContents())); | 1608 PromptObserver::Create(WebContents())); |
| 1608 std::string fill_and_submit = | 1609 std::string fill_and_submit = |
| 1609 "should_delete_testform = false;" | 1610 "should_delete_testform = false;" |
| 1610 "add_parameters_to_target_url = true;" | 1611 "add_parameters_to_target_url = true;" |
| 1611 "document.getElementById('pa_username_field').value = 'temp';" | 1612 "document.getElementById('pa_username_field').value = 'temp';" |
| 1612 "document.getElementById('pa_password_field').value = 'random';" | 1613 "document.getElementById('pa_password_field').value = 'random';" |
| 1613 "document.getElementById('pa_submit_button').click()"; | 1614 "document.getElementById('pa_submit_button').click()"; |
| 1614 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1615 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1615 observer.Wait(); | 1616 observer.Wait(); |
| 1616 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1617 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1617 } | 1618 } |
| 1618 | 1619 |
| 1619 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1620 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1620 InFrameNavigationDoesNotClearPopupState) { | 1621 InFrameNavigationDoesNotClearPopupState) { |
| 1621 // Mock out the AutofillClient so we know how long to wait. Unfortunately | 1622 // Mock out the AutofillClient so we know how long to wait. Unfortunately |
| 1622 // there isn't otherwise a good even to wait on to verify that the popup | 1623 // there isn't otherwise a good even to wait on to verify that the popup |
| 1623 // would have been shown. | 1624 // would have been shown. |
| 1624 password_manager::ContentPasswordManagerDriverFactory* driver_factory = | 1625 password_manager::ContentPasswordManagerDriverFactory* driver_factory = |
| 1625 password_manager::ContentPasswordManagerDriverFactory::FromWebContents( | 1626 password_manager::ContentPasswordManagerDriverFactory::FromWebContents( |
| 1626 WebContents()); | 1627 WebContents()); |
| 1627 ObservingAutofillClient observing_autofill_client; | 1628 ObservingAutofillClient observing_autofill_client; |
| 1628 driver_factory->TestingSetDriverForFrame( | 1629 driver_factory->TestingSetDriverForFrame( |
| 1629 RenderViewHost()->GetMainFrame(), | 1630 RenderViewHost()->GetMainFrame(), |
| 1630 make_scoped_ptr(new password_manager::ContentPasswordManagerDriver( | 1631 base::WrapUnique(new password_manager::ContentPasswordManagerDriver( |
| 1631 RenderViewHost()->GetMainFrame(), | 1632 RenderViewHost()->GetMainFrame(), |
| 1632 ChromePasswordManagerClient::FromWebContents(WebContents()), | 1633 ChromePasswordManagerClient::FromWebContents(WebContents()), |
| 1633 &observing_autofill_client))); | 1634 &observing_autofill_client))); |
| 1634 | 1635 |
| 1635 NavigateToFile("/password/password_form.html"); | 1636 NavigateToFile("/password/password_form.html"); |
| 1636 | 1637 |
| 1637 NavigationObserver form_submit_observer(WebContents()); | 1638 NavigationObserver form_submit_observer(WebContents()); |
| 1638 scoped_ptr<PromptObserver> prompt_observer( | 1639 std::unique_ptr<PromptObserver> prompt_observer( |
| 1639 PromptObserver::Create(WebContents())); | 1640 PromptObserver::Create(WebContents())); |
| 1640 std::string fill = | 1641 std::string fill = |
| 1641 "document.getElementById('username_field').value = 'temp';" | 1642 "document.getElementById('username_field').value = 'temp';" |
| 1642 "document.getElementById('password_field').value = 'random123';" | 1643 "document.getElementById('password_field').value = 'random123';" |
| 1643 "document.getElementById('input_submit_button').click();"; | 1644 "document.getElementById('input_submit_button').click();"; |
| 1644 | 1645 |
| 1645 // Save credentials for the site. | 1646 // Save credentials for the site. |
| 1646 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); | 1647 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); |
| 1647 form_submit_observer.Wait(); | 1648 form_submit_observer.Wait(); |
| 1648 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1649 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1675 top + 1)); | 1676 top + 1)); |
| 1676 // Make sure the popup would be shown. | 1677 // Make sure the popup would be shown. |
| 1677 observing_autofill_client.Wait(); | 1678 observing_autofill_client.Wait(); |
| 1678 } | 1679 } |
| 1679 | 1680 |
| 1680 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1681 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1681 ChangePwdFormBubbleShown) { | 1682 ChangePwdFormBubbleShown) { |
| 1682 NavigateToFile("/password/password_form.html"); | 1683 NavigateToFile("/password/password_form.html"); |
| 1683 | 1684 |
| 1684 NavigationObserver observer(WebContents()); | 1685 NavigationObserver observer(WebContents()); |
| 1685 scoped_ptr<PromptObserver> prompt_observer( | 1686 std::unique_ptr<PromptObserver> prompt_observer( |
| 1686 PromptObserver::Create(WebContents())); | 1687 PromptObserver::Create(WebContents())); |
| 1687 std::string fill_and_submit = | 1688 std::string fill_and_submit = |
| 1688 "document.getElementById('chg_username_field').value = 'temp';" | 1689 "document.getElementById('chg_username_field').value = 'temp';" |
| 1689 "document.getElementById('chg_password_field').value = 'random';" | 1690 "document.getElementById('chg_password_field').value = 'random';" |
| 1690 "document.getElementById('chg_new_password_1').value = 'random1';" | 1691 "document.getElementById('chg_new_password_1').value = 'random1';" |
| 1691 "document.getElementById('chg_new_password_2').value = 'random1';" | 1692 "document.getElementById('chg_new_password_2').value = 'random1';" |
| 1692 "document.getElementById('chg_submit_button').click()"; | 1693 "document.getElementById('chg_submit_button').click()"; |
| 1693 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1694 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1694 observer.Wait(); | 1695 observer.Wait(); |
| 1695 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1696 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1696 } | 1697 } |
| 1697 | 1698 |
| 1698 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1699 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1699 ChangePwdFormPushStateBubbleShown) { | 1700 ChangePwdFormPushStateBubbleShown) { |
| 1700 NavigateToFile("/password/password_push_state.html"); | 1701 NavigateToFile("/password/password_push_state.html"); |
| 1701 | 1702 |
| 1702 NavigationObserver observer(WebContents()); | 1703 NavigationObserver observer(WebContents()); |
| 1703 observer.set_quit_on_entry_committed(true); | 1704 observer.set_quit_on_entry_committed(true); |
| 1704 scoped_ptr<PromptObserver> prompt_observer( | 1705 std::unique_ptr<PromptObserver> prompt_observer( |
| 1705 PromptObserver::Create(WebContents())); | 1706 PromptObserver::Create(WebContents())); |
| 1706 std::string fill_and_submit = | 1707 std::string fill_and_submit = |
| 1707 "document.getElementById('chg_username_field').value = 'temp';" | 1708 "document.getElementById('chg_username_field').value = 'temp';" |
| 1708 "document.getElementById('chg_password_field').value = 'random';" | 1709 "document.getElementById('chg_password_field').value = 'random';" |
| 1709 "document.getElementById('chg_new_password_1').value = 'random1';" | 1710 "document.getElementById('chg_new_password_1').value = 'random1';" |
| 1710 "document.getElementById('chg_new_password_2').value = 'random1';" | 1711 "document.getElementById('chg_new_password_2').value = 'random1';" |
| 1711 "document.getElementById('chg_submit_button').click()"; | 1712 "document.getElementById('chg_submit_button').click()"; |
| 1712 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1713 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1713 observer.Wait(); | 1714 observer.Wait(); |
| 1714 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1715 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1715 } | 1716 } |
| 1716 | 1717 |
| 1717 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptOnBack) { | 1718 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptOnBack) { |
| 1718 // Go to a successful landing page through submitting first, so that it is | 1719 // Go to a successful landing page through submitting first, so that it is |
| 1719 // reachable through going back, and the remembered page transition is form | 1720 // reachable through going back, and the remembered page transition is form |
| 1720 // submit. There is no need to submit non-empty strings. | 1721 // submit. There is no need to submit non-empty strings. |
| 1721 NavigateToFile("/password/password_form.html"); | 1722 NavigateToFile("/password/password_form.html"); |
| 1722 | 1723 |
| 1723 NavigationObserver dummy_submit_observer(WebContents()); | 1724 NavigationObserver dummy_submit_observer(WebContents()); |
| 1724 std::string just_submit = | 1725 std::string just_submit = |
| 1725 "document.getElementById('input_submit_button').click()"; | 1726 "document.getElementById('input_submit_button').click()"; |
| 1726 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), just_submit)); | 1727 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), just_submit)); |
| 1727 dummy_submit_observer.Wait(); | 1728 dummy_submit_observer.Wait(); |
| 1728 | 1729 |
| 1729 // Now go to a page with a form again, fill the form, and go back instead of | 1730 // Now go to a page with a form again, fill the form, and go back instead of |
| 1730 // submitting it. | 1731 // submitting it. |
| 1731 NavigateToFile("/password/dummy_submit.html"); | 1732 NavigateToFile("/password/dummy_submit.html"); |
| 1732 | 1733 |
| 1733 NavigationObserver observer(WebContents()); | 1734 NavigationObserver observer(WebContents()); |
| 1734 scoped_ptr<PromptObserver> prompt_observer( | 1735 std::unique_ptr<PromptObserver> prompt_observer( |
| 1735 PromptObserver::Create(WebContents())); | 1736 PromptObserver::Create(WebContents())); |
| 1736 // The (dummy) submit is necessary to provisionally save the typed password. A | 1737 // The (dummy) submit is necessary to provisionally save the typed password. A |
| 1737 // user typing in the password field would not need to submit to provisionally | 1738 // user typing in the password field would not need to submit to provisionally |
| 1738 // save it, but the script cannot trigger that just by assigning to the | 1739 // save it, but the script cannot trigger that just by assigning to the |
| 1739 // field's value. | 1740 // field's value. |
| 1740 std::string fill_and_back = | 1741 std::string fill_and_back = |
| 1741 "document.getElementById('password_field').value = 'random';" | 1742 "document.getElementById('password_field').value = 'random';" |
| 1742 "document.getElementById('input_submit_button').click();" | 1743 "document.getElementById('input_submit_button').click();" |
| 1743 "window.history.back();"; | 1744 "window.history.back();"; |
| 1744 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_back)); | 1745 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_back)); |
| 1745 observer.Wait(); | 1746 observer.Wait(); |
| 1746 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 1747 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 1747 } | 1748 } |
| 1748 | 1749 |
| 1749 // Regression test for http://crbug.com/452306 | 1750 // Regression test for http://crbug.com/452306 |
| 1750 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1751 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1751 ChangingTextToPasswordFieldOnSignupForm) { | 1752 ChangingTextToPasswordFieldOnSignupForm) { |
| 1752 NavigateToFile("/password/signup_form.html"); | 1753 NavigateToFile("/password/signup_form.html"); |
| 1753 | 1754 |
| 1754 // In this case, pretend that username_field is actually a password field | 1755 // In this case, pretend that username_field is actually a password field |
| 1755 // that starts as a text field to simulate placeholder. | 1756 // that starts as a text field to simulate placeholder. |
| 1756 NavigationObserver observer(WebContents()); | 1757 NavigationObserver observer(WebContents()); |
| 1757 scoped_ptr<PromptObserver> prompt_observer( | 1758 std::unique_ptr<PromptObserver> prompt_observer( |
| 1758 PromptObserver::Create(WebContents())); | 1759 PromptObserver::Create(WebContents())); |
| 1759 std::string change_and_submit = | 1760 std::string change_and_submit = |
| 1760 "document.getElementById('other_info').value = 'username';" | 1761 "document.getElementById('other_info').value = 'username';" |
| 1761 "document.getElementById('username_field').type = 'password';" | 1762 "document.getElementById('username_field').type = 'password';" |
| 1762 "document.getElementById('username_field').value = 'mypass';" | 1763 "document.getElementById('username_field').value = 'mypass';" |
| 1763 "document.getElementById('password_field').value = 'mypass';" | 1764 "document.getElementById('password_field').value = 'mypass';" |
| 1764 "document.getElementById('testform').submit();"; | 1765 "document.getElementById('testform').submit();"; |
| 1765 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), change_and_submit)); | 1766 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), change_and_submit)); |
| 1766 observer.Wait(); | 1767 observer.Wait(); |
| 1767 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1768 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1768 } | 1769 } |
| 1769 | 1770 |
| 1770 // Regression test for http://crbug.com/451631 | 1771 // Regression test for http://crbug.com/451631 |
| 1771 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1772 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1772 SavingOnManyPasswordFieldsTest) { | 1773 SavingOnManyPasswordFieldsTest) { |
| 1773 // Simulate Macy's registration page, which contains the normal 2 password | 1774 // Simulate Macy's registration page, which contains the normal 2 password |
| 1774 // fields for confirming the new password plus 2 more fields for security | 1775 // fields for confirming the new password plus 2 more fields for security |
| 1775 // questions and credit card. Make sure that saving works correctly for such | 1776 // questions and credit card. Make sure that saving works correctly for such |
| 1776 // sites. | 1777 // sites. |
| 1777 NavigateToFile("/password/many_password_signup_form.html"); | 1778 NavigateToFile("/password/many_password_signup_form.html"); |
| 1778 | 1779 |
| 1779 NavigationObserver observer(WebContents()); | 1780 NavigationObserver observer(WebContents()); |
| 1780 scoped_ptr<PromptObserver> prompt_observer( | 1781 std::unique_ptr<PromptObserver> prompt_observer( |
| 1781 PromptObserver::Create(WebContents())); | 1782 PromptObserver::Create(WebContents())); |
| 1782 std::string fill_and_submit = | 1783 std::string fill_and_submit = |
| 1783 "document.getElementById('username_field').value = 'username';" | 1784 "document.getElementById('username_field').value = 'username';" |
| 1784 "document.getElementById('password_field').value = 'mypass';" | 1785 "document.getElementById('password_field').value = 'mypass';" |
| 1785 "document.getElementById('confirm_field').value = 'mypass';" | 1786 "document.getElementById('confirm_field').value = 'mypass';" |
| 1786 "document.getElementById('security_answer').value = 'hometown';" | 1787 "document.getElementById('security_answer').value = 'hometown';" |
| 1787 "document.getElementById('SSN').value = '1234';" | 1788 "document.getElementById('SSN').value = '1234';" |
| 1788 "document.getElementById('testform').submit();"; | 1789 "document.getElementById('testform').submit();"; |
| 1789 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1790 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1790 observer.Wait(); | 1791 observer.Wait(); |
| 1791 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1792 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1792 } | 1793 } |
| 1793 | 1794 |
| 1794 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1795 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1795 SaveWhenIFrameDestroyedOnFormSubmit) { | 1796 SaveWhenIFrameDestroyedOnFormSubmit) { |
| 1796 NavigateToFile("/password/frame_detached_on_submit.html"); | 1797 NavigateToFile("/password/frame_detached_on_submit.html"); |
| 1797 | 1798 |
| 1798 // Need to pay attention for a message that XHR has finished since there | 1799 // Need to pay attention for a message that XHR has finished since there |
| 1799 // is no navigation to wait for. | 1800 // is no navigation to wait for. |
| 1800 content::DOMMessageQueue message_queue; | 1801 content::DOMMessageQueue message_queue; |
| 1801 | 1802 |
| 1802 scoped_ptr<PromptObserver> prompt_observer( | 1803 std::unique_ptr<PromptObserver> prompt_observer( |
| 1803 PromptObserver::Create(WebContents())); | 1804 PromptObserver::Create(WebContents())); |
| 1804 std::string fill_and_submit = | 1805 std::string fill_and_submit = |
| 1805 "var iframe = document.getElementById('login_iframe');" | 1806 "var iframe = document.getElementById('login_iframe');" |
| 1806 "var frame_doc = iframe.contentDocument;" | 1807 "var frame_doc = iframe.contentDocument;" |
| 1807 "frame_doc.getElementById('username_field').value = 'temp';" | 1808 "frame_doc.getElementById('username_field').value = 'temp';" |
| 1808 "frame_doc.getElementById('password_field').value = 'random';" | 1809 "frame_doc.getElementById('password_field').value = 'random';" |
| 1809 "frame_doc.getElementById('submit_button').click();"; | 1810 "frame_doc.getElementById('submit_button').click();"; |
| 1810 | 1811 |
| 1811 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1812 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 1812 std::string message; | 1813 std::string message; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 std::string create_iframe = base::StringPrintf( | 1859 std::string create_iframe = base::StringPrintf( |
| 1859 "create_iframe(" | 1860 "create_iframe(" |
| 1860 "'http://randomsite.net:%d/password/crossite_iframe_content.html');", | 1861 "'http://randomsite.net:%d/password/crossite_iframe_content.html');", |
| 1861 embedded_test_server()->port()); | 1862 embedded_test_server()->port()); |
| 1862 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_iframe)); | 1863 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), create_iframe)); |
| 1863 ifrm_observer.Wait(); | 1864 ifrm_observer.Wait(); |
| 1864 | 1865 |
| 1865 // Store a password for autofill later | 1866 // Store a password for autofill later |
| 1866 NavigationObserver init_observer(WebContents()); | 1867 NavigationObserver init_observer(WebContents()); |
| 1867 init_observer.SetPathToWaitFor("/password/done.html"); | 1868 init_observer.SetPathToWaitFor("/password/done.html"); |
| 1868 scoped_ptr<PromptObserver> prompt_observer( | 1869 std::unique_ptr<PromptObserver> prompt_observer( |
| 1869 PromptObserver::Create(WebContents())); | 1870 PromptObserver::Create(WebContents())); |
| 1870 std::string init_form = "sendMessage('fill_and_submit');"; | 1871 std::string init_form = "sendMessage('fill_and_submit');"; |
| 1871 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), init_form)); | 1872 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), init_form)); |
| 1872 init_observer.Wait(); | 1873 init_observer.Wait(); |
| 1873 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1874 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 1874 prompt_observer->Accept(); | 1875 prompt_observer->Accept(); |
| 1875 | 1876 |
| 1876 // Visit the form again | 1877 // Visit the form again |
| 1877 NavigationObserver reload_observer(WebContents()); | 1878 NavigationObserver reload_observer(WebContents()); |
| 1878 NavigateToFile("/password/password_form_in_crosssite_iframe.html"); | 1879 NavigateToFile("/password/password_form_in_crosssite_iframe.html"); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 } | 1936 } |
| 1936 | 1937 |
| 1937 // Check that a password form in an iframe of same origin will not be | 1938 // Check that a password form in an iframe of same origin will not be |
| 1938 // filled in until user interact with the iframe. | 1939 // filled in until user interact with the iframe. |
| 1939 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1940 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 1940 SameOriginIframeAutoFillTest) { | 1941 SameOriginIframeAutoFillTest) { |
| 1941 // Visit the sign-up form to store a password for autofill later | 1942 // Visit the sign-up form to store a password for autofill later |
| 1942 NavigateToFile("/password/password_form_in_same_origin_iframe.html"); | 1943 NavigateToFile("/password/password_form_in_same_origin_iframe.html"); |
| 1943 NavigationObserver observer(WebContents()); | 1944 NavigationObserver observer(WebContents()); |
| 1944 observer.SetPathToWaitFor("/password/done.html"); | 1945 observer.SetPathToWaitFor("/password/done.html"); |
| 1945 scoped_ptr<PromptObserver> prompt_observer( | 1946 std::unique_ptr<PromptObserver> prompt_observer( |
| 1946 PromptObserver::Create(WebContents())); | 1947 PromptObserver::Create(WebContents())); |
| 1947 | 1948 |
| 1948 std::string submit = | 1949 std::string submit = |
| 1949 "var ifrmDoc = document.getElementById('iframe').contentDocument;" | 1950 "var ifrmDoc = document.getElementById('iframe').contentDocument;" |
| 1950 "ifrmDoc.getElementById('username_field').value = 'temp';" | 1951 "ifrmDoc.getElementById('username_field').value = 'temp';" |
| 1951 "ifrmDoc.getElementById('password_field').value = 'pa55w0rd';" | 1952 "ifrmDoc.getElementById('password_field').value = 'pa55w0rd';" |
| 1952 "ifrmDoc.getElementById('input_submit_button').click();"; | 1953 "ifrmDoc.getElementById('input_submit_button').click();"; |
| 1953 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 1954 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
| 1954 observer.Wait(); | 1955 observer.Wait(); |
| 1955 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 1956 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2059 iframe_killed.Wait(); | 2060 iframe_killed.Wait(); |
| 2060 } | 2061 } |
| 2061 | 2062 |
| 2062 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2063 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 2063 ChangePwdNoAccountStored) { | 2064 ChangePwdNoAccountStored) { |
| 2064 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); | 2065 ASSERT_TRUE(ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()); |
| 2065 NavigateToFile("/password/password_form.html"); | 2066 NavigateToFile("/password/password_form.html"); |
| 2066 | 2067 |
| 2067 // Fill a form and submit through a <input type="submit"> button. | 2068 // Fill a form and submit through a <input type="submit"> button. |
| 2068 NavigationObserver observer(WebContents()); | 2069 NavigationObserver observer(WebContents()); |
| 2069 scoped_ptr<PromptObserver> prompt_observer( | 2070 std::unique_ptr<PromptObserver> prompt_observer( |
| 2070 PromptObserver::Create(WebContents())); | 2071 PromptObserver::Create(WebContents())); |
| 2071 | 2072 |
| 2072 std::string fill_and_submit = | 2073 std::string fill_and_submit = |
| 2073 "document.getElementById('chg_password_wo_username_field').value = " | 2074 "document.getElementById('chg_password_wo_username_field').value = " |
| 2074 "'old_pw';" | 2075 "'old_pw';" |
| 2075 "document.getElementById('chg_new_password_wo_username_1').value = " | 2076 "document.getElementById('chg_new_password_wo_username_1').value = " |
| 2076 "'new_pw';" | 2077 "'new_pw';" |
| 2077 "document.getElementById('chg_new_password_wo_username_2').value = " | 2078 "document.getElementById('chg_new_password_wo_username_2').value = " |
| 2078 "'new_pw';" | 2079 "'new_pw';" |
| 2079 "document.getElementById('chg_submit_wo_username_button').click()"; | 2080 "document.getElementById('chg_submit_wo_username_button').click()"; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2108 .get()); | 2109 .get()); |
| 2109 autofill::PasswordForm signin_form; | 2110 autofill::PasswordForm signin_form; |
| 2110 signin_form.signon_realm = embedded_test_server()->base_url().spec(); | 2111 signin_form.signon_realm = embedded_test_server()->base_url().spec(); |
| 2111 signin_form.password_value = base::ASCIIToUTF16("pw"); | 2112 signin_form.password_value = base::ASCIIToUTF16("pw"); |
| 2112 signin_form.username_value = base::ASCIIToUTF16("temp"); | 2113 signin_form.username_value = base::ASCIIToUTF16("temp"); |
| 2113 password_store->AddLogin(signin_form); | 2114 password_store->AddLogin(signin_form); |
| 2114 | 2115 |
| 2115 // Check that password update bubble is shown. | 2116 // Check that password update bubble is shown. |
| 2116 NavigateToFile("/password/password_form.html"); | 2117 NavigateToFile("/password/password_form.html"); |
| 2117 NavigationObserver observer(WebContents()); | 2118 NavigationObserver observer(WebContents()); |
| 2118 scoped_ptr<PromptObserver> prompt_observer( | 2119 std::unique_ptr<PromptObserver> prompt_observer( |
| 2119 PromptObserver::Create(WebContents())); | 2120 PromptObserver::Create(WebContents())); |
| 2120 std::string fill_and_submit_change_password = | 2121 std::string fill_and_submit_change_password = |
| 2121 "document.getElementById('chg_password_wo_username_field').value = " | 2122 "document.getElementById('chg_password_wo_username_field').value = " |
| 2122 "'random';" | 2123 "'random';" |
| 2123 "document.getElementById('chg_new_password_wo_username_1').value = " | 2124 "document.getElementById('chg_new_password_wo_username_1').value = " |
| 2124 "'new_pw';" | 2125 "'new_pw';" |
| 2125 "document.getElementById('chg_new_password_wo_username_2').value = " | 2126 "document.getElementById('chg_new_password_wo_username_2').value = " |
| 2126 "'new_pw';" | 2127 "'new_pw';" |
| 2127 "document.getElementById('chg_submit_wo_username_button').click()"; | 2128 "document.getElementById('chg_submit_wo_username_button').click()"; |
| 2128 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 2129 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2155 .get()); | 2156 .get()); |
| 2156 autofill::PasswordForm signin_form; | 2157 autofill::PasswordForm signin_form; |
| 2157 signin_form.signon_realm = embedded_test_server()->base_url().spec(); | 2158 signin_form.signon_realm = embedded_test_server()->base_url().spec(); |
| 2158 signin_form.username_value = base::ASCIIToUTF16("temp"); | 2159 signin_form.username_value = base::ASCIIToUTF16("temp"); |
| 2159 signin_form.password_value = base::ASCIIToUTF16("pw"); | 2160 signin_form.password_value = base::ASCIIToUTF16("pw"); |
| 2160 password_store->AddLogin(signin_form); | 2161 password_store->AddLogin(signin_form); |
| 2161 | 2162 |
| 2162 // Check that password update bubble is shown. | 2163 // Check that password update bubble is shown. |
| 2163 NavigateToFile("/password/password_form.html"); | 2164 NavigateToFile("/password/password_form.html"); |
| 2164 NavigationObserver observer(WebContents()); | 2165 NavigationObserver observer(WebContents()); |
| 2165 scoped_ptr<PromptObserver> prompt_observer( | 2166 std::unique_ptr<PromptObserver> prompt_observer( |
| 2166 PromptObserver::Create(WebContents())); | 2167 PromptObserver::Create(WebContents())); |
| 2167 std::string fill_and_submit = | 2168 std::string fill_and_submit = |
| 2168 "document.getElementById('username_field').value = 'temp';" | 2169 "document.getElementById('username_field').value = 'temp';" |
| 2169 "document.getElementById('password_field').value = 'new_pw';" | 2170 "document.getElementById('password_field').value = 'new_pw';" |
| 2170 "document.getElementById('input_submit_button').click()"; | 2171 "document.getElementById('input_submit_button').click()"; |
| 2171 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2172 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 2172 observer.Wait(); | 2173 observer.Wait(); |
| 2173 // The stored password "pw" was overriden with "new_pw", so update prompt is | 2174 // The stored password "pw" was overriden with "new_pw", so update prompt is |
| 2174 // expected. | 2175 // expected. |
| 2175 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); | 2176 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2196 .get()); | 2197 .get()); |
| 2197 autofill::PasswordForm signin_form; | 2198 autofill::PasswordForm signin_form; |
| 2198 signin_form.signon_realm = embedded_test_server()->base_url().spec(); | 2199 signin_form.signon_realm = embedded_test_server()->base_url().spec(); |
| 2199 signin_form.username_value = base::ASCIIToUTF16("temp"); | 2200 signin_form.username_value = base::ASCIIToUTF16("temp"); |
| 2200 signin_form.password_value = base::ASCIIToUTF16("pw"); | 2201 signin_form.password_value = base::ASCIIToUTF16("pw"); |
| 2201 password_store->AddLogin(signin_form); | 2202 password_store->AddLogin(signin_form); |
| 2202 | 2203 |
| 2203 // Check that password update bubble is shown. | 2204 // Check that password update bubble is shown. |
| 2204 NavigateToFile("/password/password_form.html"); | 2205 NavigateToFile("/password/password_form.html"); |
| 2205 NavigationObserver observer(WebContents()); | 2206 NavigationObserver observer(WebContents()); |
| 2206 scoped_ptr<PromptObserver> prompt_observer( | 2207 std::unique_ptr<PromptObserver> prompt_observer( |
| 2207 PromptObserver::Create(WebContents())); | 2208 PromptObserver::Create(WebContents())); |
| 2208 std::string fill_and_submit = | 2209 std::string fill_and_submit = |
| 2209 "document.getElementById('username_field').value = 'temp';" | 2210 "document.getElementById('username_field').value = 'temp';" |
| 2210 "document.getElementById('password_field').value = 'pw';" | 2211 "document.getElementById('password_field').value = 'pw';" |
| 2211 "document.getElementById('input_submit_button').click()"; | 2212 "document.getElementById('input_submit_button').click()"; |
| 2212 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2213 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 2213 observer.Wait(); | 2214 observer.Wait(); |
| 2214 // The stored password "pw" was not overriden, so update prompt is not | 2215 // The stored password "pw" was not overriden, so update prompt is not |
| 2215 // expected. | 2216 // expected. |
| 2216 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); | 2217 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2229 .get()); | 2230 .get()); |
| 2230 autofill::PasswordForm signin_form; | 2231 autofill::PasswordForm signin_form; |
| 2231 signin_form.signon_realm = embedded_test_server()->base_url().spec(); | 2232 signin_form.signon_realm = embedded_test_server()->base_url().spec(); |
| 2232 signin_form.password_value = base::ASCIIToUTF16("pw"); | 2233 signin_form.password_value = base::ASCIIToUTF16("pw"); |
| 2233 signin_form.username_value = base::ASCIIToUTF16("temp"); | 2234 signin_form.username_value = base::ASCIIToUTF16("temp"); |
| 2234 password_store->AddLogin(signin_form); | 2235 password_store->AddLogin(signin_form); |
| 2235 | 2236 |
| 2236 // Check that password update bubble is shown. | 2237 // Check that password update bubble is shown. |
| 2237 NavigateToFile("/password/password_form.html"); | 2238 NavigateToFile("/password/password_form.html"); |
| 2238 NavigationObserver observer(WebContents()); | 2239 NavigationObserver observer(WebContents()); |
| 2239 scoped_ptr<PromptObserver> prompt_observer( | 2240 std::unique_ptr<PromptObserver> prompt_observer( |
| 2240 PromptObserver::Create(WebContents())); | 2241 PromptObserver::Create(WebContents())); |
| 2241 std::string fill_and_submit_change_password = | 2242 std::string fill_and_submit_change_password = |
| 2242 "document.getElementById('chg_text_field').value = '3';" | 2243 "document.getElementById('chg_text_field').value = '3';" |
| 2243 "document.getElementById('chg_password_withtext_field').value" | 2244 "document.getElementById('chg_password_withtext_field').value" |
| 2244 " = 'random';" | 2245 " = 'random';" |
| 2245 "document.getElementById('chg_new_password_withtext_username_1').value" | 2246 "document.getElementById('chg_new_password_withtext_username_1').value" |
| 2246 " = 'new_pw';" | 2247 " = 'new_pw';" |
| 2247 "document.getElementById('chg_new_password_withtext_username_2').value" | 2248 "document.getElementById('chg_new_password_withtext_username_2').value" |
| 2248 " = 'new_pw';" | 2249 " = 'new_pw';" |
| 2249 "document.getElementById('chg_submit_withtext_button').click()"; | 2250 "document.getElementById('chg_submit_withtext_button').click()"; |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2773 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2774 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 2774 PasswordRetryFormSaveNoUsernameCredentials) { | 2775 PasswordRetryFormSaveNoUsernameCredentials) { |
| 2775 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2776 scoped_refptr<password_manager::TestPasswordStore> password_store = |
| 2776 static_cast<password_manager::TestPasswordStore*>( | 2777 static_cast<password_manager::TestPasswordStore*>( |
| 2777 PasswordStoreFactory::GetForProfile( | 2778 PasswordStoreFactory::GetForProfile( |
| 2778 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2779 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
| 2779 .get()); | 2780 .get()); |
| 2780 // Check that password save bubble is shown. | 2781 // Check that password save bubble is shown. |
| 2781 NavigateToFile("/password/password_form.html"); | 2782 NavigateToFile("/password/password_form.html"); |
| 2782 NavigationObserver observer(WebContents()); | 2783 NavigationObserver observer(WebContents()); |
| 2783 scoped_ptr<PromptObserver> prompt_observer( | 2784 std::unique_ptr<PromptObserver> prompt_observer( |
| 2784 PromptObserver::Create(WebContents())); | 2785 PromptObserver::Create(WebContents())); |
| 2785 std::string fill_and_submit = | 2786 std::string fill_and_submit = |
| 2786 "document.getElementById('retry_password_field').value = 'pw';" | 2787 "document.getElementById('retry_password_field').value = 'pw';" |
| 2787 "document.getElementById('retry_submit_button').click()"; | 2788 "document.getElementById('retry_submit_button').click()"; |
| 2788 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2789 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 2789 observer.Wait(); | 2790 observer.Wait(); |
| 2790 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 2791 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 2791 prompt_observer->Accept(); | 2792 prompt_observer->Accept(); |
| 2792 // Spin the message loop to make sure the password store had a chance to | 2793 // Spin the message loop to make sure the password store had a chance to |
| 2793 // update the password. | 2794 // update the password. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2814 signin_form.password_value = base::ASCIIToUTF16("pw"); | 2815 signin_form.password_value = base::ASCIIToUTF16("pw"); |
| 2815 password_store->AddLogin(signin_form); | 2816 password_store->AddLogin(signin_form); |
| 2816 signin_form.username_value = base::ASCIIToUTF16("temp1"); | 2817 signin_form.username_value = base::ASCIIToUTF16("temp1"); |
| 2817 signin_form.password_value = base::ASCIIToUTF16("pw1"); | 2818 signin_form.password_value = base::ASCIIToUTF16("pw1"); |
| 2818 password_store->AddLogin(signin_form); | 2819 password_store->AddLogin(signin_form); |
| 2819 | 2820 |
| 2820 // Check that no password bubble is shown when the submitted password is the | 2821 // Check that no password bubble is shown when the submitted password is the |
| 2821 // same in one of the stored credentials. | 2822 // same in one of the stored credentials. |
| 2822 NavigateToFile("/password/password_form.html"); | 2823 NavigateToFile("/password/password_form.html"); |
| 2823 NavigationObserver observer(WebContents()); | 2824 NavigationObserver observer(WebContents()); |
| 2824 scoped_ptr<PromptObserver> prompt_observer( | 2825 std::unique_ptr<PromptObserver> prompt_observer( |
| 2825 PromptObserver::Create(WebContents())); | 2826 PromptObserver::Create(WebContents())); |
| 2826 std::string fill_and_submit = | 2827 std::string fill_and_submit = |
| 2827 "document.getElementById('retry_password_field').value = 'pw';" | 2828 "document.getElementById('retry_password_field').value = 'pw';" |
| 2828 "document.getElementById('retry_submit_button').click()"; | 2829 "document.getElementById('retry_submit_button').click()"; |
| 2829 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2830 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 2830 observer.Wait(); | 2831 observer.Wait(); |
| 2831 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 2832 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 2832 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); | 2833 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); |
| 2833 } | 2834 } |
| 2834 | 2835 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2845 .get()); | 2846 .get()); |
| 2846 autofill::PasswordForm signin_form; | 2847 autofill::PasswordForm signin_form; |
| 2847 signin_form.signon_realm = embedded_test_server()->base_url().spec(); | 2848 signin_form.signon_realm = embedded_test_server()->base_url().spec(); |
| 2848 signin_form.username_value = base::ASCIIToUTF16("temp"); | 2849 signin_form.username_value = base::ASCIIToUTF16("temp"); |
| 2849 signin_form.password_value = base::ASCIIToUTF16("pw"); | 2850 signin_form.password_value = base::ASCIIToUTF16("pw"); |
| 2850 password_store->AddLogin(signin_form); | 2851 password_store->AddLogin(signin_form); |
| 2851 | 2852 |
| 2852 // Check that password update bubble is shown. | 2853 // Check that password update bubble is shown. |
| 2853 NavigateToFile("/password/password_form.html"); | 2854 NavigateToFile("/password/password_form.html"); |
| 2854 NavigationObserver observer(WebContents()); | 2855 NavigationObserver observer(WebContents()); |
| 2855 scoped_ptr<PromptObserver> prompt_observer( | 2856 std::unique_ptr<PromptObserver> prompt_observer( |
| 2856 PromptObserver::Create(WebContents())); | 2857 PromptObserver::Create(WebContents())); |
| 2857 std::string fill_and_submit = | 2858 std::string fill_and_submit = |
| 2858 "document.getElementById('retry_password_field').value = 'new_pw';" | 2859 "document.getElementById('retry_password_field').value = 'new_pw';" |
| 2859 "document.getElementById('retry_submit_button').click()"; | 2860 "document.getElementById('retry_submit_button').click()"; |
| 2860 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2861 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 2861 observer.Wait(); | 2862 observer.Wait(); |
| 2862 // The new password "new_pw" is used, so update prompt is expected. | 2863 // The new password "new_pw" is used, so update prompt is expected. |
| 2863 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); | 2864 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); |
| 2864 | 2865 |
| 2865 const autofill::PasswordForm stored_form = | 2866 const autofill::PasswordForm stored_form = |
| 2866 password_store->stored_passwords().begin()->second[0]; | 2867 password_store->stored_passwords().begin()->second[0]; |
| 2867 prompt_observer->AcceptUpdatePrompt(stored_form); | 2868 prompt_observer->AcceptUpdatePrompt(stored_form); |
| 2868 // Spin the message loop to make sure the password store had a chance to | 2869 // Spin the message loop to make sure the password store had a chance to |
| 2869 // update the password. | 2870 // update the password. |
| 2870 base::RunLoop run_loop; | 2871 base::RunLoop run_loop; |
| 2871 run_loop.RunUntilIdle(); | 2872 run_loop.RunUntilIdle(); |
| 2872 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2873 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), |
| 2873 base::ASCIIToUTF16("new_pw")); | 2874 base::ASCIIToUTF16("new_pw")); |
| 2874 } | 2875 } |
| 2875 | 2876 |
| 2876 // Tests that the prompt to save the password is still shown if the fields have | 2877 // Tests that the prompt to save the password is still shown if the fields have |
| 2877 // the "autocomplete" attribute set off. | 2878 // the "autocomplete" attribute set off. |
| 2878 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2879 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
| 2879 PromptForSubmitWithAutocompleteOff) { | 2880 PromptForSubmitWithAutocompleteOff) { |
| 2880 NavigateToFile("/password/password_autocomplete_off_test.html"); | 2881 NavigateToFile("/password/password_autocomplete_off_test.html"); |
| 2881 | 2882 |
| 2882 NavigationObserver observer(WebContents()); | 2883 NavigationObserver observer(WebContents()); |
| 2883 scoped_ptr<PromptObserver> prompt_observer( | 2884 std::unique_ptr<PromptObserver> prompt_observer( |
| 2884 PromptObserver::Create(WebContents())); | 2885 PromptObserver::Create(WebContents())); |
| 2885 std::string fill_and_submit = | 2886 std::string fill_and_submit = |
| 2886 "document.getElementById('username').value = 'temp';" | 2887 "document.getElementById('username').value = 'temp';" |
| 2887 "document.getElementById('password').value = 'random';" | 2888 "document.getElementById('password').value = 'random';" |
| 2888 "document.getElementById('submit').click()"; | 2889 "document.getElementById('submit').click()"; |
| 2889 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2890 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
| 2890 observer.Wait(); | 2891 observer.Wait(); |
| 2891 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); | 2892 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); |
| 2892 } | 2893 } |
| 2893 | 2894 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2922 password_store->AddLogin(signin_form); | 2923 password_store->AddLogin(signin_form); |
| 2923 | 2924 |
| 2924 NavigateToFile("/password/password_form.html"); | 2925 NavigateToFile("/password/password_form.html"); |
| 2925 | 2926 |
| 2926 // Call the API to trigger the notification to the client. | 2927 // Call the API to trigger the notification to the client. |
| 2927 ASSERT_TRUE(content::ExecuteScript( | 2928 ASSERT_TRUE(content::ExecuteScript( |
| 2928 RenderViewHost(), | 2929 RenderViewHost(), |
| 2929 "navigator.credentials.get({password: true, unmediated: true })")); | 2930 "navigator.credentials.get({password: true, unmediated: true })")); |
| 2930 | 2931 |
| 2931 NavigationObserver observer(WebContents()); | 2932 NavigationObserver observer(WebContents()); |
| 2932 scoped_ptr<PromptObserver> prompt_observer( | 2933 std::unique_ptr<PromptObserver> prompt_observer( |
| 2933 PromptObserver::Create(WebContents())); | 2934 PromptObserver::Create(WebContents())); |
| 2934 std::string fill_and_submit_change_password = | 2935 std::string fill_and_submit_change_password = |
| 2935 "document.getElementById('username_field').value = 'user';" | 2936 "document.getElementById('username_field').value = 'user';" |
| 2936 "document.getElementById('password_field').value = 'password';" | 2937 "document.getElementById('password_field').value = 'password';" |
| 2937 "document.getElementById('input_submit_button').click()"; | 2938 "document.getElementById('input_submit_button').click()"; |
| 2938 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 2939 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
| 2939 fill_and_submit_change_password)); | 2940 fill_and_submit_change_password)); |
| 2940 observer.Wait(); | 2941 observer.Wait(); |
| 2941 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 2942 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 2942 | 2943 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2966 signin_form.username_value = base::ASCIIToUTF16("user"); | 2967 signin_form.username_value = base::ASCIIToUTF16("user"); |
| 2967 signin_form.origin = embedded_test_server()->base_url(); | 2968 signin_form.origin = embedded_test_server()->base_url(); |
| 2968 signin_form.skip_zero_click = true; | 2969 signin_form.skip_zero_click = true; |
| 2969 password_store->AddLogin(signin_form); | 2970 password_store->AddLogin(signin_form); |
| 2970 | 2971 |
| 2971 NavigateToFile("/password/password_form.html"); | 2972 NavigateToFile("/password/password_form.html"); |
| 2972 | 2973 |
| 2973 // No API call. | 2974 // No API call. |
| 2974 | 2975 |
| 2975 NavigationObserver observer(WebContents()); | 2976 NavigationObserver observer(WebContents()); |
| 2976 scoped_ptr<PromptObserver> prompt_observer( | 2977 std::unique_ptr<PromptObserver> prompt_observer( |
| 2977 PromptObserver::Create(WebContents())); | 2978 PromptObserver::Create(WebContents())); |
| 2978 std::string fill_and_submit_change_password = | 2979 std::string fill_and_submit_change_password = |
| 2979 "document.getElementById('username_field').value = 'user';" | 2980 "document.getElementById('username_field').value = 'user';" |
| 2980 "document.getElementById('password_field').value = 'password';" | 2981 "document.getElementById('password_field').value = 'password';" |
| 2981 "document.getElementById('input_submit_button').click()"; | 2982 "document.getElementById('input_submit_button').click()"; |
| 2982 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 2983 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
| 2983 fill_and_submit_change_password)); | 2984 fill_and_submit_change_password)); |
| 2984 observer.Wait(); | 2985 observer.Wait(); |
| 2985 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); | 2986 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); |
| 2986 | 2987 |
| 2987 // Verify that the form's 'skip_zero_click' is not updated. | 2988 // Verify that the form's 'skip_zero_click' is not updated. |
| 2988 auto& passwords_map = password_store->stored_passwords(); | 2989 auto& passwords_map = password_store->stored_passwords(); |
| 2989 ASSERT_EQ(1u, passwords_map.size()); | 2990 ASSERT_EQ(1u, passwords_map.size()); |
| 2990 auto& passwords_vector = passwords_map.begin()->second; | 2991 auto& passwords_vector = passwords_map.begin()->second; |
| 2991 ASSERT_EQ(1u, passwords_vector.size()); | 2992 ASSERT_EQ(1u, passwords_vector.size()); |
| 2992 const autofill::PasswordForm& form = passwords_vector[0]; | 2993 const autofill::PasswordForm& form = passwords_vector[0]; |
| 2993 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value); | 2994 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value); |
| 2994 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value); | 2995 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value); |
| 2995 EXPECT_TRUE(form.skip_zero_click); | 2996 EXPECT_TRUE(form.skip_zero_click); |
| 2996 } | 2997 } |
| 2997 | 2998 |
| 2998 } // namespace password_manager | 2999 } // namespace password_manager |
| OLD | NEW |