OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 explicit ObservingAutofillClient(content::WebContents* web_contents) | 159 explicit ObservingAutofillClient(content::WebContents* web_contents) |
160 : run_loop_(nullptr), popup_shown_(false) {} | 160 : run_loop_(nullptr), popup_shown_(false) {} |
161 friend class content::WebContentsUserData<ObservingAutofillClient>; | 161 friend class content::WebContentsUserData<ObservingAutofillClient>; |
162 | 162 |
163 base::RunLoop* run_loop_; | 163 base::RunLoop* run_loop_; |
164 bool popup_shown_; | 164 bool popup_shown_; |
165 | 165 |
166 DISALLOW_COPY_AND_ASSIGN(ObservingAutofillClient); | 166 DISALLOW_COPY_AND_ASSIGN(ObservingAutofillClient); |
167 }; | 167 }; |
168 | 168 |
169 // For simplicity we assume that password store contains only 1 credential. | |
170 void CheckThatCredentialsStored( | |
171 password_manager::TestPasswordStore* password_store, | |
172 const base::string16& username, | |
173 const base::string16& password) { | |
174 auto& passwords_map = password_store->stored_passwords(); | |
175 ASSERT_EQ(1u, passwords_map.size()); | |
176 auto& passwords_vector = passwords_map.begin()->second; | |
177 ASSERT_EQ(1u, passwords_vector.size()); | |
178 const autofill::PasswordForm& form = passwords_vector[0]; | |
179 EXPECT_EQ(username, form.username_value); | |
180 EXPECT_EQ(password, form.password_value); | |
181 } | |
182 | |
183 void TestPromptNotShown(const char* failure_message, | 169 void TestPromptNotShown(const char* failure_message, |
184 content::WebContents* web_contents, | 170 content::WebContents* web_contents, |
185 content::RenderViewHost* rvh) { | 171 content::RenderViewHost* rvh) { |
186 SCOPED_TRACE(testing::Message(failure_message)); | 172 SCOPED_TRACE(testing::Message(failure_message)); |
187 | 173 |
188 NavigationObserver observer(web_contents); | 174 NavigationObserver observer(web_contents); |
189 std::string fill_and_submit = | 175 std::string fill_and_submit = |
190 "document.getElementById('username_failed').value = 'temp';" | 176 "document.getElementById('username_failed').value = 'temp';" |
191 "document.getElementById('password_failed').value = 'random';" | 177 "document.getElementById('password_failed').value = 'random';" |
192 "document.getElementById('failed_form').submit()"; | 178 "document.getElementById('failed_form').submit()"; |
193 | 179 |
194 ASSERT_TRUE(content::ExecuteScript(rvh, fill_and_submit)); | 180 ASSERT_TRUE(content::ExecuteScript(rvh, fill_and_submit)); |
195 observer.Wait(); | 181 observer.Wait(); |
196 EXPECT_FALSE(BubbleObserver(web_contents).IsShowingSavePrompt()); | 182 EXPECT_FALSE(BubbleObserver(web_contents).IsSavePromptShownAutomatically()); |
197 } | 183 } |
198 | 184 |
199 } // namespace | 185 } // namespace |
200 | 186 |
201 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ObservingAutofillClient); | 187 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ObservingAutofillClient); |
202 | 188 |
203 namespace password_manager { | 189 namespace password_manager { |
204 | 190 |
205 // Actual tests --------------------------------------------------------------- | 191 // Actual tests --------------------------------------------------------------- |
206 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForNormalSubmit) { | 192 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForNormalSubmit) { |
207 NavigateToFile("/password/password_form.html"); | 193 NavigateToFile("/password/password_form.html"); |
208 | 194 |
209 // Fill a form and submit through a <input type="submit"> button. Nothing | 195 // Fill a form and submit through a <input type="submit"> button. Nothing |
210 // special. | 196 // special. |
211 NavigationObserver observer(WebContents()); | 197 NavigationObserver observer(WebContents()); |
212 std::string fill_and_submit = | 198 std::string fill_and_submit = |
213 "document.getElementById('username_field').value = 'temp';" | 199 "document.getElementById('username_field').value = 'temp';" |
214 "document.getElementById('password_field').value = 'random';" | 200 "document.getElementById('password_field').value = 'random';" |
215 "document.getElementById('input_submit_button').click()"; | 201 "document.getElementById('input_submit_button').click()"; |
216 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 202 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
217 observer.Wait(); | 203 observer.Wait(); |
218 | 204 |
219 // Save the password and check the store. | 205 // Save the password and check the store. |
220 BubbleObserver bubble_observer(WebContents()); | 206 BubbleObserver bubble_observer(WebContents()); |
221 EXPECT_TRUE(bubble_observer.IsShowingSavePrompt()); | 207 EXPECT_TRUE(bubble_observer.IsSavePromptShownAutomatically()); |
222 bubble_observer.AcceptSavePrompt(); | 208 bubble_observer.AcceptSavePrompt(); |
223 WaitForPasswordStore(); | 209 WaitForPasswordStore(); |
224 | 210 |
225 scoped_refptr<password_manager::TestPasswordStore> password_store = | 211 CheckThatCredentialsStored(base::ASCIIToUTF16("temp"), |
226 static_cast<password_manager::TestPasswordStore*>( | |
227 PasswordStoreFactory::GetForProfile( | |
228 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
229 .get()); | |
230 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | |
231 base::ASCIIToUTF16("random")); | 212 base::ASCIIToUTF16("random")); |
232 } | 213 } |
233 | 214 |
234 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 215 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
235 NoPromptIfFormReappeared) { | 216 NoPromptIfFormReappeared) { |
236 NavigateToFile("/password/failed.html"); | 217 NavigateToFile("/password/failed.html"); |
237 TestPromptNotShown("normal form", WebContents(), RenderViewHost()); | 218 TestPromptNotShown("normal form", WebContents(), RenderViewHost()); |
238 } | 219 } |
239 | 220 |
240 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 221 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
(...skipping 21 matching lines...) Expand all Loading... |
262 // should not send "PasswordFormsParsed" messages after the page was loaded. | 243 // should not send "PasswordFormsParsed" messages after the page was loaded. |
263 NavigationObserver observer(WebContents()); | 244 NavigationObserver observer(WebContents()); |
264 std::string fill_and_submit = | 245 std::string fill_and_submit = |
265 "document.getElementById('username_field').value = 'temp';" | 246 "document.getElementById('username_field').value = 'temp';" |
266 "document.getElementById('password_field').value = 'random';" | 247 "document.getElementById('password_field').value = 'random';" |
267 "document.getElementById('input_submit_button').click()"; | 248 "document.getElementById('input_submit_button').click()"; |
268 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 249 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
269 observer.Wait(); | 250 observer.Wait(); |
270 std::unique_ptr<BubbleObserver> prompt_observer( | 251 std::unique_ptr<BubbleObserver> prompt_observer( |
271 new BubbleObserver(WebContents())); | 252 new BubbleObserver(WebContents())); |
272 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 253 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
273 } | 254 } |
274 | 255 |
275 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 256 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
276 PromptForSubmitWithInPageNavigation) { | 257 PromptForSubmitWithInPageNavigation) { |
277 NavigateToFile("/password/password_navigate_before_submit.html"); | 258 NavigateToFile("/password/password_navigate_before_submit.html"); |
278 | 259 |
279 // Fill a form and submit through a <input type="submit"> button. Nothing | 260 // Fill a form and submit through a <input type="submit"> button. Nothing |
280 // special. The form does an in-page navigation before submitting. | 261 // special. The form does an in-page navigation before submitting. |
281 NavigationObserver observer(WebContents()); | 262 NavigationObserver observer(WebContents()); |
282 std::unique_ptr<BubbleObserver> prompt_observer( | 263 std::unique_ptr<BubbleObserver> prompt_observer( |
283 new BubbleObserver(WebContents())); | 264 new BubbleObserver(WebContents())); |
284 std::string fill_and_submit = | 265 std::string fill_and_submit = |
285 "document.getElementById('username_field').value = 'temp';" | 266 "document.getElementById('username_field').value = 'temp';" |
286 "document.getElementById('password_field').value = 'random';" | 267 "document.getElementById('password_field').value = 'random';" |
287 "document.getElementById('input_submit_button').click()"; | 268 "document.getElementById('input_submit_button').click()"; |
288 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 269 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
289 observer.Wait(); | 270 observer.Wait(); |
290 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 271 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
291 } | 272 } |
292 | 273 |
293 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 274 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
294 LoginSuccessWithUnrelatedForm) { | 275 LoginSuccessWithUnrelatedForm) { |
295 // Log in, see a form on the landing page. That form is not related to the | 276 // Log in, see a form on the landing page. That form is not related to the |
296 // login form (=has a different action), so we should offer saving the | 277 // login form (=has a different action), so we should offer saving the |
297 // password. | 278 // password. |
298 NavigateToFile("/password/password_form.html"); | 279 NavigateToFile("/password/password_form.html"); |
299 | 280 |
300 NavigationObserver observer(WebContents()); | 281 NavigationObserver observer(WebContents()); |
301 std::unique_ptr<BubbleObserver> prompt_observer( | 282 std::unique_ptr<BubbleObserver> prompt_observer( |
302 new BubbleObserver(WebContents())); | 283 new BubbleObserver(WebContents())); |
303 std::string fill_and_submit = | 284 std::string fill_and_submit = |
304 "document.getElementById('username_unrelated').value = 'temp';" | 285 "document.getElementById('username_unrelated').value = 'temp';" |
305 "document.getElementById('password_unrelated').value = 'random';" | 286 "document.getElementById('password_unrelated').value = 'random';" |
306 "document.getElementById('submit_unrelated').click()"; | 287 "document.getElementById('submit_unrelated').click()"; |
307 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 288 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
308 observer.Wait(); | 289 observer.Wait(); |
309 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 290 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
310 } | 291 } |
311 | 292 |
312 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, LoginFailed) { | 293 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, LoginFailed) { |
313 // Log in, see a form on the landing page. That form is not related to the | 294 // Log in, see a form on the landing page. That form is not related to the |
314 // login form (=has a different action), so we should offer saving the | 295 // login form (=has a different action), so we should offer saving the |
315 // password. | 296 // password. |
316 NavigateToFile("/password/password_form.html"); | 297 NavigateToFile("/password/password_form.html"); |
317 | 298 |
318 NavigationObserver observer(WebContents()); | 299 NavigationObserver observer(WebContents()); |
319 std::unique_ptr<BubbleObserver> prompt_observer( | 300 std::unique_ptr<BubbleObserver> prompt_observer( |
320 new BubbleObserver(WebContents())); | 301 new BubbleObserver(WebContents())); |
321 std::string fill_and_submit = | 302 std::string fill_and_submit = |
322 "document.getElementById('username_failed').value = 'temp';" | 303 "document.getElementById('username_failed').value = 'temp';" |
323 "document.getElementById('password_failed').value = 'random';" | 304 "document.getElementById('password_failed').value = 'random';" |
324 "document.getElementById('submit_failed').click()"; | 305 "document.getElementById('submit_failed').click()"; |
325 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 306 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
326 observer.Wait(); | 307 observer.Wait(); |
327 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 308 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
328 } | 309 } |
329 | 310 |
330 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, Redirects) { | 311 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, Redirects) { |
331 NavigateToFile("/password/password_form.html"); | 312 NavigateToFile("/password/password_form.html"); |
332 | 313 |
333 // Fill a form and submit through a <input type="submit"> button. The form | 314 // Fill a form and submit through a <input type="submit"> button. The form |
334 // points to a redirection page. | 315 // points to a redirection page. |
335 NavigationObserver observer1(WebContents()); | 316 NavigationObserver observer1(WebContents()); |
336 std::string fill_and_submit = | 317 std::string fill_and_submit = |
337 "document.getElementById('username_redirect').value = 'temp';" | 318 "document.getElementById('username_redirect').value = 'temp';" |
338 "document.getElementById('password_redirect').value = 'random';" | 319 "document.getElementById('password_redirect').value = 'random';" |
339 "document.getElementById('submit_redirect').click()"; | 320 "document.getElementById('submit_redirect').click()"; |
340 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 321 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
341 observer1.Wait(); | 322 observer1.Wait(); |
342 BubbleObserver bubble_observer(WebContents()); | 323 BubbleObserver bubble_observer(WebContents()); |
343 EXPECT_TRUE(bubble_observer.IsShowingSavePrompt()); | 324 EXPECT_TRUE(bubble_observer.IsSavePromptShownAutomatically()); |
344 | 325 |
345 // The redirection page now redirects via Javascript. We check that the | 326 // The redirection page now redirects via Javascript. We check that the |
346 // bubble stays. | 327 // bubble stays. |
347 NavigationObserver observer2(WebContents()); | 328 NavigationObserver observer2(WebContents()); |
348 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture( | 329 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture( |
349 RenderFrameHost(), "window.location.href = 'done.html';")); | 330 RenderFrameHost(), "window.location.href = 'done.html';")); |
350 observer2.Wait(); | 331 observer2.Wait(); |
351 EXPECT_TRUE(bubble_observer.IsShowingSavePrompt()); | 332 EXPECT_TRUE(bubble_observer.IsSavePromptShownAutomatically()); |
352 } | 333 } |
353 | 334 |
354 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 335 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
355 PromptForSubmitUsingJavaScript) { | 336 PromptForSubmitUsingJavaScript) { |
356 NavigateToFile("/password/password_form.html"); | 337 NavigateToFile("/password/password_form.html"); |
357 | 338 |
358 // Fill a form and submit using <button> that calls submit() on the form. | 339 // Fill a form and submit using <button> that calls submit() on the form. |
359 // This should work regardless of the type of element, as long as submit() is | 340 // This should work regardless of the type of element, as long as submit() is |
360 // called. | 341 // called. |
361 NavigationObserver observer(WebContents()); | 342 NavigationObserver observer(WebContents()); |
362 std::unique_ptr<BubbleObserver> prompt_observer( | 343 std::unique_ptr<BubbleObserver> prompt_observer( |
363 new BubbleObserver(WebContents())); | 344 new BubbleObserver(WebContents())); |
364 std::string fill_and_submit = | 345 std::string fill_and_submit = |
365 "document.getElementById('username_field').value = 'temp';" | 346 "document.getElementById('username_field').value = 'temp';" |
366 "document.getElementById('password_field').value = 'random';" | 347 "document.getElementById('password_field').value = 'random';" |
367 "document.getElementById('submit_button').click()"; | 348 "document.getElementById('submit_button').click()"; |
368 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 349 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
369 observer.Wait(); | 350 observer.Wait(); |
370 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 351 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
371 } | 352 } |
372 | 353 |
373 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForDynamicForm) { | 354 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForDynamicForm) { |
374 // Adding a PSL matching form is a workaround explained later. | 355 // Adding a PSL matching form is a workaround explained later. |
375 scoped_refptr<password_manager::TestPasswordStore> password_store = | 356 scoped_refptr<password_manager::TestPasswordStore> password_store = |
376 static_cast<password_manager::TestPasswordStore*>( | 357 static_cast<password_manager::TestPasswordStore*>( |
377 PasswordStoreFactory::GetForProfile( | 358 PasswordStoreFactory::GetForProfile( |
378 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 359 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
379 .get()); | 360 .get()); |
380 autofill::PasswordForm signin_form; | 361 autofill::PasswordForm signin_form; |
(...skipping 20 matching lines...) Expand all Loading... |
401 | 382 |
402 // Fill the dynamic password form and submit. | 383 // Fill the dynamic password form and submit. |
403 NavigationObserver observer(WebContents()); | 384 NavigationObserver observer(WebContents()); |
404 std::string fill_and_submit = | 385 std::string fill_and_submit = |
405 "document.dynamic_form.username.value = 'tempro';" | 386 "document.dynamic_form.username.value = 'tempro';" |
406 "document.dynamic_form.password.value = 'random';" | 387 "document.dynamic_form.password.value = 'random';" |
407 "document.dynamic_form.submit()"; | 388 "document.dynamic_form.submit()"; |
408 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 389 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
409 observer.Wait(); | 390 observer.Wait(); |
410 | 391 |
411 EXPECT_TRUE(BubbleObserver(WebContents()).IsShowingSavePrompt()); | 392 EXPECT_TRUE(BubbleObserver(WebContents()).IsSavePromptShownAutomatically()); |
412 } | 393 } |
413 | 394 |
414 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptForNavigation) { | 395 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptForNavigation) { |
415 NavigateToFile("/password/password_form.html"); | 396 NavigateToFile("/password/password_form.html"); |
416 | 397 |
417 // Don't fill the password form, just navigate away. Shouldn't prompt. | 398 // Don't fill the password form, just navigate away. Shouldn't prompt. |
418 NavigationObserver observer(WebContents()); | 399 NavigationObserver observer(WebContents()); |
419 std::unique_ptr<BubbleObserver> prompt_observer( | 400 std::unique_ptr<BubbleObserver> prompt_observer( |
420 new BubbleObserver(WebContents())); | 401 new BubbleObserver(WebContents())); |
421 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture( | 402 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture( |
422 RenderFrameHost(), "window.location.href = 'done.html';")); | 403 RenderFrameHost(), "window.location.href = 'done.html';")); |
423 observer.Wait(); | 404 observer.Wait(); |
424 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 405 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
425 } | 406 } |
426 | 407 |
427 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 408 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
428 NoPromptForSubFrameNavigation) { | 409 NoPromptForSubFrameNavigation) { |
429 NavigateToFile("/password/multi_frames.html"); | 410 NavigateToFile("/password/multi_frames.html"); |
430 | 411 |
431 // If you are filling out a password form in one frame and a different frame | 412 // If you are filling out a password form in one frame and a different frame |
432 // navigates, this should not trigger the infobar. | 413 // navigates, this should not trigger the infobar. |
433 NavigationObserver observer(WebContents()); | 414 NavigationObserver observer(WebContents()); |
434 std::unique_ptr<BubbleObserver> prompt_observer( | 415 std::unique_ptr<BubbleObserver> prompt_observer( |
435 new BubbleObserver(WebContents())); | 416 new BubbleObserver(WebContents())); |
436 observer.SetPathToWaitFor("/password/done.html"); | 417 observer.SetPathToWaitFor("/password/done.html"); |
437 std::string fill = | 418 std::string fill = |
438 "var first_frame = document.getElementById('first_frame');" | 419 "var first_frame = document.getElementById('first_frame');" |
439 "var frame_doc = first_frame.contentDocument;" | 420 "var frame_doc = first_frame.contentDocument;" |
440 "frame_doc.getElementById('username_field').value = 'temp';" | 421 "frame_doc.getElementById('username_field').value = 'temp';" |
441 "frame_doc.getElementById('password_field').value = 'random';"; | 422 "frame_doc.getElementById('password_field').value = 'random';"; |
442 std::string navigate_frame = | 423 std::string navigate_frame = |
443 "var second_iframe = document.getElementById('second_frame');" | 424 "var second_iframe = document.getElementById('second_frame');" |
444 "second_iframe.contentWindow.location.href = 'done.html';"; | 425 "second_iframe.contentWindow.location.href = 'done.html';"; |
445 | 426 |
446 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); | 427 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); |
447 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); | 428 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); |
448 observer.Wait(); | 429 observer.Wait(); |
449 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 430 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
450 } | 431 } |
451 | 432 |
452 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 433 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
453 PromptAfterSubmitWithSubFrameNavigation) { | 434 PromptAfterSubmitWithSubFrameNavigation) { |
454 NavigateToFile("/password/multi_frames.html"); | 435 NavigateToFile("/password/multi_frames.html"); |
455 | 436 |
456 // Make sure that we prompt to save password even if a sub-frame navigation | 437 // Make sure that we prompt to save password even if a sub-frame navigation |
457 // happens first. | 438 // happens first. |
458 NavigationObserver observer(WebContents()); | 439 NavigationObserver observer(WebContents()); |
459 std::unique_ptr<BubbleObserver> prompt_observer( | 440 std::unique_ptr<BubbleObserver> prompt_observer( |
460 new BubbleObserver(WebContents())); | 441 new BubbleObserver(WebContents())); |
461 observer.SetPathToWaitFor("/password/done.html"); | 442 observer.SetPathToWaitFor("/password/done.html"); |
462 std::string navigate_frame = | 443 std::string navigate_frame = |
463 "var second_iframe = document.getElementById('second_frame');" | 444 "var second_iframe = document.getElementById('second_frame');" |
464 "second_iframe.contentWindow.location.href = 'other.html';"; | 445 "second_iframe.contentWindow.location.href = 'other.html';"; |
465 std::string fill_and_submit = | 446 std::string fill_and_submit = |
466 "var first_frame = document.getElementById('first_frame');" | 447 "var first_frame = document.getElementById('first_frame');" |
467 "var frame_doc = first_frame.contentDocument;" | 448 "var frame_doc = first_frame.contentDocument;" |
468 "frame_doc.getElementById('username_field').value = 'temp';" | 449 "frame_doc.getElementById('username_field').value = 'temp';" |
469 "frame_doc.getElementById('password_field').value = 'random';" | 450 "frame_doc.getElementById('password_field').value = 'random';" |
470 "frame_doc.getElementById('input_submit_button').click();"; | 451 "frame_doc.getElementById('input_submit_button').click();"; |
471 | 452 |
472 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); | 453 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); |
473 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 454 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
474 observer.Wait(); | 455 observer.Wait(); |
475 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 456 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
476 } | 457 } |
477 | 458 |
478 IN_PROC_BROWSER_TEST_F( | 459 IN_PROC_BROWSER_TEST_F( |
479 PasswordManagerBrowserTestBase, | 460 PasswordManagerBrowserTestBase, |
480 NoPromptForFailedLoginFromMainFrameWithMultiFramesInPage) { | 461 NoPromptForFailedLoginFromMainFrameWithMultiFramesInPage) { |
481 NavigateToFile("/password/multi_frames.html"); | 462 NavigateToFile("/password/multi_frames.html"); |
482 | 463 |
483 // Make sure that we don't prompt to save the password for a failed login | 464 // Make sure that we don't prompt to save the password for a failed login |
484 // from the main frame with multiple frames in the same page. | 465 // from the main frame with multiple frames in the same page. |
485 NavigationObserver observer(WebContents()); | 466 NavigationObserver observer(WebContents()); |
486 std::unique_ptr<BubbleObserver> prompt_observer( | 467 std::unique_ptr<BubbleObserver> prompt_observer( |
487 new BubbleObserver(WebContents())); | 468 new BubbleObserver(WebContents())); |
488 std::string fill_and_submit = | 469 std::string fill_and_submit = |
489 "document.getElementById('username_failed').value = 'temp';" | 470 "document.getElementById('username_failed').value = 'temp';" |
490 "document.getElementById('password_failed').value = 'random';" | 471 "document.getElementById('password_failed').value = 'random';" |
491 "document.getElementById('submit_failed').click();"; | 472 "document.getElementById('submit_failed').click();"; |
492 | 473 |
493 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 474 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
494 observer.Wait(); | 475 observer.Wait(); |
495 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 476 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
496 } | 477 } |
497 | 478 |
498 IN_PROC_BROWSER_TEST_F( | 479 IN_PROC_BROWSER_TEST_F( |
499 PasswordManagerBrowserTestBase, | 480 PasswordManagerBrowserTestBase, |
500 NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage) { | 481 NoPromptForFailedLoginFromSubFrameWithMultiFramesInPage) { |
501 NavigateToFile("/password/multi_frames.html"); | 482 NavigateToFile("/password/multi_frames.html"); |
502 | 483 |
503 // Make sure that we don't prompt to save the password for a failed login | 484 // Make sure that we don't prompt to save the password for a failed login |
504 // from a sub-frame with multiple frames in the same page. | 485 // from a sub-frame with multiple frames in the same page. |
505 NavigationObserver observer(WebContents()); | 486 NavigationObserver observer(WebContents()); |
506 std::unique_ptr<BubbleObserver> prompt_observer( | 487 std::unique_ptr<BubbleObserver> prompt_observer( |
507 new BubbleObserver(WebContents())); | 488 new BubbleObserver(WebContents())); |
508 std::string fill_and_submit = | 489 std::string fill_and_submit = |
509 "var first_frame = document.getElementById('first_frame');" | 490 "var first_frame = document.getElementById('first_frame');" |
510 "var frame_doc = first_frame.contentDocument;" | 491 "var frame_doc = first_frame.contentDocument;" |
511 "frame_doc.getElementById('username_failed').value = 'temp';" | 492 "frame_doc.getElementById('username_failed').value = 'temp';" |
512 "frame_doc.getElementById('password_failed').value = 'random';" | 493 "frame_doc.getElementById('password_failed').value = 'random';" |
513 "frame_doc.getElementById('submit_failed').click();"; | 494 "frame_doc.getElementById('submit_failed').click();"; |
514 | 495 |
515 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 496 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
516 observer.SetPathToWaitFor("/password/failed.html"); | 497 observer.SetPathToWaitFor("/password/failed.html"); |
517 observer.Wait(); | 498 observer.Wait(); |
518 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 499 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
519 } | 500 } |
520 | 501 |
521 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForXHRSubmit) { | 502 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForXHRSubmit) { |
522 NavigateToFile("/password/password_xhr_submit.html"); | 503 NavigateToFile("/password/password_xhr_submit.html"); |
523 | 504 |
524 // Verify that we show the save password prompt if a form returns false | 505 // Verify that we show the save password prompt if a form returns false |
525 // in its onsubmit handler but instead logs in/navigates via XHR. | 506 // in its onsubmit handler but instead logs in/navigates via XHR. |
526 // Note that calling 'submit()' on a form with javascript doesn't call | 507 // Note that calling 'submit()' on a form with javascript doesn't call |
527 // the onsubmit handler, so we click the submit button instead. | 508 // the onsubmit handler, so we click the submit button instead. |
528 NavigationObserver observer(WebContents()); | 509 NavigationObserver observer(WebContents()); |
529 std::unique_ptr<BubbleObserver> prompt_observer( | 510 std::unique_ptr<BubbleObserver> prompt_observer( |
530 new BubbleObserver(WebContents())); | 511 new BubbleObserver(WebContents())); |
531 std::string fill_and_submit = | 512 std::string fill_and_submit = |
532 "document.getElementById('username_field').value = 'temp';" | 513 "document.getElementById('username_field').value = 'temp';" |
533 "document.getElementById('password_field').value = 'random';" | 514 "document.getElementById('password_field').value = 'random';" |
534 "document.getElementById('submit_button').click()"; | 515 "document.getElementById('submit_button').click()"; |
535 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 516 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
536 observer.Wait(); | 517 observer.Wait(); |
537 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 518 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
538 } | 519 } |
539 | 520 |
540 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 521 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
541 PromptForXHRWithoutOnSubmit) { | 522 PromptForXHRWithoutOnSubmit) { |
542 NavigateToFile("/password/password_xhr_submit.html"); | 523 NavigateToFile("/password/password_xhr_submit.html"); |
543 | 524 |
544 // Verify that if XHR navigation occurs and the form is properly filled out, | 525 // Verify that if XHR navigation occurs and the form is properly filled out, |
545 // we try and save the password even though onsubmit hasn't been called. | 526 // we try and save the password even though onsubmit hasn't been called. |
546 NavigationObserver observer(WebContents()); | 527 NavigationObserver observer(WebContents()); |
547 std::unique_ptr<BubbleObserver> prompt_observer( | 528 std::unique_ptr<BubbleObserver> prompt_observer( |
548 new BubbleObserver(WebContents())); | 529 new BubbleObserver(WebContents())); |
549 std::string fill_and_navigate = | 530 std::string fill_and_navigate = |
550 "document.getElementById('username_field').value = 'temp';" | 531 "document.getElementById('username_field').value = 'temp';" |
551 "document.getElementById('password_field').value = 'random';" | 532 "document.getElementById('password_field').value = 'random';" |
552 "send_xhr()"; | 533 "send_xhr()"; |
553 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 534 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
554 observer.Wait(); | 535 observer.Wait(); |
555 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 536 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
556 } | 537 } |
557 | 538 |
558 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 539 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
559 PromptForXHRWithNewPasswordsWithoutOnSubmit) { | 540 PromptForXHRWithNewPasswordsWithoutOnSubmit) { |
560 NavigateToFile("/password/password_xhr_submit.html"); | 541 NavigateToFile("/password/password_xhr_submit.html"); |
561 | 542 |
562 // Verify that if XHR navigation occurs and the form is properly filled out, | 543 // Verify that if XHR navigation occurs and the form is properly filled out, |
563 // we try and save the password even though onsubmit hasn't been called. | 544 // we try and save the password even though onsubmit hasn't been called. |
564 // Specifically verify that the password form saving new passwords is treated | 545 // Specifically verify that the password form saving new passwords is treated |
565 // the same as a login form. | 546 // the same as a login form. |
566 NavigationObserver observer(WebContents()); | 547 NavigationObserver observer(WebContents()); |
567 std::unique_ptr<BubbleObserver> prompt_observer( | 548 std::unique_ptr<BubbleObserver> prompt_observer( |
568 new BubbleObserver(WebContents())); | 549 new BubbleObserver(WebContents())); |
569 std::string fill_and_navigate = | 550 std::string fill_and_navigate = |
570 "document.getElementById('signup_username_field').value = 'temp';" | 551 "document.getElementById('signup_username_field').value = 'temp';" |
571 "document.getElementById('signup_password_field').value = 'random';" | 552 "document.getElementById('signup_password_field').value = 'random';" |
572 "document.getElementById('confirmation_password_field').value = 'random';" | 553 "document.getElementById('confirmation_password_field').value = 'random';" |
573 "send_xhr()"; | 554 "send_xhr()"; |
574 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 555 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
575 observer.Wait(); | 556 observer.Wait(); |
576 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 557 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
577 } | 558 } |
578 | 559 |
579 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 560 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
580 PromptForXHRSubmitWithoutNavigation) { | 561 PromptForXHRSubmitWithoutNavigation) { |
581 NavigateToFile("/password/password_xhr_submit.html"); | 562 NavigateToFile("/password/password_xhr_submit.html"); |
582 | 563 |
583 // 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 |
584 // is no navigation to wait for. | 565 // is no navigation to wait for. |
585 content::DOMMessageQueue message_queue; | 566 content::DOMMessageQueue message_queue; |
586 | 567 |
587 // Verify that if XHR without navigation occurs and the form has been filled | 568 // Verify that if XHR without navigation occurs and the form has been filled |
588 // out we try and save the password. Note that in general the submission | 569 // out we try and save the password. Note that in general the submission |
589 // doesn't need to be via form.submit(), but for testing purposes it's | 570 // doesn't need to be via form.submit(), but for testing purposes it's |
590 // necessary since we otherwise ignore changes made to the value of these | 571 // necessary since we otherwise ignore changes made to the value of these |
591 // fields by script. | 572 // fields by script. |
592 std::unique_ptr<BubbleObserver> prompt_observer( | 573 std::unique_ptr<BubbleObserver> prompt_observer( |
593 new BubbleObserver(WebContents())); | 574 new BubbleObserver(WebContents())); |
594 std::string fill_and_submit = | 575 std::string fill_and_submit = |
595 "navigate = false;" | 576 "navigate = false;" |
596 "document.getElementById('username_field').value = 'temp';" | 577 "document.getElementById('username_field').value = 'temp';" |
597 "document.getElementById('password_field').value = 'random';" | 578 "document.getElementById('password_field').value = 'random';" |
598 "document.getElementById('submit_button').click();"; | 579 "document.getElementById('submit_button').click();"; |
599 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 580 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
600 std::string message; | 581 std::string message; |
601 while (message_queue.WaitForMessage(&message)) { | 582 while (message_queue.WaitForMessage(&message)) { |
602 if (message == "\"XHR_FINISHED\"") | 583 if (message == "\"XHR_FINISHED\"") |
603 break; | 584 break; |
604 } | 585 } |
605 | 586 |
606 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 587 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
607 } | 588 } |
608 | 589 |
609 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 590 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
610 PromptForXHRSubmitWithoutNavigation_SignupForm) { | 591 PromptForXHRSubmitWithoutNavigation_SignupForm) { |
611 NavigateToFile("/password/password_xhr_submit.html"); | 592 NavigateToFile("/password/password_xhr_submit.html"); |
612 | 593 |
613 // Need to pay attention for a message that XHR has finished since there | 594 // Need to pay attention for a message that XHR has finished since there |
614 // is no navigation to wait for. | 595 // is no navigation to wait for. |
615 content::DOMMessageQueue message_queue; | 596 content::DOMMessageQueue message_queue; |
616 | 597 |
(...skipping 10 matching lines...) Expand all Loading... |
627 "document.getElementById('signup_password_field').value = 'random';" | 608 "document.getElementById('signup_password_field').value = 'random';" |
628 "document.getElementById('confirmation_password_field').value = 'random';" | 609 "document.getElementById('confirmation_password_field').value = 'random';" |
629 "document.getElementById('signup_submit_button').click();"; | 610 "document.getElementById('signup_submit_button').click();"; |
630 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 611 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
631 std::string message; | 612 std::string message; |
632 while (message_queue.WaitForMessage(&message)) { | 613 while (message_queue.WaitForMessage(&message)) { |
633 if (message == "\"XHR_FINISHED\"") | 614 if (message == "\"XHR_FINISHED\"") |
634 break; | 615 break; |
635 } | 616 } |
636 | 617 |
637 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 618 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
638 } | 619 } |
639 | 620 |
640 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 621 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
641 NoPromptForXHRSubmitWithoutNavigationWithUnfilledForm) { | 622 NoPromptForXHRSubmitWithoutNavigationWithUnfilledForm) { |
642 NavigateToFile("/password/password_xhr_submit.html"); | 623 NavigateToFile("/password/password_xhr_submit.html"); |
643 | 624 |
644 // Need to pay attention for a message that XHR has finished since there | 625 // Need to pay attention for a message that XHR has finished since there |
645 // is no navigation to wait for. | 626 // is no navigation to wait for. |
646 content::DOMMessageQueue message_queue; | 627 content::DOMMessageQueue message_queue; |
647 | 628 |
648 // Verify that if XHR without navigation occurs and the form has NOT been | 629 // Verify that if XHR without navigation occurs and the form has NOT been |
649 // filled out we don't prompt. | 630 // filled out we don't prompt. |
650 std::unique_ptr<BubbleObserver> prompt_observer( | 631 std::unique_ptr<BubbleObserver> prompt_observer( |
651 new BubbleObserver(WebContents())); | 632 new BubbleObserver(WebContents())); |
652 std::string fill_and_submit = | 633 std::string fill_and_submit = |
653 "navigate = false;" | 634 "navigate = false;" |
654 "document.getElementById('username_field').value = 'temp';" | 635 "document.getElementById('username_field').value = 'temp';" |
655 "document.getElementById('submit_button').click();"; | 636 "document.getElementById('submit_button').click();"; |
656 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 637 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
657 std::string message; | 638 std::string message; |
658 while (message_queue.WaitForMessage(&message)) { | 639 while (message_queue.WaitForMessage(&message)) { |
659 if (message == "\"XHR_FINISHED\"") | 640 if (message == "\"XHR_FINISHED\"") |
660 break; | 641 break; |
661 } | 642 } |
662 | 643 |
663 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 644 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
664 } | 645 } |
665 | 646 |
666 IN_PROC_BROWSER_TEST_F( | 647 IN_PROC_BROWSER_TEST_F( |
667 PasswordManagerBrowserTestBase, | 648 PasswordManagerBrowserTestBase, |
668 NoPromptForXHRSubmitWithoutNavigationWithUnfilledForm_SignupForm) { | 649 NoPromptForXHRSubmitWithoutNavigationWithUnfilledForm_SignupForm) { |
669 NavigateToFile("/password/password_xhr_submit.html"); | 650 NavigateToFile("/password/password_xhr_submit.html"); |
670 | 651 |
671 // Need to pay attention for a message that XHR has finished since there | 652 // Need to pay attention for a message that XHR has finished since there |
672 // is no navigation to wait for. | 653 // is no navigation to wait for. |
673 content::DOMMessageQueue message_queue; | 654 content::DOMMessageQueue message_queue; |
674 | 655 |
675 // Verify that if XHR without navigation occurs and the form has NOT been | 656 // Verify that if XHR without navigation occurs and the form has NOT been |
676 // filled out we don't prompt. | 657 // filled out we don't prompt. |
677 std::unique_ptr<BubbleObserver> prompt_observer( | 658 std::unique_ptr<BubbleObserver> prompt_observer( |
678 new BubbleObserver(WebContents())); | 659 new BubbleObserver(WebContents())); |
679 std::string fill_and_submit = | 660 std::string fill_and_submit = |
680 "navigate = false;" | 661 "navigate = false;" |
681 "document.getElementById('signup_username_field').value = 'temp';" | 662 "document.getElementById('signup_username_field').value = 'temp';" |
682 "document.getElementById('signup_submit_button').click();"; | 663 "document.getElementById('signup_submit_button').click();"; |
683 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 664 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
684 std::string message; | 665 std::string message; |
685 while (message_queue.WaitForMessage(&message)) { | 666 while (message_queue.WaitForMessage(&message)) { |
686 if (message == "\"XHR_FINISHED\"") | 667 if (message == "\"XHR_FINISHED\"") |
687 break; | 668 break; |
688 } | 669 } |
689 | 670 |
690 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 671 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
691 } | 672 } |
692 | 673 |
693 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForFetchSubmit) { | 674 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, PromptForFetchSubmit) { |
694 NavigateToFile("/password/password_fetch_submit.html"); | 675 NavigateToFile("/password/password_fetch_submit.html"); |
695 | 676 |
696 // Verify that we show the save password prompt if a form returns false | 677 // Verify that we show the save password prompt if a form returns false |
697 // in its onsubmit handler but instead logs in/navigates via Fetch. | 678 // in its onsubmit handler but instead logs in/navigates via Fetch. |
698 // Note that calling 'submit()' on a form with javascript doesn't call | 679 // Note that calling 'submit()' on a form with javascript doesn't call |
699 // the onsubmit handler, so we click the submit button instead. | 680 // the onsubmit handler, so we click the submit button instead. |
700 NavigationObserver observer(WebContents()); | 681 NavigationObserver observer(WebContents()); |
701 std::unique_ptr<BubbleObserver> prompt_observer( | 682 std::unique_ptr<BubbleObserver> prompt_observer( |
702 new BubbleObserver(WebContents())); | 683 new BubbleObserver(WebContents())); |
703 std::string fill_and_submit = | 684 std::string fill_and_submit = |
704 "document.getElementById('username_field').value = 'temp';" | 685 "document.getElementById('username_field').value = 'temp';" |
705 "document.getElementById('password_field').value = 'random';" | 686 "document.getElementById('password_field').value = 'random';" |
706 "document.getElementById('submit_button').click()"; | 687 "document.getElementById('submit_button').click()"; |
707 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 688 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
708 observer.Wait(); | 689 observer.Wait(); |
709 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 690 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
710 } | 691 } |
711 | 692 |
712 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 693 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
713 PromptForFetchWithoutOnSubmit) { | 694 PromptForFetchWithoutOnSubmit) { |
714 NavigateToFile("/password/password_fetch_submit.html"); | 695 NavigateToFile("/password/password_fetch_submit.html"); |
715 | 696 |
716 // Verify that if Fetch navigation occurs and the form is properly filled out, | 697 // Verify that if Fetch navigation occurs and the form is properly filled out, |
717 // we try and save the password even though onsubmit hasn't been called. | 698 // we try and save the password even though onsubmit hasn't been called. |
718 NavigationObserver observer(WebContents()); | 699 NavigationObserver observer(WebContents()); |
719 std::unique_ptr<BubbleObserver> prompt_observer( | 700 std::unique_ptr<BubbleObserver> prompt_observer( |
720 new BubbleObserver(WebContents())); | 701 new BubbleObserver(WebContents())); |
721 std::string fill_and_navigate = | 702 std::string fill_and_navigate = |
722 "document.getElementById('username_field').value = 'temp';" | 703 "document.getElementById('username_field').value = 'temp';" |
723 "document.getElementById('password_field').value = 'random';" | 704 "document.getElementById('password_field').value = 'random';" |
724 "send_fetch()"; | 705 "send_fetch()"; |
725 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 706 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
726 observer.Wait(); | 707 observer.Wait(); |
727 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 708 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
728 } | 709 } |
729 | 710 |
730 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 711 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
731 PromptForFetchWithNewPasswordsWithoutOnSubmit) { | 712 PromptForFetchWithNewPasswordsWithoutOnSubmit) { |
732 NavigateToFile("/password/password_fetch_submit.html"); | 713 NavigateToFile("/password/password_fetch_submit.html"); |
733 | 714 |
734 // Verify that if Fetch navigation occurs and the form is properly filled out, | 715 // Verify that if Fetch navigation occurs and the form is properly filled out, |
735 // we try and save the password even though onsubmit hasn't been called. | 716 // we try and save the password even though onsubmit hasn't been called. |
736 // Specifically verify that the password form saving new passwords is treated | 717 // Specifically verify that the password form saving new passwords is treated |
737 // the same as a login form. | 718 // the same as a login form. |
738 NavigationObserver observer(WebContents()); | 719 NavigationObserver observer(WebContents()); |
739 std::unique_ptr<BubbleObserver> prompt_observer( | 720 std::unique_ptr<BubbleObserver> prompt_observer( |
740 new BubbleObserver(WebContents())); | 721 new BubbleObserver(WebContents())); |
741 std::string fill_and_navigate = | 722 std::string fill_and_navigate = |
742 "document.getElementById('signup_username_field').value = 'temp';" | 723 "document.getElementById('signup_username_field').value = 'temp';" |
743 "document.getElementById('signup_password_field').value = 'random';" | 724 "document.getElementById('signup_password_field').value = 'random';" |
744 "document.getElementById('confirmation_password_field').value = 'random';" | 725 "document.getElementById('confirmation_password_field').value = 'random';" |
745 "send_fetch()"; | 726 "send_fetch()"; |
746 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); | 727 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); |
747 observer.Wait(); | 728 observer.Wait(); |
748 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 729 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
749 } | 730 } |
750 | 731 |
751 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 732 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
752 PromptForFetchSubmitWithoutNavigation) { | 733 PromptForFetchSubmitWithoutNavigation) { |
753 NavigateToFile("/password/password_fetch_submit.html"); | 734 NavigateToFile("/password/password_fetch_submit.html"); |
754 | 735 |
755 // Need to pay attention for a message that XHR has finished since there | 736 // Need to pay attention for a message that XHR has finished since there |
756 // is no navigation to wait for. | 737 // is no navigation to wait for. |
757 content::DOMMessageQueue message_queue; | 738 content::DOMMessageQueue message_queue; |
758 | 739 |
759 // Verify that if XHR without navigation occurs and the form has been filled | 740 // Verify that if XHR without navigation occurs and the form has been filled |
760 // out we try and save the password. Note that in general the submission | 741 // out we try and save the password. Note that in general the submission |
761 // doesn't need to be via form.submit(), but for testing purposes it's | 742 // doesn't need to be via form.submit(), but for testing purposes it's |
762 // necessary since we otherwise ignore changes made to the value of these | 743 // necessary since we otherwise ignore changes made to the value of these |
763 // fields by script. | 744 // fields by script. |
764 std::unique_ptr<BubbleObserver> prompt_observer( | 745 std::unique_ptr<BubbleObserver> prompt_observer( |
765 new BubbleObserver(WebContents())); | 746 new BubbleObserver(WebContents())); |
766 std::string fill_and_submit = | 747 std::string fill_and_submit = |
767 "navigate = false;" | 748 "navigate = false;" |
768 "document.getElementById('username_field').value = 'temp';" | 749 "document.getElementById('username_field').value = 'temp';" |
769 "document.getElementById('password_field').value = 'random';" | 750 "document.getElementById('password_field').value = 'random';" |
770 "document.getElementById('submit_button').click();"; | 751 "document.getElementById('submit_button').click();"; |
771 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 752 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
772 std::string message; | 753 std::string message; |
773 while (message_queue.WaitForMessage(&message)) { | 754 while (message_queue.WaitForMessage(&message)) { |
774 if (message == "\"FETCH_FINISHED\"") | 755 if (message == "\"FETCH_FINISHED\"") |
775 break; | 756 break; |
776 } | 757 } |
777 | 758 |
778 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 759 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
779 } | 760 } |
780 | 761 |
781 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 762 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
782 PromptForFetchSubmitWithoutNavigation_SignupForm) { | 763 PromptForFetchSubmitWithoutNavigation_SignupForm) { |
783 NavigateToFile("/password/password_fetch_submit.html"); | 764 NavigateToFile("/password/password_fetch_submit.html"); |
784 | 765 |
785 // Need to pay attention for a message that Fetch has finished since there | 766 // Need to pay attention for a message that Fetch has finished since there |
786 // is no navigation to wait for. | 767 // is no navigation to wait for. |
787 content::DOMMessageQueue message_queue; | 768 content::DOMMessageQueue message_queue; |
788 | 769 |
(...skipping 10 matching lines...) Expand all Loading... |
799 "document.getElementById('signup_password_field').value = 'random';" | 780 "document.getElementById('signup_password_field').value = 'random';" |
800 "document.getElementById('confirmation_password_field').value = 'random';" | 781 "document.getElementById('confirmation_password_field').value = 'random';" |
801 "document.getElementById('signup_submit_button').click();"; | 782 "document.getElementById('signup_submit_button').click();"; |
802 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 783 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
803 std::string message; | 784 std::string message; |
804 while (message_queue.WaitForMessage(&message)) { | 785 while (message_queue.WaitForMessage(&message)) { |
805 if (message == "\"FETCH_FINISHED\"") | 786 if (message == "\"FETCH_FINISHED\"") |
806 break; | 787 break; |
807 } | 788 } |
808 | 789 |
809 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 790 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
810 } | 791 } |
811 | 792 |
812 IN_PROC_BROWSER_TEST_F( | 793 IN_PROC_BROWSER_TEST_F( |
813 PasswordManagerBrowserTestBase, | 794 PasswordManagerBrowserTestBase, |
814 NoPromptForFetchSubmitWithoutNavigationWithUnfilledForm) { | 795 NoPromptForFetchSubmitWithoutNavigationWithUnfilledForm) { |
815 NavigateToFile("/password/password_fetch_submit.html"); | 796 NavigateToFile("/password/password_fetch_submit.html"); |
816 | 797 |
817 // Need to pay attention for a message that Fetch has finished since there | 798 // Need to pay attention for a message that Fetch has finished since there |
818 // is no navigation to wait for. | 799 // is no navigation to wait for. |
819 content::DOMMessageQueue message_queue; | 800 content::DOMMessageQueue message_queue; |
820 | 801 |
821 // Verify that if Fetch without navigation occurs and the form has NOT been | 802 // Verify that if Fetch without navigation occurs and the form has NOT been |
822 // filled out we don't prompt. | 803 // filled out we don't prompt. |
823 std::unique_ptr<BubbleObserver> prompt_observer( | 804 std::unique_ptr<BubbleObserver> prompt_observer( |
824 new BubbleObserver(WebContents())); | 805 new BubbleObserver(WebContents())); |
825 std::string fill_and_submit = | 806 std::string fill_and_submit = |
826 "navigate = false;" | 807 "navigate = false;" |
827 "document.getElementById('username_field').value = 'temp';" | 808 "document.getElementById('username_field').value = 'temp';" |
828 "document.getElementById('submit_button').click();"; | 809 "document.getElementById('submit_button').click();"; |
829 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 810 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
830 std::string message; | 811 std::string message; |
831 while (message_queue.WaitForMessage(&message)) { | 812 while (message_queue.WaitForMessage(&message)) { |
832 if (message == "\"FETCH_FINISHED\"") | 813 if (message == "\"FETCH_FINISHED\"") |
833 break; | 814 break; |
834 } | 815 } |
835 | 816 |
836 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 817 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
837 } | 818 } |
838 | 819 |
839 IN_PROC_BROWSER_TEST_F( | 820 IN_PROC_BROWSER_TEST_F( |
840 PasswordManagerBrowserTestBase, | 821 PasswordManagerBrowserTestBase, |
841 NoPromptForFetchSubmitWithoutNavigationWithUnfilledForm_SignupForm) { | 822 NoPromptForFetchSubmitWithoutNavigationWithUnfilledForm_SignupForm) { |
842 NavigateToFile("/password/password_fetch_submit.html"); | 823 NavigateToFile("/password/password_fetch_submit.html"); |
843 | 824 |
844 // Need to pay attention for a message that Fetch has finished since there | 825 // Need to pay attention for a message that Fetch has finished since there |
845 // is no navigation to wait for. | 826 // is no navigation to wait for. |
846 content::DOMMessageQueue message_queue; | 827 content::DOMMessageQueue message_queue; |
847 | 828 |
848 // Verify that if Fetch without navigation occurs and the form has NOT been | 829 // Verify that if Fetch without navigation occurs and the form has NOT been |
849 // filled out we don't prompt. | 830 // filled out we don't prompt. |
850 std::unique_ptr<BubbleObserver> prompt_observer( | 831 std::unique_ptr<BubbleObserver> prompt_observer( |
851 new BubbleObserver(WebContents())); | 832 new BubbleObserver(WebContents())); |
852 std::string fill_and_submit = | 833 std::string fill_and_submit = |
853 "navigate = false;" | 834 "navigate = false;" |
854 "document.getElementById('signup_username_field').value = 'temp';" | 835 "document.getElementById('signup_username_field').value = 'temp';" |
855 "document.getElementById('signup_submit_button').click();"; | 836 "document.getElementById('signup_submit_button').click();"; |
856 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 837 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
857 std::string message; | 838 std::string message; |
858 while (message_queue.WaitForMessage(&message)) { | 839 while (message_queue.WaitForMessage(&message)) { |
859 if (message == "\"FETCH_FINISHED\"") | 840 if (message == "\"FETCH_FINISHED\"") |
860 break; | 841 break; |
861 } | 842 } |
862 | 843 |
863 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 844 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
864 } | 845 } |
865 | 846 |
866 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptIfLinkClicked) { | 847 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptIfLinkClicked) { |
867 NavigateToFile("/password/password_form.html"); | 848 NavigateToFile("/password/password_form.html"); |
868 | 849 |
869 // Verify that if the user takes a direct action to leave the page, we don't | 850 // Verify that if the user takes a direct action to leave the page, we don't |
870 // prompt to save the password even if the form is already filled out. | 851 // prompt to save the password even if the form is already filled out. |
871 NavigationObserver observer(WebContents()); | 852 NavigationObserver observer(WebContents()); |
872 std::unique_ptr<BubbleObserver> prompt_observer( | 853 std::unique_ptr<BubbleObserver> prompt_observer( |
873 new BubbleObserver(WebContents())); | 854 new BubbleObserver(WebContents())); |
874 std::string fill_and_click_link = | 855 std::string fill_and_click_link = |
875 "document.getElementById('username_field').value = 'temp';" | 856 "document.getElementById('username_field').value = 'temp';" |
876 "document.getElementById('password_field').value = 'random';" | 857 "document.getElementById('password_field').value = 'random';" |
877 "document.getElementById('link').click();"; | 858 "document.getElementById('link').click();"; |
878 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_click_link)); | 859 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_click_link)); |
879 observer.Wait(); | 860 observer.Wait(); |
880 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 861 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
881 } | 862 } |
882 | 863 |
883 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 864 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
884 VerifyPasswordGenerationUpload) { | 865 VerifyPasswordGenerationUpload) { |
885 // Prevent Autofill requests from actually going over the wire. | 866 // Prevent Autofill requests from actually going over the wire. |
886 net::TestURLFetcherFactory factory; | 867 net::TestURLFetcherFactory factory; |
887 // Disable Autofill requesting access to AddressBook data. This causes | 868 // Disable Autofill requesting access to AddressBook data. This causes |
888 // the test to hang on Mac. | 869 // the test to hang on Mac. |
889 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs()); | 870 autofill::test::DisableSystemServices(browser()->profile()->GetPrefs()); |
890 | 871 |
891 // Visit a signup form. | 872 // Visit a signup form. |
892 NavigateToFile("/password/signup_form.html"); | 873 NavigateToFile("/password/signup_form.html"); |
893 | 874 |
894 // Enter a password and save it. | 875 // Enter a password and save it. |
895 NavigationObserver first_observer(WebContents()); | 876 NavigationObserver first_observer(WebContents()); |
896 std::unique_ptr<BubbleObserver> prompt_observer( | 877 std::unique_ptr<BubbleObserver> prompt_observer( |
897 new BubbleObserver(WebContents())); | 878 new BubbleObserver(WebContents())); |
898 std::string fill_and_submit = | 879 std::string fill_and_submit = |
899 "document.getElementById('other_info').value = 'stuff';" | 880 "document.getElementById('other_info').value = 'stuff';" |
900 "document.getElementById('username_field').value = 'my_username';" | 881 "document.getElementById('username_field').value = 'my_username';" |
901 "document.getElementById('password_field').value = 'password';" | 882 "document.getElementById('password_field').value = 'password';" |
902 "document.getElementById('input_submit_button').click()"; | 883 "document.getElementById('input_submit_button').click()"; |
903 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 884 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
904 | 885 |
905 first_observer.Wait(); | 886 first_observer.Wait(); |
906 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 887 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
907 prompt_observer->AcceptSavePrompt(); | 888 prompt_observer->AcceptSavePrompt(); |
908 | 889 |
909 // Now navigate to a login form that has similar HTML markup. | 890 // Now navigate to a login form that has similar HTML markup. |
910 NavigateToFile("/password/password_form.html"); | 891 NavigateToFile("/password/password_form.html"); |
911 | 892 |
912 // Simulate a user click to force an autofill of the form's DOM value, not | 893 // Simulate a user click to force an autofill of the form's DOM value, not |
913 // just the suggested value. | 894 // just the suggested value. |
914 content::SimulateMouseClick(WebContents(), 0, | 895 content::SimulateMouseClick(WebContents(), 0, |
915 blink::WebMouseEvent::Button::kLeft); | 896 blink::WebMouseEvent::Button::kLeft); |
916 | 897 |
917 // The form should be filled with the previously submitted username. | 898 // The form should be filled with the previously submitted username. |
918 CheckElementValue("username_field", "my_username"); | 899 CheckElementValue("username_field", "my_username"); |
919 CheckElementValue("password_field", "password"); | 900 CheckElementValue("password_field", "password"); |
920 | 901 |
921 // Submit the form and verify that there is no infobar (as the password | 902 // Submit the form and verify that there is no infobar (as the password |
922 // has already been saved). | 903 // has already been saved). |
923 NavigationObserver second_observer(WebContents()); | 904 NavigationObserver second_observer(WebContents()); |
924 std::unique_ptr<BubbleObserver> second_prompt_observer( | 905 std::unique_ptr<BubbleObserver> second_prompt_observer( |
925 new BubbleObserver(WebContents())); | 906 new BubbleObserver(WebContents())); |
926 std::string submit_form = | 907 std::string submit_form = |
927 "document.getElementById('input_submit_button').click()"; | 908 "document.getElementById('input_submit_button').click()"; |
928 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit_form)); | 909 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit_form)); |
929 second_observer.Wait(); | 910 second_observer.Wait(); |
930 EXPECT_FALSE(second_prompt_observer->IsShowingSavePrompt()); | 911 EXPECT_FALSE(second_prompt_observer->IsSavePromptShownAutomatically()); |
931 | 912 |
932 // Verify that we sent two pings to Autofill. One vote for of PASSWORD for | 913 // Verify that we sent two pings to Autofill. One vote for of PASSWORD for |
933 // the current form, and one vote for ACCOUNT_CREATION_PASSWORD on the | 914 // the current form, and one vote for ACCOUNT_CREATION_PASSWORD on the |
934 // original form since it has more than 2 text input fields and was used for | 915 // original form since it has more than 2 text input fields and was used for |
935 // the first time on a different form. | 916 // the first time on a different form. |
936 base::HistogramBase* upload_histogram = | 917 base::HistogramBase* upload_histogram = |
937 base::StatisticsRecorder::FindHistogram( | 918 base::StatisticsRecorder::FindHistogram( |
938 "PasswordGeneration.UploadStarted"); | 919 "PasswordGeneration.UploadStarted"); |
939 ASSERT_TRUE(upload_histogram); | 920 ASSERT_TRUE(upload_histogram); |
940 std::unique_ptr<base::HistogramSamples> snapshot = | 921 std::unique_ptr<base::HistogramSamples> snapshot = |
(...skipping 16 matching lines...) Expand all Loading... |
957 new BubbleObserver(WebContents())); | 938 new BubbleObserver(WebContents())); |
958 std::string fill_and_submit = | 939 std::string fill_and_submit = |
959 "var iframe = document.getElementById('test_iframe');" | 940 "var iframe = document.getElementById('test_iframe');" |
960 "var iframe_doc = iframe.contentDocument;" | 941 "var iframe_doc = iframe.contentDocument;" |
961 "iframe_doc.getElementById('username_field').value = 'temp';" | 942 "iframe_doc.getElementById('username_field').value = 'temp';" |
962 "iframe_doc.getElementById('password_field').value = 'random';" | 943 "iframe_doc.getElementById('password_field').value = 'random';" |
963 "iframe_doc.getElementById('submit_button').click()"; | 944 "iframe_doc.getElementById('submit_button').click()"; |
964 | 945 |
965 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 946 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
966 observer.Wait(); | 947 observer.Wait(); |
967 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 948 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
968 } | 949 } |
969 | 950 |
970 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 951 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
971 PromptForInputElementWithoutName) { | 952 PromptForInputElementWithoutName) { |
972 // Check that the prompt is shown for forms where input elements lack the | 953 // Check that the prompt is shown for forms where input elements lack the |
973 // "name" attribute but the "id" is present. | 954 // "name" attribute but the "id" is present. |
974 NavigateToFile("/password/password_form.html"); | 955 NavigateToFile("/password/password_form.html"); |
975 | 956 |
976 NavigationObserver observer(WebContents()); | 957 NavigationObserver observer(WebContents()); |
977 std::unique_ptr<BubbleObserver> prompt_observer( | 958 std::unique_ptr<BubbleObserver> prompt_observer( |
978 new BubbleObserver(WebContents())); | 959 new BubbleObserver(WebContents())); |
979 std::string fill_and_submit = | 960 std::string fill_and_submit = |
980 "document.getElementById('username_field_no_name').value = 'temp';" | 961 "document.getElementById('username_field_no_name').value = 'temp';" |
981 "document.getElementById('password_field_no_name').value = 'random';" | 962 "document.getElementById('password_field_no_name').value = 'random';" |
982 "document.getElementById('input_submit_button_no_name').click()"; | 963 "document.getElementById('input_submit_button_no_name').click()"; |
983 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 964 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
984 observer.Wait(); | 965 observer.Wait(); |
985 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 966 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
986 } | 967 } |
987 | 968 |
988 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 969 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
989 PromptForInputElementWithoutId) { | 970 PromptForInputElementWithoutId) { |
990 // Check that the prompt is shown for forms where input elements lack the | 971 // Check that the prompt is shown for forms where input elements lack the |
991 // "id" attribute but the "name" attribute is present. | 972 // "id" attribute but the "name" attribute is present. |
992 NavigateToFile("/password/password_form.html"); | 973 NavigateToFile("/password/password_form.html"); |
993 | 974 |
994 NavigationObserver observer(WebContents()); | 975 NavigationObserver observer(WebContents()); |
995 std::unique_ptr<BubbleObserver> prompt_observer( | 976 std::unique_ptr<BubbleObserver> prompt_observer( |
996 new BubbleObserver(WebContents())); | 977 new BubbleObserver(WebContents())); |
997 std::string fill_and_submit = | 978 std::string fill_and_submit = |
998 "document.getElementsByName('username_field_no_id')[0].value = 'temp';" | 979 "document.getElementsByName('username_field_no_id')[0].value = 'temp';" |
999 "document.getElementsByName('password_field_no_id')[0].value = 'random';" | 980 "document.getElementsByName('password_field_no_id')[0].value = 'random';" |
1000 "document.getElementsByName('input_submit_button_no_id')[0].click()"; | 981 "document.getElementsByName('input_submit_button_no_id')[0].click()"; |
1001 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 982 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1002 observer.Wait(); | 983 observer.Wait(); |
1003 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 984 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1004 } | 985 } |
1005 | 986 |
1006 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 987 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1007 PromptForInputElementWithoutIdAndName) { | 988 PromptForInputElementWithoutIdAndName) { |
1008 // Check that prompt is shown for forms where the input fields lack both | 989 // Check that prompt is shown for forms where the input fields lack both |
1009 // the "id" and the "name" attributes. | 990 // the "id" and the "name" attributes. |
1010 NavigateToFile("/password/password_form.html"); | 991 NavigateToFile("/password/password_form.html"); |
1011 | 992 |
1012 NavigationObserver observer(WebContents()); | 993 NavigationObserver observer(WebContents()); |
1013 std::unique_ptr<BubbleObserver> prompt_observer( | 994 std::unique_ptr<BubbleObserver> prompt_observer( |
1014 new BubbleObserver(WebContents())); | 995 new BubbleObserver(WebContents())); |
1015 std::string fill_and_submit = | 996 std::string fill_and_submit = |
1016 "var form = document.getElementById('testform_elements_no_id_no_name');" | 997 "var form = document.getElementById('testform_elements_no_id_no_name');" |
1017 "var username = form.children[0];" | 998 "var username = form.children[0];" |
1018 "username.value = 'temp';" | 999 "username.value = 'temp';" |
1019 "var password = form.children[1];" | 1000 "var password = form.children[1];" |
1020 "password.value = 'random';" | 1001 "password.value = 'random';" |
1021 "form.children[2].click()"; // form.children[2] is the submit button. | 1002 "form.children[2].click()"; // form.children[2] is the submit button. |
1022 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1003 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1023 observer.Wait(); | 1004 observer.Wait(); |
1024 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1005 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1025 prompt_observer->AcceptSavePrompt(); | 1006 prompt_observer->AcceptSavePrompt(); |
1026 | 1007 |
1027 // Check that credentials are stored. | 1008 // Check that credentials are stored. |
1028 scoped_refptr<password_manager::TestPasswordStore> password_store = | |
1029 static_cast<password_manager::TestPasswordStore*>( | |
1030 PasswordStoreFactory::GetForProfile( | |
1031 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
1032 .get()); | |
1033 | |
1034 WaitForPasswordStore(); | 1009 WaitForPasswordStore(); |
1035 EXPECT_FALSE(password_store->IsEmpty()); | 1010 CheckThatCredentialsStored(base::ASCIIToUTF16("temp"), |
1036 | |
1037 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | |
1038 base::ASCIIToUTF16("random")); | 1011 base::ASCIIToUTF16("random")); |
1039 } | 1012 } |
1040 | 1013 |
1041 // Test for checking that no prompt is shown for URLs with file: scheme. | 1014 // Test for checking that no prompt is shown for URLs with file: scheme. |
1042 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1015 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1043 NoPromptForFileSchemeURLs) { | 1016 NoPromptForFileSchemeURLs) { |
1044 GURL url = GetFileURL("password_form.html"); | 1017 GURL url = GetFileURL("password_form.html"); |
1045 ui_test_utils::NavigateToURL(browser(), url); | 1018 ui_test_utils::NavigateToURL(browser(), url); |
1046 | 1019 |
1047 NavigationObserver observer(WebContents()); | 1020 NavigationObserver observer(WebContents()); |
1048 std::unique_ptr<BubbleObserver> prompt_observer( | 1021 std::unique_ptr<BubbleObserver> prompt_observer( |
1049 new BubbleObserver(WebContents())); | 1022 new BubbleObserver(WebContents())); |
1050 std::string fill_and_submit = | 1023 std::string fill_and_submit = |
1051 "document.getElementById('username_field').value = 'temp';" | 1024 "document.getElementById('username_field').value = 'temp';" |
1052 "document.getElementById('password_field').value = 'random';" | 1025 "document.getElementById('password_field').value = 'random';" |
1053 "document.getElementById('input_submit_button').click();"; | 1026 "document.getElementById('input_submit_button').click();"; |
1054 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1027 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1055 observer.Wait(); | 1028 observer.Wait(); |
1056 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1029 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1057 } | 1030 } |
1058 | 1031 |
1059 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1032 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1060 NoPromptForLandingPageWithHTTPErrorStatusCode) { | 1033 NoPromptForLandingPageWithHTTPErrorStatusCode) { |
1061 // Check that no prompt is shown for forms where the landing page has | 1034 // Check that no prompt is shown for forms where the landing page has |
1062 // HTTP status 404. | 1035 // HTTP status 404. |
1063 NavigateToFile("/password/password_form.html"); | 1036 NavigateToFile("/password/password_form.html"); |
1064 | 1037 |
1065 NavigationObserver observer(WebContents()); | 1038 NavigationObserver observer(WebContents()); |
1066 std::unique_ptr<BubbleObserver> prompt_observer( | 1039 std::unique_ptr<BubbleObserver> prompt_observer( |
1067 new BubbleObserver(WebContents())); | 1040 new BubbleObserver(WebContents())); |
1068 std::string fill_and_submit = | 1041 std::string fill_and_submit = |
1069 "document.getElementById('username_field_http_error').value = 'temp';" | 1042 "document.getElementById('username_field_http_error').value = 'temp';" |
1070 "document.getElementById('password_field_http_error').value = 'random';" | 1043 "document.getElementById('password_field_http_error').value = 'random';" |
1071 "document.getElementById('input_submit_button_http_error').click()"; | 1044 "document.getElementById('input_submit_button_http_error').click()"; |
1072 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1045 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1073 observer.Wait(); | 1046 observer.Wait(); |
1074 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1047 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1075 } | 1048 } |
1076 | 1049 |
1077 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1050 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1078 DeleteFrameBeforeSubmit) { | 1051 DeleteFrameBeforeSubmit) { |
1079 NavigateToFile("/password/multi_frames.html"); | 1052 NavigateToFile("/password/multi_frames.html"); |
1080 | 1053 |
1081 NavigationObserver observer(WebContents()); | 1054 NavigationObserver observer(WebContents()); |
1082 // Make sure we save some password info from an iframe and then destroy it. | 1055 // Make sure we save some password info from an iframe and then destroy it. |
1083 std::string save_and_remove = | 1056 std::string save_and_remove = |
1084 "var first_frame = document.getElementById('first_frame');" | 1057 "var first_frame = document.getElementById('first_frame');" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 DontPromptForPasswordFormWithDefaultValue) { | 1168 DontPromptForPasswordFormWithDefaultValue) { |
1196 NavigateToFile("/password/password_form_with_default_value.html"); | 1169 NavigateToFile("/password/password_form_with_default_value.html"); |
1197 | 1170 |
1198 // Don't prompt if we navigate away even if there is a password value since | 1171 // Don't prompt if we navigate away even if there is a password value since |
1199 // it's not coming from the user. | 1172 // it's not coming from the user. |
1200 NavigationObserver observer(WebContents()); | 1173 NavigationObserver observer(WebContents()); |
1201 std::unique_ptr<BubbleObserver> prompt_observer( | 1174 std::unique_ptr<BubbleObserver> prompt_observer( |
1202 new BubbleObserver(WebContents())); | 1175 new BubbleObserver(WebContents())); |
1203 NavigateToFile("/password/done.html"); | 1176 NavigateToFile("/password/done.html"); |
1204 observer.Wait(); | 1177 observer.Wait(); |
1205 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1178 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1206 } | 1179 } |
1207 | 1180 |
1208 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1181 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1209 DontPromptForPasswordFormWithReadonlyPasswordField) { | 1182 DontPromptForPasswordFormWithReadonlyPasswordField) { |
1210 NavigateToFile("/password/password_form_with_password_readonly.html"); | 1183 NavigateToFile("/password/password_form_with_password_readonly.html"); |
1211 | 1184 |
1212 // Fill a form and submit through a <input type="submit"> button. Nothing | 1185 // Fill a form and submit through a <input type="submit"> button. Nothing |
1213 // special. | 1186 // special. |
1214 NavigationObserver observer(WebContents()); | 1187 NavigationObserver observer(WebContents()); |
1215 std::unique_ptr<BubbleObserver> prompt_observer( | 1188 std::unique_ptr<BubbleObserver> prompt_observer( |
1216 new BubbleObserver(WebContents())); | 1189 new BubbleObserver(WebContents())); |
1217 std::string fill_and_submit = | 1190 std::string fill_and_submit = |
1218 "document.getElementById('username_field').value = 'temp';" | 1191 "document.getElementById('username_field').value = 'temp';" |
1219 "document.getElementById('password_field').value = 'random';" | 1192 "document.getElementById('password_field').value = 'random';" |
1220 "document.getElementById('input_submit_button').click()"; | 1193 "document.getElementById('input_submit_button').click()"; |
1221 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1194 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1222 observer.Wait(); | 1195 observer.Wait(); |
1223 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1196 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1224 } | 1197 } |
1225 | 1198 |
1226 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1199 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1227 PromptWhenEnableAutomaticPasswordSavingSwitchIsNotSet) { | 1200 PromptWhenEnableAutomaticPasswordSavingSwitchIsNotSet) { |
1228 NavigateToFile("/password/password_form.html"); | 1201 NavigateToFile("/password/password_form.html"); |
1229 | 1202 |
1230 // Fill a form and submit through a <input type="submit"> button. | 1203 // Fill a form and submit through a <input type="submit"> button. |
1231 NavigationObserver observer(WebContents()); | 1204 NavigationObserver observer(WebContents()); |
1232 std::unique_ptr<BubbleObserver> prompt_observer( | 1205 std::unique_ptr<BubbleObserver> prompt_observer( |
1233 new BubbleObserver(WebContents())); | 1206 new BubbleObserver(WebContents())); |
1234 std::string fill_and_submit = | 1207 std::string fill_and_submit = |
1235 "document.getElementById('username_field').value = 'temp';" | 1208 "document.getElementById('username_field').value = 'temp';" |
1236 "document.getElementById('password_field').value = 'random';" | 1209 "document.getElementById('password_field').value = 'random';" |
1237 "document.getElementById('input_submit_button').click()"; | 1210 "document.getElementById('input_submit_button').click()"; |
1238 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1211 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1239 observer.Wait(); | 1212 observer.Wait(); |
1240 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1213 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1241 } | 1214 } |
1242 | 1215 |
1243 // Test fix for crbug.com/368690. | 1216 // Test fix for crbug.com/368690. |
1244 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptWhenReloading) { | 1217 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptWhenReloading) { |
1245 NavigateToFile("/password/password_form.html"); | 1218 NavigateToFile("/password/password_form.html"); |
1246 | 1219 |
1247 std::string fill = | 1220 std::string fill = |
1248 "document.getElementById('username_redirect').value = 'temp';" | 1221 "document.getElementById('username_redirect').value = 'temp';" |
1249 "document.getElementById('password_redirect').value = 'random';"; | 1222 "document.getElementById('password_redirect').value = 'random';"; |
1250 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); | 1223 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill)); |
1251 | 1224 |
1252 NavigationObserver observer(WebContents()); | 1225 NavigationObserver observer(WebContents()); |
1253 std::unique_ptr<BubbleObserver> prompt_observer( | 1226 std::unique_ptr<BubbleObserver> prompt_observer( |
1254 new BubbleObserver(WebContents())); | 1227 new BubbleObserver(WebContents())); |
1255 GURL url = embedded_test_server()->GetURL("/password/password_form.html"); | 1228 GURL url = embedded_test_server()->GetURL("/password/password_form.html"); |
1256 chrome::NavigateParams params(browser(), url, ::ui::PAGE_TRANSITION_RELOAD); | 1229 chrome::NavigateParams params(browser(), url, ::ui::PAGE_TRANSITION_RELOAD); |
1257 ui_test_utils::NavigateToURL(¶ms); | 1230 ui_test_utils::NavigateToURL(¶ms); |
1258 observer.Wait(); | 1231 observer.Wait(); |
1259 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1232 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1260 } | 1233 } |
1261 | 1234 |
1262 // Test that if a form gets dynamically added between the form parsing and | 1235 // Test that if a form gets dynamically added between the form parsing and |
1263 // rendering, and while the main frame still loads, it still is registered, and | 1236 // rendering, and while the main frame still loads, it still is registered, and |
1264 // thus saving passwords from it works. | 1237 // thus saving passwords from it works. |
1265 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1238 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1266 FormsAddedBetweenParsingAndRendering) { | 1239 FormsAddedBetweenParsingAndRendering) { |
1267 NavigateToFile("/password/between_parsing_and_rendering.html"); | 1240 NavigateToFile("/password/between_parsing_and_rendering.html"); |
1268 | 1241 |
1269 NavigationObserver observer(WebContents()); | 1242 NavigationObserver observer(WebContents()); |
1270 std::string submit = | 1243 std::string submit = |
1271 "document.getElementById('username').value = 'temp';" | 1244 "document.getElementById('username').value = 'temp';" |
1272 "document.getElementById('password').value = 'random';" | 1245 "document.getElementById('password').value = 'random';" |
1273 "document.getElementById('submit-button').click();"; | 1246 "document.getElementById('submit-button').click();"; |
1274 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 1247 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
1275 observer.Wait(); | 1248 observer.Wait(); |
1276 | 1249 |
1277 EXPECT_TRUE(BubbleObserver(WebContents()).IsShowingSavePrompt()); | 1250 EXPECT_TRUE(BubbleObserver(WebContents()).IsSavePromptShownAutomatically()); |
1278 } | 1251 } |
1279 | 1252 |
1280 // Test that if a hidden form gets dynamically added between the form parsing | 1253 // Test that if a hidden form gets dynamically added between the form parsing |
1281 // and rendering, it still is registered, and autofilling works. | 1254 // and rendering, it still is registered, and autofilling works. |
1282 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1255 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1283 HiddenFormAddedBetweenParsingAndRendering) { | 1256 HiddenFormAddedBetweenParsingAndRendering) { |
1284 // At first let us save a credential to the password store. | 1257 // At first let us save a credential to the password store. |
1285 scoped_refptr<password_manager::TestPasswordStore> password_store = | 1258 scoped_refptr<password_manager::TestPasswordStore> password_store = |
1286 static_cast<password_manager::TestPasswordStore*>( | 1259 static_cast<password_manager::TestPasswordStore*>( |
1287 PasswordStoreFactory::GetForProfile( | 1260 PasswordStoreFactory::GetForProfile( |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 static_cast<password_manager::TestPasswordStore*>( | 1343 static_cast<password_manager::TestPasswordStore*>( |
1371 PasswordStoreFactory::GetForProfile( | 1344 PasswordStoreFactory::GetForProfile( |
1372 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); | 1345 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get()); |
1373 ASSERT_TRUE(password_store->IsEmpty()); | 1346 ASSERT_TRUE(password_store->IsEmpty()); |
1374 | 1347 |
1375 // Navigate to a page requiring HTTP auth. Wait for the tab to get the correct | 1348 // Navigate to a page requiring HTTP auth. Wait for the tab to get the correct |
1376 // WebContents, but don't wait for navigation, which only finishes after | 1349 // WebContents, but don't wait for navigation, which only finishes after |
1377 // authentication. | 1350 // authentication. |
1378 ui_test_utils::NavigateToURLWithDisposition( | 1351 ui_test_utils::NavigateToURLWithDisposition( |
1379 browser(), http_test_server.GetURL("/basic_auth"), | 1352 browser(), http_test_server.GetURL("/basic_auth"), |
1380 WindowOpenDisposition::NEW_FOREGROUND_TAB, | 1353 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
1381 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | |
1382 | 1354 |
1383 content::WebContents* tab = | 1355 content::NavigationController* nav_controller = |
1384 browser()->tab_strip_model()->GetActiveWebContents(); | 1356 &WebContents()->GetController(); |
1385 content::NavigationController* nav_controller = &tab->GetController(); | 1357 NavigationObserver nav_observer(WebContents()); |
1386 NavigationObserver nav_observer(tab); | |
1387 WindowedAuthNeededObserver auth_needed_observer(nav_controller); | 1358 WindowedAuthNeededObserver auth_needed_observer(nav_controller); |
1388 auth_needed_observer.Wait(); | 1359 auth_needed_observer.Wait(); |
1389 | 1360 |
1390 WindowedAuthSuppliedObserver auth_supplied_observer(nav_controller); | 1361 WindowedAuthSuppliedObserver auth_supplied_observer(nav_controller); |
1391 // Offer valid credentials on the auth challenge. | 1362 // Offer valid credentials on the auth challenge. |
1392 ASSERT_EQ(1u, login_observer.handlers().size()); | 1363 ASSERT_EQ(1u, login_observer.handlers().size()); |
1393 LoginHandler* handler = *login_observer.handlers().begin(); | 1364 LoginHandler* handler = *login_observer.handlers().begin(); |
1394 ASSERT_TRUE(handler); | 1365 ASSERT_TRUE(handler); |
1395 // Any username/password will work. | 1366 // Any username/password will work. |
1396 handler->SetAuth(base::UTF8ToUTF16("user"), base::UTF8ToUTF16("pwd")); | 1367 handler->SetAuth(base::UTF8ToUTF16("user"), base::UTF8ToUTF16("pwd")); |
1397 auth_supplied_observer.Wait(); | 1368 auth_supplied_observer.Wait(); |
1398 | 1369 |
1399 // The password manager should be working correctly. | 1370 // The password manager should be working correctly. |
1400 nav_observer.Wait(); | 1371 nav_observer.Wait(); |
1401 WaitForPasswordStore(); | 1372 WaitForPasswordStore(); |
1402 BubbleObserver bubble_observer(tab); | 1373 BubbleObserver bubble_observer(WebContents()); |
1403 EXPECT_TRUE(bubble_observer.IsShowingSavePrompt()); | 1374 EXPECT_TRUE(bubble_observer.IsSavePromptShownAutomatically()); |
1404 bubble_observer.AcceptSavePrompt(); | 1375 bubble_observer.AcceptSavePrompt(); |
1405 | 1376 |
1406 // Spin the message loop to make sure the password store had a chance to save | 1377 // Spin the message loop to make sure the password store had a chance to save |
1407 // the password. | 1378 // the password. |
1408 WaitForPasswordStore(); | 1379 WaitForPasswordStore(); |
1409 EXPECT_FALSE(password_store->IsEmpty()); | 1380 EXPECT_FALSE(password_store->IsEmpty()); |
1410 } | 1381 } |
1411 | 1382 |
1412 // Fill out a form and click a button. The Javascript removes the form, creates | 1383 // Fill out a form and click a button. The Javascript removes the form, creates |
1413 // a similar one with another action, fills it out and submits. Chrome can | 1384 // a similar one with another action, fills it out and submits. Chrome can |
1414 // manage to detect the new one and create a complete matching | 1385 // manage to detect the new one and create a complete matching |
1415 // PasswordFormManager. Otherwise, the all-but-action matching PFM should be | 1386 // PasswordFormManager. Otherwise, the all-but-action matching PFM should be |
1416 // used. Regardless of the internals the user sees the bubble in 100% cases. | 1387 // used. Regardless of the internals the user sees the bubble in 100% cases. |
1417 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1388 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1418 PreferPasswordFormManagerWhichFinishedMatching) { | 1389 PreferPasswordFormManagerWhichFinishedMatching) { |
1419 NavigateToFile("/password/create_form_copy_on_submit.html"); | 1390 NavigateToFile("/password/create_form_copy_on_submit.html"); |
1420 | 1391 |
1421 NavigationObserver observer(WebContents()); | 1392 NavigationObserver observer(WebContents()); |
1422 std::unique_ptr<BubbleObserver> prompt_observer( | 1393 std::unique_ptr<BubbleObserver> prompt_observer( |
1423 new BubbleObserver(WebContents())); | 1394 new BubbleObserver(WebContents())); |
1424 std::string submit = | 1395 std::string submit = |
1425 "document.getElementById('username').value = 'overwrite_me';" | 1396 "document.getElementById('username').value = 'overwrite_me';" |
1426 "document.getElementById('password').value = 'random';" | 1397 "document.getElementById('password').value = 'random';" |
1427 "document.getElementById('non-form-button').click();"; | 1398 "document.getElementById('non-form-button').click();"; |
1428 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 1399 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
1429 observer.Wait(); | 1400 observer.Wait(); |
1430 | 1401 |
1431 WaitForPasswordStore(); | 1402 WaitForPasswordStore(); |
1432 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1403 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1433 } | 1404 } |
1434 | 1405 |
1435 // Test that if login fails and content server pushes a different login form | 1406 // Test that if login fails and content server pushes a different login form |
1436 // with action URL having different schemes. Heuristic shall be able | 1407 // with action URL having different schemes. Heuristic shall be able |
1437 // identify such cases and *shall not* prompt to save incorrect password. | 1408 // identify such cases and *shall not* prompt to save incorrect password. |
1438 IN_PROC_BROWSER_TEST_F( | 1409 IN_PROC_BROWSER_TEST_F( |
1439 PasswordManagerBrowserTestBase, | 1410 PasswordManagerBrowserTestBase, |
1440 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpToHttps) { | 1411 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpToHttps) { |
1441 std::string path = | 1412 std::string path = |
1442 "/password/separate_login_form_with_onload_submit_script.html"; | 1413 "/password/separate_login_form_with_onload_submit_script.html"; |
1443 GURL http_url(embedded_test_server()->GetURL(path)); | 1414 GURL http_url(embedded_test_server()->GetURL(path)); |
1444 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); | 1415 ASSERT_TRUE(http_url.SchemeIs(url::kHttpScheme)); |
1445 | 1416 |
1446 NavigationObserver observer(WebContents()); | 1417 NavigationObserver observer(WebContents()); |
1447 std::unique_ptr<BubbleObserver> prompt_observer( | 1418 std::unique_ptr<BubbleObserver> prompt_observer( |
1448 new BubbleObserver(WebContents())); | 1419 new BubbleObserver(WebContents())); |
1449 ui_test_utils::NavigateToURL(browser(), http_url); | 1420 ui_test_utils::NavigateToURL(browser(), http_url); |
1450 | 1421 |
1451 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); | 1422 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); |
1452 observer.Wait(); | 1423 observer.Wait(); |
1453 | 1424 |
1454 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1425 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1455 } | 1426 } |
1456 | 1427 |
1457 IN_PROC_BROWSER_TEST_F( | 1428 IN_PROC_BROWSER_TEST_F( |
1458 PasswordManagerBrowserTestBase, | 1429 PasswordManagerBrowserTestBase, |
1459 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpsToHttp) { | 1430 NoPromptForLoginFailedAndServerPushSeperateLoginForm_HttpsToHttp) { |
1460 // This test case cannot inject the scripts via content::ExecuteScript() in | 1431 // This test case cannot inject the scripts via content::ExecuteScript() in |
1461 // files served through HTTPS. Therefore the scripts are made part of the HTML | 1432 // files served through HTTPS. Therefore the scripts are made part of the HTML |
1462 // site and executed on load. | 1433 // site and executed on load. |
1463 std::string path = | 1434 std::string path = |
1464 "/password/separate_login_form_with_onload_submit_script.html"; | 1435 "/password/separate_login_form_with_onload_submit_script.html"; |
1465 GURL https_url(https_test_server().GetURL(path)); | 1436 GURL https_url(https_test_server().GetURL(path)); |
1466 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme)); | 1437 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme)); |
1467 | 1438 |
1468 NavigationObserver observer(WebContents()); | 1439 NavigationObserver observer(WebContents()); |
1469 std::unique_ptr<BubbleObserver> prompt_observer( | 1440 std::unique_ptr<BubbleObserver> prompt_observer( |
1470 new BubbleObserver(WebContents())); | 1441 new BubbleObserver(WebContents())); |
1471 ui_test_utils::NavigateToURL(browser(), https_url); | 1442 ui_test_utils::NavigateToURL(browser(), https_url); |
1472 | 1443 |
1473 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); | 1444 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); |
1474 observer.Wait(); | 1445 observer.Wait(); |
1475 | 1446 |
1476 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1447 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1477 } | 1448 } |
1478 | 1449 |
1479 // Tests whether a attempted submission of a malicious credentials gets blocked. | 1450 // Tests whether a attempted submission of a malicious credentials gets blocked. |
1480 // This simulates a case which is described in http://crbug.com/571580. | 1451 // This simulates a case which is described in http://crbug.com/571580. |
1481 IN_PROC_BROWSER_TEST_F( | 1452 IN_PROC_BROWSER_TEST_F( |
1482 PasswordManagerBrowserTestBase, | 1453 PasswordManagerBrowserTestBase, |
1483 NoPromptForSeperateLoginFormWhenSwitchingFromHttpsToHttp) { | 1454 NoPromptForSeperateLoginFormWhenSwitchingFromHttpsToHttp) { |
1484 std::string path = "/password/password_form.html"; | 1455 std::string path = "/password/password_form.html"; |
1485 GURL https_url(https_test_server().GetURL(path)); | 1456 GURL https_url(https_test_server().GetURL(path)); |
1486 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme)); | 1457 ASSERT_TRUE(https_url.SchemeIs(url::kHttpsScheme)); |
1487 | 1458 |
1488 NavigationObserver form_observer(WebContents()); | 1459 NavigationObserver form_observer(WebContents()); |
1489 ui_test_utils::NavigateToURL(browser(), https_url); | 1460 ui_test_utils::NavigateToURL(browser(), https_url); |
1490 form_observer.Wait(); | 1461 form_observer.Wait(); |
1491 | 1462 |
1492 std::string fill_and_submit_redirect = | 1463 std::string fill_and_submit_redirect = |
1493 "document.getElementById('username_redirect').value = 'user';" | 1464 "document.getElementById('username_redirect').value = 'user';" |
1494 "document.getElementById('password_redirect').value = 'password';" | 1465 "document.getElementById('password_redirect').value = 'password';" |
1495 "document.getElementById('submit_redirect').click()"; | 1466 "document.getElementById('submit_redirect').click()"; |
1496 ASSERT_TRUE( | 1467 ASSERT_TRUE( |
1497 content::ExecuteScript(RenderViewHost(), fill_and_submit_redirect)); | 1468 content::ExecuteScript(RenderViewHost(), fill_and_submit_redirect)); |
1498 | 1469 |
1499 NavigationObserver redirect_observer(WebContents()); | 1470 NavigationObserver redirect_observer(WebContents()); |
1500 redirect_observer.SetPathToWaitFor("/password/redirect.html"); | 1471 redirect_observer.SetPathToWaitFor("/password/redirect.html"); |
1501 redirect_observer.Wait(); | 1472 redirect_observer.Wait(); |
1502 | 1473 |
1503 WaitForPasswordStore(); | 1474 WaitForPasswordStore(); |
1504 BubbleObserver prompt_observer(WebContents()); | 1475 BubbleObserver prompt_observer(WebContents()); |
1505 EXPECT_TRUE(prompt_observer.IsShowingSavePrompt()); | 1476 EXPECT_TRUE(prompt_observer.IsSavePromptShownAutomatically()); |
1506 | 1477 |
1507 // Normally the redirect happens to done.html. Here an attack is simulated | 1478 // Normally the redirect happens to done.html. Here an attack is simulated |
1508 // that hijacks the redirect to a attacker controlled page. | 1479 // that hijacks the redirect to a attacker controlled page. |
1509 GURL http_url( | 1480 GURL http_url( |
1510 embedded_test_server()->GetURL("/password/simple_password.html")); | 1481 embedded_test_server()->GetURL("/password/simple_password.html")); |
1511 std::string attacker_redirect = | 1482 std::string attacker_redirect = |
1512 "window.location.href = '" + http_url.spec() + "';"; | 1483 "window.location.href = '" + http_url.spec() + "';"; |
1513 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(), | 1484 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(), |
1514 attacker_redirect)); | 1485 attacker_redirect)); |
1515 | 1486 |
1516 NavigationObserver attacker_observer(WebContents()); | 1487 NavigationObserver attacker_observer(WebContents()); |
1517 attacker_observer.SetPathToWaitFor("/password/simple_password.html"); | 1488 attacker_observer.SetPathToWaitFor("/password/simple_password.html"); |
1518 attacker_observer.Wait(); | 1489 attacker_observer.Wait(); |
1519 | 1490 |
1520 EXPECT_TRUE(prompt_observer.IsShowingSavePrompt()); | 1491 EXPECT_TRUE(prompt_observer.IsSavePromptShownAutomatically()); |
1521 | 1492 |
1522 std::string fill_and_submit_attacker_form = | 1493 std::string fill_and_submit_attacker_form = |
1523 "document.getElementById('username_field').value = 'attacker_username';" | 1494 "document.getElementById('username_field').value = 'attacker_username';" |
1524 "document.getElementById('password_field').value = 'attacker_password';" | 1495 "document.getElementById('password_field').value = 'attacker_password';" |
1525 "document.getElementById('input_submit_button').click()"; | 1496 "document.getElementById('input_submit_button').click()"; |
1526 ASSERT_TRUE( | 1497 ASSERT_TRUE( |
1527 content::ExecuteScript(RenderViewHost(), fill_and_submit_attacker_form)); | 1498 content::ExecuteScript(RenderViewHost(), fill_and_submit_attacker_form)); |
1528 | 1499 |
1529 NavigationObserver done_observer(WebContents()); | 1500 NavigationObserver done_observer(WebContents()); |
1530 done_observer.SetPathToWaitFor("/password/done.html"); | 1501 done_observer.SetPathToWaitFor("/password/done.html"); |
1531 done_observer.Wait(); | 1502 done_observer.Wait(); |
1532 | 1503 |
1533 EXPECT_TRUE(prompt_observer.IsShowingSavePrompt()); | 1504 EXPECT_TRUE(prompt_observer.IsSavePromptShownAutomatically()); |
1534 prompt_observer.AcceptSavePrompt(); | 1505 prompt_observer.AcceptSavePrompt(); |
1535 | 1506 |
1536 // Wait for password store and check that credentials are stored. | 1507 // Wait for password store and check that credentials are stored. |
1537 WaitForPasswordStore(); | 1508 WaitForPasswordStore(); |
1538 scoped_refptr<password_manager::TestPasswordStore> password_store = | 1509 CheckThatCredentialsStored(base::ASCIIToUTF16("user"), |
1539 static_cast<password_manager::TestPasswordStore*>( | |
1540 PasswordStoreFactory::GetForProfile( | |
1541 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
1542 .get()); | |
1543 EXPECT_FALSE(password_store->IsEmpty()); | |
1544 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("user"), | |
1545 base::ASCIIToUTF16("password")); | 1510 base::ASCIIToUTF16("password")); |
1546 } | 1511 } |
1547 | 1512 |
1548 // Tests that after HTTP -> HTTPS migration the credential is autofilled. | 1513 // Tests that after HTTP -> HTTPS migration the credential is autofilled. |
1549 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1514 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1550 HttpMigratedCredentialAutofilled) { | 1515 HttpMigratedCredentialAutofilled) { |
1551 // Add an http credential to the password store. | 1516 // Add an http credential to the password store. |
1552 GURL https_origin = https_test_server().base_url(); | 1517 GURL https_origin = https_test_server().base_url(); |
1553 ASSERT_TRUE(https_origin.SchemeIs(url::kHttpsScheme)); | 1518 ASSERT_TRUE(https_origin.SchemeIs(url::kHttpsScheme)); |
1554 GURL::Replacements rep; | 1519 GURL::Replacements rep; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 | 1618 |
1654 NavigationObserver observer(WebContents()); | 1619 NavigationObserver observer(WebContents()); |
1655 std::unique_ptr<BubbleObserver> prompt_observer( | 1620 std::unique_ptr<BubbleObserver> prompt_observer( |
1656 new BubbleObserver(WebContents())); | 1621 new BubbleObserver(WebContents())); |
1657 std::string submit = | 1622 std::string submit = |
1658 "document.getElementById('password').value = 'password';" | 1623 "document.getElementById('password').value = 'password';" |
1659 "document.getElementById('submit-button').click();"; | 1624 "document.getElementById('submit-button').click();"; |
1660 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 1625 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
1661 observer.Wait(); | 1626 observer.Wait(); |
1662 | 1627 |
1663 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1628 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1664 prompt_observer->AcceptSavePrompt(); | 1629 prompt_observer->AcceptSavePrompt(); |
1665 | 1630 |
1666 WaitForPasswordStore(); | 1631 WaitForPasswordStore(); |
1667 EXPECT_FALSE(password_store->IsEmpty()); | 1632 EXPECT_FALSE(password_store->IsEmpty()); |
1668 } | 1633 } |
1669 | 1634 |
1670 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1635 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1671 AutofillSuggestionsForPasswordFormWithoutUsernameField) { | 1636 AutofillSuggestionsForPasswordFormWithoutUsernameField) { |
1672 std::string submit = | 1637 std::string submit = |
1673 "document.getElementById('password').value = 'mypassword';" | 1638 "document.getElementById('password').value = 'mypassword';" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 NavigationObserver observer(WebContents()); | 1690 NavigationObserver observer(WebContents()); |
1726 observer.set_quit_on_entry_committed(true); | 1691 observer.set_quit_on_entry_committed(true); |
1727 std::unique_ptr<BubbleObserver> prompt_observer( | 1692 std::unique_ptr<BubbleObserver> prompt_observer( |
1728 new BubbleObserver(WebContents())); | 1693 new BubbleObserver(WebContents())); |
1729 std::string fill_and_submit = | 1694 std::string fill_and_submit = |
1730 "document.getElementById('username_field').value = 'temp';" | 1695 "document.getElementById('username_field').value = 'temp';" |
1731 "document.getElementById('password_field').value = 'random';" | 1696 "document.getElementById('password_field').value = 'random';" |
1732 "document.getElementById('submit_button').click()"; | 1697 "document.getElementById('submit_button').click()"; |
1733 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1698 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1734 observer.Wait(); | 1699 observer.Wait(); |
1735 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1700 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1736 } | 1701 } |
1737 | 1702 |
1738 // Similar to the case above, but this time the form persists after | 1703 // Similar to the case above, but this time the form persists after |
1739 // 'history.pushState()'. And save password prompt should not show up | 1704 // 'history.pushState()'. And save password prompt should not show up |
1740 // in this case. | 1705 // in this case. |
1741 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1706 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1742 NoPromptForPushStateWhenFormPersists) { | 1707 NoPromptForPushStateWhenFormPersists) { |
1743 NavigateToFile("/password/password_push_state.html"); | 1708 NavigateToFile("/password/password_push_state.html"); |
1744 | 1709 |
1745 // Set |should_delete_testform| to false to keep submitted form visible after | 1710 // Set |should_delete_testform| to false to keep submitted form visible after |
1746 // history.pushsTate(); | 1711 // history.pushsTate(); |
1747 NavigationObserver observer(WebContents()); | 1712 NavigationObserver observer(WebContents()); |
1748 observer.set_quit_on_entry_committed(true); | 1713 observer.set_quit_on_entry_committed(true); |
1749 std::unique_ptr<BubbleObserver> prompt_observer( | 1714 std::unique_ptr<BubbleObserver> prompt_observer( |
1750 new BubbleObserver(WebContents())); | 1715 new BubbleObserver(WebContents())); |
1751 std::string fill_and_submit = | 1716 std::string fill_and_submit = |
1752 "should_delete_testform = false;" | 1717 "should_delete_testform = false;" |
1753 "document.getElementById('username_field').value = 'temp';" | 1718 "document.getElementById('username_field').value = 'temp';" |
1754 "document.getElementById('password_field').value = 'random';" | 1719 "document.getElementById('password_field').value = 'random';" |
1755 "document.getElementById('submit_button').click()"; | 1720 "document.getElementById('submit_button').click()"; |
1756 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1721 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1757 observer.Wait(); | 1722 observer.Wait(); |
1758 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1723 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1759 } | 1724 } |
1760 | 1725 |
1761 // The password manager should distinguish forms with empty actions. After | 1726 // The password manager should distinguish forms with empty actions. After |
1762 // successful login, the login form disappears, but the another one shouldn't be | 1727 // successful login, the login form disappears, but the another one shouldn't be |
1763 // recognized as the login form. The save prompt should appear. | 1728 // recognized as the login form. The save prompt should appear. |
1764 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1729 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1765 PromptForPushStateWhenFormWithEmptyActionDisappears) { | 1730 PromptForPushStateWhenFormWithEmptyActionDisappears) { |
1766 NavigateToFile("/password/password_push_state.html"); | 1731 NavigateToFile("/password/password_push_state.html"); |
1767 | 1732 |
1768 NavigationObserver observer(WebContents()); | 1733 NavigationObserver observer(WebContents()); |
1769 observer.set_quit_on_entry_committed(true); | 1734 observer.set_quit_on_entry_committed(true); |
1770 std::unique_ptr<BubbleObserver> prompt_observer( | 1735 std::unique_ptr<BubbleObserver> prompt_observer( |
1771 new BubbleObserver(WebContents())); | 1736 new BubbleObserver(WebContents())); |
1772 std::string fill_and_submit = | 1737 std::string fill_and_submit = |
1773 "document.getElementById('ea_username_field').value = 'temp';" | 1738 "document.getElementById('ea_username_field').value = 'temp';" |
1774 "document.getElementById('ea_password_field').value = 'random';" | 1739 "document.getElementById('ea_password_field').value = 'random';" |
1775 "document.getElementById('ea_submit_button').click()"; | 1740 "document.getElementById('ea_submit_button').click()"; |
1776 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1741 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1777 observer.Wait(); | 1742 observer.Wait(); |
1778 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1743 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1779 } | 1744 } |
1780 | 1745 |
1781 // Similar to the case above, but this time the form persists after | 1746 // Similar to the case above, but this time the form persists after |
1782 // 'history.pushState()'. The password manager should find the login form even | 1747 // 'history.pushState()'. The password manager should find the login form even |
1783 // if the action of the form is empty. Save password prompt should not show up. | 1748 // if the action of the form is empty. Save password prompt should not show up. |
1784 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1749 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1785 PromptForPushStateWhenFormWithEmptyActionPersists) { | 1750 PromptForPushStateWhenFormWithEmptyActionPersists) { |
1786 NavigateToFile("/password/password_push_state.html"); | 1751 NavigateToFile("/password/password_push_state.html"); |
1787 | 1752 |
1788 NavigationObserver observer(WebContents()); | 1753 NavigationObserver observer(WebContents()); |
1789 observer.set_quit_on_entry_committed(true); | 1754 observer.set_quit_on_entry_committed(true); |
1790 std::unique_ptr<BubbleObserver> prompt_observer( | 1755 std::unique_ptr<BubbleObserver> prompt_observer( |
1791 new BubbleObserver(WebContents())); | 1756 new BubbleObserver(WebContents())); |
1792 std::string fill_and_submit = | 1757 std::string fill_and_submit = |
1793 "should_delete_testform = false;" | 1758 "should_delete_testform = false;" |
1794 "document.getElementById('ea_username_field').value = 'temp';" | 1759 "document.getElementById('ea_username_field').value = 'temp';" |
1795 "document.getElementById('ea_password_field').value = 'random';" | 1760 "document.getElementById('ea_password_field').value = 'random';" |
1796 "document.getElementById('ea_submit_button').click()"; | 1761 "document.getElementById('ea_submit_button').click()"; |
1797 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1762 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1798 observer.Wait(); | 1763 observer.Wait(); |
1799 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1764 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1800 } | 1765 } |
1801 | 1766 |
1802 // Current and target URLs contain different parameters and references. This | 1767 // Current and target URLs contain different parameters and references. This |
1803 // test checks that parameters and references in origins are ignored for | 1768 // test checks that parameters and references in origins are ignored for |
1804 // form origin comparison. | 1769 // form origin comparison. |
1805 IN_PROC_BROWSER_TEST_F( | 1770 IN_PROC_BROWSER_TEST_F( |
1806 PasswordManagerBrowserTestBase, | 1771 PasswordManagerBrowserTestBase, |
1807 PromptForPushStateWhenFormDisappears_ParametersInOrigins) { | 1772 PromptForPushStateWhenFormDisappears_ParametersInOrigins) { |
1808 NavigateToFile("/password/password_push_state.html?login#r"); | 1773 NavigateToFile("/password/password_push_state.html?login#r"); |
1809 | 1774 |
1810 NavigationObserver observer(WebContents()); | 1775 NavigationObserver observer(WebContents()); |
1811 observer.set_quit_on_entry_committed(true); | 1776 observer.set_quit_on_entry_committed(true); |
1812 std::unique_ptr<BubbleObserver> prompt_observer( | 1777 std::unique_ptr<BubbleObserver> prompt_observer( |
1813 new BubbleObserver(WebContents())); | 1778 new BubbleObserver(WebContents())); |
1814 std::string fill_and_submit = | 1779 std::string fill_and_submit = |
1815 "add_parameters_to_target_url = true;" | 1780 "add_parameters_to_target_url = true;" |
1816 "document.getElementById('pa_username_field').value = 'temp';" | 1781 "document.getElementById('pa_username_field').value = 'temp';" |
1817 "document.getElementById('pa_password_field').value = 'random';" | 1782 "document.getElementById('pa_password_field').value = 'random';" |
1818 "document.getElementById('pa_submit_button').click()"; | 1783 "document.getElementById('pa_submit_button').click()"; |
1819 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1784 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1820 observer.Wait(); | 1785 observer.Wait(); |
1821 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1786 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1822 } | 1787 } |
1823 | 1788 |
1824 // Similar to the case above, but this time the form persists after | 1789 // Similar to the case above, but this time the form persists after |
1825 // 'history.pushState()'. The password manager should find the login form even | 1790 // 'history.pushState()'. The password manager should find the login form even |
1826 // if target and current URLs contain different parameters or references. | 1791 // if target and current URLs contain different parameters or references. |
1827 // Save password prompt should not show up. | 1792 // Save password prompt should not show up. |
1828 IN_PROC_BROWSER_TEST_F( | 1793 IN_PROC_BROWSER_TEST_F( |
1829 PasswordManagerBrowserTestBase, | 1794 PasswordManagerBrowserTestBase, |
1830 PromptForPushStateWhenFormPersists_ParametersInOrigins) { | 1795 PromptForPushStateWhenFormPersists_ParametersInOrigins) { |
1831 NavigateToFile("/password/password_push_state.html?login#r"); | 1796 NavigateToFile("/password/password_push_state.html?login#r"); |
1832 | 1797 |
1833 NavigationObserver observer(WebContents()); | 1798 NavigationObserver observer(WebContents()); |
1834 observer.set_quit_on_entry_committed(true); | 1799 observer.set_quit_on_entry_committed(true); |
1835 std::unique_ptr<BubbleObserver> prompt_observer( | 1800 std::unique_ptr<BubbleObserver> prompt_observer( |
1836 new BubbleObserver(WebContents())); | 1801 new BubbleObserver(WebContents())); |
1837 std::string fill_and_submit = | 1802 std::string fill_and_submit = |
1838 "should_delete_testform = false;" | 1803 "should_delete_testform = false;" |
1839 "add_parameters_to_target_url = true;" | 1804 "add_parameters_to_target_url = true;" |
1840 "document.getElementById('pa_username_field').value = 'temp';" | 1805 "document.getElementById('pa_username_field').value = 'temp';" |
1841 "document.getElementById('pa_password_field').value = 'random';" | 1806 "document.getElementById('pa_password_field').value = 'random';" |
1842 "document.getElementById('pa_submit_button').click()"; | 1807 "document.getElementById('pa_submit_button').click()"; |
1843 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1808 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1844 observer.Wait(); | 1809 observer.Wait(); |
1845 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1810 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1846 } | 1811 } |
1847 | 1812 |
1848 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1813 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1849 InFrameNavigationDoesNotClearPopupState) { | 1814 InFrameNavigationDoesNotClearPopupState) { |
1850 scoped_refptr<password_manager::TestPasswordStore> password_store = | 1815 scoped_refptr<password_manager::TestPasswordStore> password_store = |
1851 static_cast<password_manager::TestPasswordStore*>( | 1816 static_cast<password_manager::TestPasswordStore*>( |
1852 PasswordStoreFactory::GetForProfile( | 1817 PasswordStoreFactory::GetForProfile( |
1853 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 1818 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
1854 .get()); | 1819 .get()); |
1855 autofill::PasswordForm signin_form; | 1820 autofill::PasswordForm signin_form; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 std::unique_ptr<BubbleObserver> prompt_observer( | 1875 std::unique_ptr<BubbleObserver> prompt_observer( |
1911 new BubbleObserver(WebContents())); | 1876 new BubbleObserver(WebContents())); |
1912 std::string fill_and_submit = | 1877 std::string fill_and_submit = |
1913 "document.getElementById('chg_username_field').value = 'temp';" | 1878 "document.getElementById('chg_username_field').value = 'temp';" |
1914 "document.getElementById('chg_password_field').value = 'random';" | 1879 "document.getElementById('chg_password_field').value = 'random';" |
1915 "document.getElementById('chg_new_password_1').value = 'random1';" | 1880 "document.getElementById('chg_new_password_1').value = 'random1';" |
1916 "document.getElementById('chg_new_password_2').value = 'random1';" | 1881 "document.getElementById('chg_new_password_2').value = 'random1';" |
1917 "document.getElementById('chg_submit_button').click()"; | 1882 "document.getElementById('chg_submit_button').click()"; |
1918 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1883 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1919 observer.Wait(); | 1884 observer.Wait(); |
1920 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1885 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1921 } | 1886 } |
1922 | 1887 |
1923 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1888 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1924 ChangePwdFormPushStateBubbleShown) { | 1889 ChangePwdFormPushStateBubbleShown) { |
1925 NavigateToFile("/password/password_push_state.html"); | 1890 NavigateToFile("/password/password_push_state.html"); |
1926 | 1891 |
1927 NavigationObserver observer(WebContents()); | 1892 NavigationObserver observer(WebContents()); |
1928 observer.set_quit_on_entry_committed(true); | 1893 observer.set_quit_on_entry_committed(true); |
1929 std::unique_ptr<BubbleObserver> prompt_observer( | 1894 std::unique_ptr<BubbleObserver> prompt_observer( |
1930 new BubbleObserver(WebContents())); | 1895 new BubbleObserver(WebContents())); |
1931 std::string fill_and_submit = | 1896 std::string fill_and_submit = |
1932 "document.getElementById('chg_username_field').value = 'temp';" | 1897 "document.getElementById('chg_username_field').value = 'temp';" |
1933 "document.getElementById('chg_password_field').value = 'random';" | 1898 "document.getElementById('chg_password_field').value = 'random';" |
1934 "document.getElementById('chg_new_password_1').value = 'random1';" | 1899 "document.getElementById('chg_new_password_1').value = 'random1';" |
1935 "document.getElementById('chg_new_password_2').value = 'random1';" | 1900 "document.getElementById('chg_new_password_2').value = 'random1';" |
1936 "document.getElementById('chg_submit_button').click()"; | 1901 "document.getElementById('chg_submit_button').click()"; |
1937 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1902 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
1938 observer.Wait(); | 1903 observer.Wait(); |
1939 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1904 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1940 } | 1905 } |
1941 | 1906 |
1942 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptOnBack) { | 1907 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, NoPromptOnBack) { |
1943 // Go to a successful landing page through submitting first, so that it is | 1908 // Go to a successful landing page through submitting first, so that it is |
1944 // reachable through going back, and the remembered page transition is form | 1909 // reachable through going back, and the remembered page transition is form |
1945 // submit. There is no need to submit non-empty strings. | 1910 // submit. There is no need to submit non-empty strings. |
1946 NavigateToFile("/password/password_form.html"); | 1911 NavigateToFile("/password/password_form.html"); |
1947 | 1912 |
1948 NavigationObserver dummy_submit_observer(WebContents()); | 1913 NavigationObserver dummy_submit_observer(WebContents()); |
1949 std::string just_submit = | 1914 std::string just_submit = |
(...skipping 11 matching lines...) Expand all Loading... |
1961 // The (dummy) submit is necessary to provisionally save the typed password. A | 1926 // The (dummy) submit is necessary to provisionally save the typed password. A |
1962 // user typing in the password field would not need to submit to provisionally | 1927 // user typing in the password field would not need to submit to provisionally |
1963 // save it, but the script cannot trigger that just by assigning to the | 1928 // save it, but the script cannot trigger that just by assigning to the |
1964 // field's value. | 1929 // field's value. |
1965 std::string fill_and_back = | 1930 std::string fill_and_back = |
1966 "document.getElementById('password_field').value = 'random';" | 1931 "document.getElementById('password_field').value = 'random';" |
1967 "document.getElementById('input_submit_button').click();" | 1932 "document.getElementById('input_submit_button').click();" |
1968 "window.history.back();"; | 1933 "window.history.back();"; |
1969 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_back)); | 1934 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_back)); |
1970 observer.Wait(); | 1935 observer.Wait(); |
1971 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 1936 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
1972 } | 1937 } |
1973 | 1938 |
1974 // Regression test for http://crbug.com/452306 | 1939 // Regression test for http://crbug.com/452306 |
1975 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1940 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1976 ChangingTextToPasswordFieldOnSignupForm) { | 1941 ChangingTextToPasswordFieldOnSignupForm) { |
1977 NavigateToFile("/password/signup_form.html"); | 1942 NavigateToFile("/password/signup_form.html"); |
1978 | 1943 |
1979 // In this case, pretend that username_field is actually a password field | 1944 // In this case, pretend that username_field is actually a password field |
1980 // that starts as a text field to simulate placeholder. | 1945 // that starts as a text field to simulate placeholder. |
1981 NavigationObserver observer(WebContents()); | 1946 NavigationObserver observer(WebContents()); |
1982 std::unique_ptr<BubbleObserver> prompt_observer( | 1947 std::unique_ptr<BubbleObserver> prompt_observer( |
1983 new BubbleObserver(WebContents())); | 1948 new BubbleObserver(WebContents())); |
1984 std::string change_and_submit = | 1949 std::string change_and_submit = |
1985 "document.getElementById('other_info').value = 'username';" | 1950 "document.getElementById('other_info').value = 'username';" |
1986 "document.getElementById('username_field').type = 'password';" | 1951 "document.getElementById('username_field').type = 'password';" |
1987 "document.getElementById('username_field').value = 'mypass';" | 1952 "document.getElementById('username_field').value = 'mypass';" |
1988 "document.getElementById('password_field').value = 'mypass';" | 1953 "document.getElementById('password_field').value = 'mypass';" |
1989 "document.getElementById('testform').submit();"; | 1954 "document.getElementById('testform').submit();"; |
1990 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), change_and_submit)); | 1955 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), change_and_submit)); |
1991 observer.Wait(); | 1956 observer.Wait(); |
1992 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1957 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
1993 } | 1958 } |
1994 | 1959 |
1995 // Regression test for http://crbug.com/451631 | 1960 // Regression test for http://crbug.com/451631 |
1996 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1961 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1997 SavingOnManyPasswordFieldsTest) { | 1962 SavingOnManyPasswordFieldsTest) { |
1998 // Simulate Macy's registration page, which contains the normal 2 password | 1963 // Simulate Macy's registration page, which contains the normal 2 password |
1999 // fields for confirming the new password plus 2 more fields for security | 1964 // fields for confirming the new password plus 2 more fields for security |
2000 // questions and credit card. Make sure that saving works correctly for such | 1965 // questions and credit card. Make sure that saving works correctly for such |
2001 // sites. | 1966 // sites. |
2002 NavigateToFile("/password/many_password_signup_form.html"); | 1967 NavigateToFile("/password/many_password_signup_form.html"); |
2003 | 1968 |
2004 NavigationObserver observer(WebContents()); | 1969 NavigationObserver observer(WebContents()); |
2005 std::unique_ptr<BubbleObserver> prompt_observer( | 1970 std::unique_ptr<BubbleObserver> prompt_observer( |
2006 new BubbleObserver(WebContents())); | 1971 new BubbleObserver(WebContents())); |
2007 std::string fill_and_submit = | 1972 std::string fill_and_submit = |
2008 "document.getElementById('username_field').value = 'username';" | 1973 "document.getElementById('username_field').value = 'username';" |
2009 "document.getElementById('password_field').value = 'mypass';" | 1974 "document.getElementById('password_field').value = 'mypass';" |
2010 "document.getElementById('confirm_field').value = 'mypass';" | 1975 "document.getElementById('confirm_field').value = 'mypass';" |
2011 "document.getElementById('security_answer').value = 'hometown';" | 1976 "document.getElementById('security_answer').value = 'hometown';" |
2012 "document.getElementById('SSN').value = '1234';" | 1977 "document.getElementById('SSN').value = '1234';" |
2013 "document.getElementById('testform').submit();"; | 1978 "document.getElementById('testform').submit();"; |
2014 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 1979 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
2015 observer.Wait(); | 1980 observer.Wait(); |
2016 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 1981 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
2017 } | 1982 } |
2018 | 1983 |
2019 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1984 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2020 SaveWhenIFrameDestroyedOnFormSubmit) { | 1985 SaveWhenIFrameDestroyedOnFormSubmit) { |
2021 NavigateToFile("/password/frame_detached_on_submit.html"); | 1986 NavigateToFile("/password/frame_detached_on_submit.html"); |
2022 | 1987 |
2023 // Need to pay attention for a message that XHR has finished since there | 1988 // Need to pay attention for a message that XHR has finished since there |
2024 // is no navigation to wait for. | 1989 // is no navigation to wait for. |
2025 content::DOMMessageQueue message_queue; | 1990 content::DOMMessageQueue message_queue; |
2026 | 1991 |
2027 std::unique_ptr<BubbleObserver> prompt_observer( | 1992 std::unique_ptr<BubbleObserver> prompt_observer( |
2028 new BubbleObserver(WebContents())); | 1993 new BubbleObserver(WebContents())); |
2029 std::string fill_and_submit = | 1994 std::string fill_and_submit = |
2030 "var iframe = document.getElementById('login_iframe');" | 1995 "var iframe = document.getElementById('login_iframe');" |
2031 "var frame_doc = iframe.contentDocument;" | 1996 "var frame_doc = iframe.contentDocument;" |
2032 "frame_doc.getElementById('username_field').value = 'temp';" | 1997 "frame_doc.getElementById('username_field').value = 'temp';" |
2033 "frame_doc.getElementById('password_field').value = 'random';" | 1998 "frame_doc.getElementById('password_field').value = 'random';" |
2034 "frame_doc.getElementById('submit_button').click();"; | 1999 "frame_doc.getElementById('submit_button').click();"; |
2035 | 2000 |
2036 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2001 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
2037 std::string message; | 2002 std::string message; |
2038 while (message_queue.WaitForMessage(&message)) { | 2003 while (message_queue.WaitForMessage(&message)) { |
2039 if (message == "\"SUBMISSION_FINISHED\"") | 2004 if (message == "\"SUBMISSION_FINISHED\"") |
2040 break; | 2005 break; |
2041 } | 2006 } |
2042 | 2007 |
2043 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 2008 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
2044 } | 2009 } |
2045 | 2010 |
2046 // Tests that if a site embeds the login and signup forms into one <form>, the | 2011 // Tests that if a site embeds the login and signup forms into one <form>, the |
2047 // login form still gets autofilled. | 2012 // login form still gets autofilled. |
2048 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2013 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2049 AutofillSuggestionsForLoginSignupForm) { | 2014 AutofillSuggestionsForLoginSignupForm) { |
2050 std::string submit = | 2015 std::string submit = |
2051 "document.getElementById('username').value = 'myusername';" | 2016 "document.getElementById('username').value = 'myusername';" |
2052 "document.getElementById('password').value = 'mypassword';" | 2017 "document.getElementById('password').value = 'mypassword';" |
2053 "document.getElementById('submit').click();"; | 2018 "document.getElementById('submit').click();"; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 ifrm_observer.Wait(); | 2051 ifrm_observer.Wait(); |
2087 | 2052 |
2088 // Store a password for autofill later | 2053 // Store a password for autofill later |
2089 NavigationObserver init_observer(WebContents()); | 2054 NavigationObserver init_observer(WebContents()); |
2090 init_observer.SetPathToWaitFor("/password/done.html"); | 2055 init_observer.SetPathToWaitFor("/password/done.html"); |
2091 std::unique_ptr<BubbleObserver> prompt_observer( | 2056 std::unique_ptr<BubbleObserver> prompt_observer( |
2092 new BubbleObserver(WebContents())); | 2057 new BubbleObserver(WebContents())); |
2093 std::string init_form = "sendMessage('fill_and_submit');"; | 2058 std::string init_form = "sendMessage('fill_and_submit');"; |
2094 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), init_form)); | 2059 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), init_form)); |
2095 init_observer.Wait(); | 2060 init_observer.Wait(); |
2096 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 2061 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
2097 prompt_observer->AcceptSavePrompt(); | 2062 prompt_observer->AcceptSavePrompt(); |
2098 | 2063 |
2099 // Visit the form again | 2064 // Visit the form again |
2100 NavigationObserver reload_observer(WebContents()); | 2065 NavigationObserver reload_observer(WebContents()); |
2101 NavigateToFile("/password/password_form_in_crosssite_iframe.html"); | 2066 NavigateToFile("/password/password_form_in_crosssite_iframe.html"); |
2102 reload_observer.Wait(); | 2067 reload_observer.Wait(); |
2103 | 2068 |
2104 NavigationObserver ifrm_observer_2(WebContents()); | 2069 NavigationObserver ifrm_observer_2(WebContents()); |
2105 ifrm_observer_2.SetPathToWaitFor("/password/crossite_iframe_content.html"); | 2070 ifrm_observer_2.SetPathToWaitFor("/password/crossite_iframe_content.html"); |
2106 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(), | 2071 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2159 std::unique_ptr<BubbleObserver> prompt_observer( | 2124 std::unique_ptr<BubbleObserver> prompt_observer( |
2160 new BubbleObserver(WebContents())); | 2125 new BubbleObserver(WebContents())); |
2161 | 2126 |
2162 std::string submit = | 2127 std::string submit = |
2163 "var ifrmDoc = document.getElementById('iframe').contentDocument;" | 2128 "var ifrmDoc = document.getElementById('iframe').contentDocument;" |
2164 "ifrmDoc.getElementById('username_field').value = 'temp';" | 2129 "ifrmDoc.getElementById('username_field').value = 'temp';" |
2165 "ifrmDoc.getElementById('password_field').value = 'pa55w0rd';" | 2130 "ifrmDoc.getElementById('password_field').value = 'pa55w0rd';" |
2166 "ifrmDoc.getElementById('input_submit_button').click();"; | 2131 "ifrmDoc.getElementById('input_submit_button').click();"; |
2167 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); | 2132 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); |
2168 observer.Wait(); | 2133 observer.Wait(); |
2169 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 2134 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
2170 prompt_observer->AcceptSavePrompt(); | 2135 prompt_observer->AcceptSavePrompt(); |
2171 | 2136 |
2172 // Visit the form again | 2137 // Visit the form again |
2173 NavigationObserver reload_observer(WebContents()); | 2138 NavigationObserver reload_observer(WebContents()); |
2174 NavigateToFile("/password/password_form_in_same_origin_iframe.html"); | 2139 NavigateToFile("/password/password_form_in_same_origin_iframe.html"); |
2175 reload_observer.Wait(); | 2140 reload_observer.Wait(); |
2176 | 2141 |
2177 // Verify username is autofilled | 2142 // Verify username is autofilled |
2178 CheckElementValue("iframe", "username_field", "temp"); | 2143 CheckElementValue("iframe", "username_field", "temp"); |
2179 | 2144 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2287 "document.getElementById('chg_password_wo_username_field').value = " | 2252 "document.getElementById('chg_password_wo_username_field').value = " |
2288 "'old_pw';" | 2253 "'old_pw';" |
2289 "document.getElementById('chg_new_password_wo_username_1').value = " | 2254 "document.getElementById('chg_new_password_wo_username_1').value = " |
2290 "'new_pw';" | 2255 "'new_pw';" |
2291 "document.getElementById('chg_new_password_wo_username_2').value = " | 2256 "document.getElementById('chg_new_password_wo_username_2').value = " |
2292 "'new_pw';" | 2257 "'new_pw';" |
2293 "document.getElementById('chg_submit_wo_username_button').click()"; | 2258 "document.getElementById('chg_submit_wo_username_button').click()"; |
2294 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2259 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
2295 observer.Wait(); | 2260 observer.Wait(); |
2296 // No credentials stored before, so save bubble is shown. | 2261 // No credentials stored before, so save bubble is shown. |
2297 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 2262 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
2298 prompt_observer->AcceptSavePrompt(); | 2263 prompt_observer->AcceptSavePrompt(); |
| 2264 |
2299 // Check that credentials are stored. | 2265 // Check that credentials are stored. |
2300 scoped_refptr<password_manager::TestPasswordStore> password_store = | |
2301 static_cast<password_manager::TestPasswordStore*>( | |
2302 PasswordStoreFactory::GetForProfile( | |
2303 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
2304 .get()); | |
2305 WaitForPasswordStore(); | 2266 WaitForPasswordStore(); |
2306 EXPECT_FALSE(password_store->IsEmpty()); | 2267 CheckThatCredentialsStored(base::ASCIIToUTF16(""), |
2307 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16(""), | |
2308 base::ASCIIToUTF16("new_pw")); | 2268 base::ASCIIToUTF16("new_pw")); |
2309 } | 2269 } |
2310 | 2270 |
2311 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2271 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2312 ChangePwd1AccountStored) { | 2272 ChangePwd1AccountStored) { |
2313 // At first let us save credentials to the PasswordManager. | 2273 // At first let us save credentials to the PasswordManager. |
2314 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2274 scoped_refptr<password_manager::TestPasswordStore> password_store = |
2315 static_cast<password_manager::TestPasswordStore*>( | 2275 static_cast<password_manager::TestPasswordStore*>( |
2316 PasswordStoreFactory::GetForProfile( | 2276 PasswordStoreFactory::GetForProfile( |
2317 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2277 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
(...skipping 13 matching lines...) Expand all Loading... |
2331 "document.getElementById('chg_password_wo_username_field').value = " | 2291 "document.getElementById('chg_password_wo_username_field').value = " |
2332 "'random';" | 2292 "'random';" |
2333 "document.getElementById('chg_new_password_wo_username_1').value = " | 2293 "document.getElementById('chg_new_password_wo_username_1').value = " |
2334 "'new_pw';" | 2294 "'new_pw';" |
2335 "document.getElementById('chg_new_password_wo_username_2').value = " | 2295 "document.getElementById('chg_new_password_wo_username_2').value = " |
2336 "'new_pw';" | 2296 "'new_pw';" |
2337 "document.getElementById('chg_submit_wo_username_button').click()"; | 2297 "document.getElementById('chg_submit_wo_username_button').click()"; |
2338 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 2298 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
2339 fill_and_submit_change_password)); | 2299 fill_and_submit_change_password)); |
2340 observer.Wait(); | 2300 observer.Wait(); |
2341 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); | 2301 EXPECT_TRUE(prompt_observer->IsUpdatePromptShownAutomatically()); |
2342 | 2302 |
2343 // We emulate that the user clicks "Update" button. | 2303 // We emulate that the user clicks "Update" button. |
2344 const autofill::PasswordForm& pending_credentials = | 2304 const autofill::PasswordForm& pending_credentials = |
2345 ManagePasswordsUIController::FromWebContents(WebContents()) | 2305 ManagePasswordsUIController::FromWebContents(WebContents()) |
2346 ->GetPendingPassword(); | 2306 ->GetPendingPassword(); |
2347 prompt_observer->AcceptUpdatePrompt(pending_credentials); | 2307 prompt_observer->AcceptUpdatePrompt(pending_credentials); |
2348 | 2308 |
2349 WaitForPasswordStore(); | 2309 WaitForPasswordStore(); |
2350 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2310 CheckThatCredentialsStored(base::ASCIIToUTF16("temp"), |
2351 base::ASCIIToUTF16("new_pw")); | 2311 base::ASCIIToUTF16("new_pw")); |
2352 } | 2312 } |
2353 | 2313 |
2354 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2314 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2355 PasswordOverridenUpdateBubbleShown) { | 2315 PasswordOverridenUpdateBubbleShown) { |
2356 // At first let us save credentials to the PasswordManager. | 2316 // At first let us save credentials to the PasswordManager. |
2357 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2317 scoped_refptr<password_manager::TestPasswordStore> password_store = |
2358 static_cast<password_manager::TestPasswordStore*>( | 2318 static_cast<password_manager::TestPasswordStore*>( |
2359 PasswordStoreFactory::GetForProfile( | 2319 PasswordStoreFactory::GetForProfile( |
2360 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2320 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
(...skipping 16 matching lines...) Expand all Loading... |
2377 std::unique_ptr<BubbleObserver> prompt_observer( | 2337 std::unique_ptr<BubbleObserver> prompt_observer( |
2378 new BubbleObserver(WebContents())); | 2338 new BubbleObserver(WebContents())); |
2379 std::string fill_and_submit = | 2339 std::string fill_and_submit = |
2380 "document.getElementById('username_field').value = 'temp';" | 2340 "document.getElementById('username_field').value = 'temp';" |
2381 "document.getElementById('password_field').value = 'new_pw';" | 2341 "document.getElementById('password_field').value = 'new_pw';" |
2382 "document.getElementById('input_submit_button').click()"; | 2342 "document.getElementById('input_submit_button').click()"; |
2383 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2343 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
2384 observer.Wait(); | 2344 observer.Wait(); |
2385 // The stored password "pw" was overriden with "new_pw", so update prompt is | 2345 // The stored password "pw" was overriden with "new_pw", so update prompt is |
2386 // expected. | 2346 // expected. |
2387 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); | 2347 EXPECT_TRUE(prompt_observer->IsUpdatePromptShownAutomatically()); |
2388 | 2348 |
2389 const autofill::PasswordForm stored_form = | 2349 const autofill::PasswordForm stored_form = |
2390 password_store->stored_passwords().begin()->second[0]; | 2350 password_store->stored_passwords().begin()->second[0]; |
2391 prompt_observer->AcceptUpdatePrompt(stored_form); | 2351 prompt_observer->AcceptUpdatePrompt(stored_form); |
2392 WaitForPasswordStore(); | 2352 WaitForPasswordStore(); |
2393 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2353 CheckThatCredentialsStored(base::ASCIIToUTF16("temp"), |
2394 base::ASCIIToUTF16("new_pw")); | 2354 base::ASCIIToUTF16("new_pw")); |
2395 } | 2355 } |
2396 | 2356 |
2397 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2357 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2398 PasswordNotOverridenUpdateBubbleNotShown) { | 2358 PasswordNotOverridenUpdateBubbleNotShown) { |
2399 // At first let us save credentials to the PasswordManager. | 2359 // At first let us save credentials to the PasswordManager. |
2400 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2360 scoped_refptr<password_manager::TestPasswordStore> password_store = |
2401 static_cast<password_manager::TestPasswordStore*>( | 2361 static_cast<password_manager::TestPasswordStore*>( |
2402 PasswordStoreFactory::GetForProfile( | 2362 PasswordStoreFactory::GetForProfile( |
2403 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2363 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
(...skipping 10 matching lines...) Expand all Loading... |
2414 std::unique_ptr<BubbleObserver> prompt_observer( | 2374 std::unique_ptr<BubbleObserver> prompt_observer( |
2415 new BubbleObserver(WebContents())); | 2375 new BubbleObserver(WebContents())); |
2416 std::string fill_and_submit = | 2376 std::string fill_and_submit = |
2417 "document.getElementById('username_field').value = 'temp';" | 2377 "document.getElementById('username_field').value = 'temp';" |
2418 "document.getElementById('password_field').value = 'pw';" | 2378 "document.getElementById('password_field').value = 'pw';" |
2419 "document.getElementById('input_submit_button').click()"; | 2379 "document.getElementById('input_submit_button').click()"; |
2420 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2380 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
2421 observer.Wait(); | 2381 observer.Wait(); |
2422 // The stored password "pw" was not overriden, so update prompt is not | 2382 // The stored password "pw" was not overriden, so update prompt is not |
2423 // expected. | 2383 // expected. |
2424 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); | 2384 EXPECT_FALSE(prompt_observer->IsUpdatePromptShownAutomatically()); |
2425 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2385 CheckThatCredentialsStored(base::ASCIIToUTF16("temp"), |
2426 base::ASCIIToUTF16("pw")); | 2386 base::ASCIIToUTF16("pw")); |
2427 } | 2387 } |
2428 | 2388 |
2429 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2389 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2430 ChangePwdWhenTheFormContainNotUsernameTextfield) { | 2390 ChangePwdWhenTheFormContainNotUsernameTextfield) { |
2431 // At first let us save credentials to the PasswordManager. | 2391 // At first let us save credentials to the PasswordManager. |
2432 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2392 scoped_refptr<password_manager::TestPasswordStore> password_store = |
2433 static_cast<password_manager::TestPasswordStore*>( | 2393 static_cast<password_manager::TestPasswordStore*>( |
2434 PasswordStoreFactory::GetForProfile( | 2394 PasswordStoreFactory::GetForProfile( |
2435 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2395 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
(...skipping 14 matching lines...) Expand all Loading... |
2450 "document.getElementById('chg_password_withtext_field').value" | 2410 "document.getElementById('chg_password_withtext_field').value" |
2451 " = 'random';" | 2411 " = 'random';" |
2452 "document.getElementById('chg_new_password_withtext_username_1').value" | 2412 "document.getElementById('chg_new_password_withtext_username_1').value" |
2453 " = 'new_pw';" | 2413 " = 'new_pw';" |
2454 "document.getElementById('chg_new_password_withtext_username_2').value" | 2414 "document.getElementById('chg_new_password_withtext_username_2').value" |
2455 " = 'new_pw';" | 2415 " = 'new_pw';" |
2456 "document.getElementById('chg_submit_withtext_button').click()"; | 2416 "document.getElementById('chg_submit_withtext_button').click()"; |
2457 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 2417 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
2458 fill_and_submit_change_password)); | 2418 fill_and_submit_change_password)); |
2459 observer.Wait(); | 2419 observer.Wait(); |
2460 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); | 2420 EXPECT_TRUE(prompt_observer->IsUpdatePromptShownAutomatically()); |
2461 | 2421 |
2462 const autofill::PasswordForm stored_form = | 2422 const autofill::PasswordForm stored_form = |
2463 password_store->stored_passwords().begin()->second[0]; | 2423 password_store->stored_passwords().begin()->second[0]; |
2464 prompt_observer->AcceptUpdatePrompt(stored_form); | 2424 prompt_observer->AcceptUpdatePrompt(stored_form); |
2465 WaitForPasswordStore(); | 2425 WaitForPasswordStore(); |
2466 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2426 CheckThatCredentialsStored(base::ASCIIToUTF16("temp"), |
2467 base::ASCIIToUTF16("new_pw")); | 2427 base::ASCIIToUTF16("new_pw")); |
2468 } | 2428 } |
2469 | 2429 |
2470 // Test whether the password form with the username and password fields having | 2430 // Test whether the password form with the username and password fields having |
2471 // ambiguity in id attribute gets autofilled correctly. | 2431 // ambiguity in id attribute gets autofilled correctly. |
2472 IN_PROC_BROWSER_TEST_F( | 2432 IN_PROC_BROWSER_TEST_F( |
2473 PasswordManagerBrowserTestBase, | 2433 PasswordManagerBrowserTestBase, |
2474 AutofillSuggestionsForPasswordFormWithAmbiguousIdAttribute) { | 2434 AutofillSuggestionsForPasswordFormWithAmbiguousIdAttribute) { |
2475 // At first let us save credentials to the PasswordManager. | 2435 // At first let us save credentials to the PasswordManager. |
2476 scoped_refptr<password_manager::PasswordStore> password_store = | 2436 scoped_refptr<password_manager::PasswordStore> password_store = |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2926 bool logs_found = false; | 2886 bool logs_found = false; |
2927 ASSERT_TRUE(content::ExecuteScriptWithoutUserGestureAndExtractBool( | 2887 ASSERT_TRUE(content::ExecuteScriptWithoutUserGestureAndExtractBool( |
2928 internals_web_contents->GetMainFrame(), find_logs, &logs_found)); | 2888 internals_web_contents->GetMainFrame(), find_logs, &logs_found)); |
2929 EXPECT_TRUE(logs_found); | 2889 EXPECT_TRUE(logs_found); |
2930 } | 2890 } |
2931 | 2891 |
2932 // Tests that submitted credentials are saved on a password form without | 2892 // Tests that submitted credentials are saved on a password form without |
2933 // username element when there are no stored credentials. | 2893 // username element when there are no stored credentials. |
2934 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2894 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2935 PasswordRetryFormSaveNoUsernameCredentials) { | 2895 PasswordRetryFormSaveNoUsernameCredentials) { |
2936 scoped_refptr<password_manager::TestPasswordStore> password_store = | |
2937 static_cast<password_manager::TestPasswordStore*>( | |
2938 PasswordStoreFactory::GetForProfile( | |
2939 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
2940 .get()); | |
2941 // Check that password save bubble is shown. | 2896 // Check that password save bubble is shown. |
2942 NavigateToFile("/password/password_form.html"); | 2897 NavigateToFile("/password/password_form.html"); |
2943 NavigationObserver observer(WebContents()); | 2898 NavigationObserver observer(WebContents()); |
2944 std::unique_ptr<BubbleObserver> prompt_observer( | 2899 std::unique_ptr<BubbleObserver> prompt_observer( |
2945 new BubbleObserver(WebContents())); | 2900 new BubbleObserver(WebContents())); |
2946 std::string fill_and_submit = | 2901 std::string fill_and_submit = |
2947 "document.getElementById('retry_password_field').value = 'pw';" | 2902 "document.getElementById('retry_password_field').value = 'pw';" |
2948 "document.getElementById('retry_submit_button').click()"; | 2903 "document.getElementById('retry_submit_button').click()"; |
2949 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2904 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
2950 observer.Wait(); | 2905 observer.Wait(); |
2951 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 2906 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
2952 prompt_observer->AcceptSavePrompt(); | 2907 prompt_observer->AcceptSavePrompt(); |
2953 | 2908 |
2954 WaitForPasswordStore(); | 2909 WaitForPasswordStore(); |
2955 CheckThatCredentialsStored(password_store.get(), base::string16(), | 2910 CheckThatCredentialsStored(base::string16(), base::ASCIIToUTF16("pw")); |
2956 base::ASCIIToUTF16("pw")); | |
2957 } | 2911 } |
2958 | 2912 |
2959 // Tests that no bubble shown when a password form without username submitted | 2913 // Tests that no bubble shown when a password form without username submitted |
2960 // and there is stored credentials with the same password. | 2914 // and there is stored credentials with the same password. |
2961 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2915 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2962 PasswordRetryFormNoBubbleWhenPasswordTheSame) { | 2916 PasswordRetryFormNoBubbleWhenPasswordTheSame) { |
2963 // At first let us save credentials to the PasswordManager. | 2917 // At first let us save credentials to the PasswordManager. |
2964 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2918 scoped_refptr<password_manager::TestPasswordStore> password_store = |
2965 static_cast<password_manager::TestPasswordStore*>( | 2919 static_cast<password_manager::TestPasswordStore*>( |
2966 PasswordStoreFactory::GetForProfile( | 2920 PasswordStoreFactory::GetForProfile( |
(...skipping 12 matching lines...) Expand all Loading... |
2979 // same in one of the stored credentials. | 2933 // same in one of the stored credentials. |
2980 NavigateToFile("/password/password_form.html"); | 2934 NavigateToFile("/password/password_form.html"); |
2981 NavigationObserver observer(WebContents()); | 2935 NavigationObserver observer(WebContents()); |
2982 std::unique_ptr<BubbleObserver> prompt_observer( | 2936 std::unique_ptr<BubbleObserver> prompt_observer( |
2983 new BubbleObserver(WebContents())); | 2937 new BubbleObserver(WebContents())); |
2984 std::string fill_and_submit = | 2938 std::string fill_and_submit = |
2985 "document.getElementById('retry_password_field').value = 'pw';" | 2939 "document.getElementById('retry_password_field').value = 'pw';" |
2986 "document.getElementById('retry_submit_button').click()"; | 2940 "document.getElementById('retry_submit_button').click()"; |
2987 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2941 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
2988 observer.Wait(); | 2942 observer.Wait(); |
2989 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 2943 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
2990 EXPECT_FALSE(prompt_observer->IsShowingUpdatePrompt()); | 2944 EXPECT_FALSE(prompt_observer->IsUpdatePromptShownAutomatically()); |
2991 } | 2945 } |
2992 | 2946 |
2993 // Tests that the update bubble shown when a password form without username is | 2947 // Tests that the update bubble shown when a password form without username is |
2994 // submitted and there are stored credentials but with different password. | 2948 // submitted and there are stored credentials but with different password. |
2995 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2949 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2996 PasswordRetryFormUpdateBubbleShown) { | 2950 PasswordRetryFormUpdateBubbleShown) { |
2997 // At first let us save credentials to the PasswordManager. | 2951 // At first let us save credentials to the PasswordManager. |
2998 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2952 scoped_refptr<password_manager::TestPasswordStore> password_store = |
2999 static_cast<password_manager::TestPasswordStore*>( | 2953 static_cast<password_manager::TestPasswordStore*>( |
3000 PasswordStoreFactory::GetForProfile( | 2954 PasswordStoreFactory::GetForProfile( |
3001 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2955 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
3002 .get()); | 2956 .get()); |
3003 autofill::PasswordForm signin_form; | 2957 autofill::PasswordForm signin_form; |
3004 signin_form.signon_realm = embedded_test_server()->base_url().spec(); | 2958 signin_form.signon_realm = embedded_test_server()->base_url().spec(); |
3005 signin_form.username_value = base::ASCIIToUTF16("temp"); | 2959 signin_form.username_value = base::ASCIIToUTF16("temp"); |
3006 signin_form.password_value = base::ASCIIToUTF16("pw"); | 2960 signin_form.password_value = base::ASCIIToUTF16("pw"); |
3007 password_store->AddLogin(signin_form); | 2961 password_store->AddLogin(signin_form); |
3008 | 2962 |
3009 // Check that password update bubble is shown. | 2963 // Check that password update bubble is shown. |
3010 NavigateToFile("/password/password_form.html"); | 2964 NavigateToFile("/password/password_form.html"); |
3011 NavigationObserver observer(WebContents()); | 2965 NavigationObserver observer(WebContents()); |
3012 std::unique_ptr<BubbleObserver> prompt_observer( | 2966 std::unique_ptr<BubbleObserver> prompt_observer( |
3013 new BubbleObserver(WebContents())); | 2967 new BubbleObserver(WebContents())); |
3014 std::string fill_and_submit = | 2968 std::string fill_and_submit = |
3015 "document.getElementById('retry_password_field').value = 'new_pw';" | 2969 "document.getElementById('retry_password_field').value = 'new_pw';" |
3016 "document.getElementById('retry_submit_button').click()"; | 2970 "document.getElementById('retry_submit_button').click()"; |
3017 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 2971 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
3018 observer.Wait(); | 2972 observer.Wait(); |
3019 // The new password "new_pw" is used, so update prompt is expected. | 2973 // The new password "new_pw" is used, so update prompt is expected. |
3020 EXPECT_TRUE(prompt_observer->IsShowingUpdatePrompt()); | 2974 EXPECT_TRUE(prompt_observer->IsUpdatePromptShownAutomatically()); |
3021 | 2975 |
3022 const autofill::PasswordForm stored_form = | 2976 const autofill::PasswordForm stored_form = |
3023 password_store->stored_passwords().begin()->second[0]; | 2977 password_store->stored_passwords().begin()->second[0]; |
3024 prompt_observer->AcceptUpdatePrompt(stored_form); | 2978 prompt_observer->AcceptUpdatePrompt(stored_form); |
3025 | 2979 |
3026 WaitForPasswordStore(); | 2980 WaitForPasswordStore(); |
3027 CheckThatCredentialsStored(password_store.get(), base::ASCIIToUTF16("temp"), | 2981 CheckThatCredentialsStored(base::ASCIIToUTF16("temp"), |
3028 base::ASCIIToUTF16("new_pw")); | 2982 base::ASCIIToUTF16("new_pw")); |
3029 } | 2983 } |
3030 | 2984 |
3031 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2985 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
3032 NoCrashWhenNavigatingWithOpenAccountPicker) { | 2986 NoCrashWhenNavigatingWithOpenAccountPicker) { |
3033 // Save credentials with 'skip_zero_click'. | 2987 // Save credentials with 'skip_zero_click'. |
3034 scoped_refptr<password_manager::TestPasswordStore> password_store = | 2988 scoped_refptr<password_manager::TestPasswordStore> password_store = |
3035 static_cast<password_manager::TestPasswordStore*>( | 2989 static_cast<password_manager::TestPasswordStore*>( |
3036 PasswordStoreFactory::GetForProfile( | 2990 PasswordStoreFactory::GetForProfile( |
3037 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | 2991 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) |
(...skipping 28 matching lines...) Expand all Loading... |
3066 | 3020 |
3067 NavigationObserver observer(WebContents()); | 3021 NavigationObserver observer(WebContents()); |
3068 std::unique_ptr<BubbleObserver> prompt_observer( | 3022 std::unique_ptr<BubbleObserver> prompt_observer( |
3069 new BubbleObserver(WebContents())); | 3023 new BubbleObserver(WebContents())); |
3070 std::string fill_and_submit = | 3024 std::string fill_and_submit = |
3071 "document.getElementById('username').value = 'temp';" | 3025 "document.getElementById('username').value = 'temp';" |
3072 "document.getElementById('password').value = 'random';" | 3026 "document.getElementById('password').value = 'random';" |
3073 "document.getElementById('submit').click()"; | 3027 "document.getElementById('submit').click()"; |
3074 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); | 3028 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); |
3075 observer.Wait(); | 3029 observer.Wait(); |
3076 EXPECT_TRUE(prompt_observer->IsShowingSavePrompt()); | 3030 EXPECT_TRUE(prompt_observer->IsSavePromptShownAutomatically()); |
3077 } | 3031 } |
3078 | 3032 |
3079 // Tests that password suggestions still work if the fields have the | 3033 // Tests that password suggestions still work if the fields have the |
3080 // "autocomplete" attribute set to off. | 3034 // "autocomplete" attribute set to off. |
3081 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 3035 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
3082 AutofillSuggestionsForPasswordFormWithAutocompleteOff) { | 3036 AutofillSuggestionsForPasswordFormWithAutocompleteOff) { |
3083 std::string submit = | 3037 std::string submit = |
3084 "document.getElementById('username').value = 'temp';" | 3038 "document.getElementById('username').value = 'temp';" |
3085 "document.getElementById('password').value = 'mypassword';" | 3039 "document.getElementById('password').value = 'mypassword';" |
3086 "document.getElementById('submit').click();"; | 3040 "document.getElementById('submit').click();"; |
(...skipping 29 matching lines...) Expand all Loading... |
3116 NavigationObserver observer(WebContents()); | 3070 NavigationObserver observer(WebContents()); |
3117 std::unique_ptr<BubbleObserver> prompt_observer( | 3071 std::unique_ptr<BubbleObserver> prompt_observer( |
3118 new BubbleObserver(WebContents())); | 3072 new BubbleObserver(WebContents())); |
3119 std::string fill_and_submit_change_password = | 3073 std::string fill_and_submit_change_password = |
3120 "document.getElementById('username_field').value = 'user';" | 3074 "document.getElementById('username_field').value = 'user';" |
3121 "document.getElementById('password_field').value = 'password';" | 3075 "document.getElementById('password_field').value = 'password';" |
3122 "document.getElementById('input_submit_button').click()"; | 3076 "document.getElementById('input_submit_button').click()"; |
3123 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 3077 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
3124 fill_and_submit_change_password)); | 3078 fill_and_submit_change_password)); |
3125 observer.Wait(); | 3079 observer.Wait(); |
3126 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 3080 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
3127 | 3081 |
3128 // Verify that the form's 'skip_zero_click' is not updated. | 3082 // Verify that the form's 'skip_zero_click' is not updated. |
3129 auto& passwords_map = password_store->stored_passwords(); | 3083 auto& passwords_map = password_store->stored_passwords(); |
3130 ASSERT_EQ(1u, passwords_map.size()); | 3084 ASSERT_EQ(1u, passwords_map.size()); |
3131 auto& passwords_vector = passwords_map.begin()->second; | 3085 auto& passwords_vector = passwords_map.begin()->second; |
3132 ASSERT_EQ(1u, passwords_vector.size()); | 3086 ASSERT_EQ(1u, passwords_vector.size()); |
3133 const autofill::PasswordForm& form = passwords_vector[0]; | 3087 const autofill::PasswordForm& form = passwords_vector[0]; |
3134 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value); | 3088 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value); |
3135 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value); | 3089 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value); |
3136 EXPECT_TRUE(form.skip_zero_click); | 3090 EXPECT_TRUE(form.skip_zero_click); |
(...skipping 22 matching lines...) Expand all Loading... |
3159 NavigationObserver observer(WebContents()); | 3113 NavigationObserver observer(WebContents()); |
3160 std::unique_ptr<BubbleObserver> prompt_observer( | 3114 std::unique_ptr<BubbleObserver> prompt_observer( |
3161 new BubbleObserver(WebContents())); | 3115 new BubbleObserver(WebContents())); |
3162 std::string fill_and_submit_change_password = | 3116 std::string fill_and_submit_change_password = |
3163 "document.getElementById('username_field').value = 'user';" | 3117 "document.getElementById('username_field').value = 'user';" |
3164 "document.getElementById('password_field').value = 'password';" | 3118 "document.getElementById('password_field').value = 'password';" |
3165 "document.getElementById('input_submit_button').click()"; | 3119 "document.getElementById('input_submit_button').click()"; |
3166 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), | 3120 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), |
3167 fill_and_submit_change_password)); | 3121 fill_and_submit_change_password)); |
3168 observer.Wait(); | 3122 observer.Wait(); |
3169 EXPECT_FALSE(prompt_observer->IsShowingSavePrompt()); | 3123 EXPECT_FALSE(prompt_observer->IsSavePromptShownAutomatically()); |
3170 | 3124 |
3171 // Verify that the form's 'skip_zero_click' is not updated. | 3125 // Verify that the form's 'skip_zero_click' is not updated. |
3172 auto& passwords_map = password_store->stored_passwords(); | 3126 auto& passwords_map = password_store->stored_passwords(); |
3173 ASSERT_EQ(1u, passwords_map.size()); | 3127 ASSERT_EQ(1u, passwords_map.size()); |
3174 auto& passwords_vector = passwords_map.begin()->second; | 3128 auto& passwords_vector = passwords_map.begin()->second; |
3175 ASSERT_EQ(1u, passwords_vector.size()); | 3129 ASSERT_EQ(1u, passwords_vector.size()); |
3176 const autofill::PasswordForm& form = passwords_vector[0]; | 3130 const autofill::PasswordForm& form = passwords_vector[0]; |
3177 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value); | 3131 EXPECT_EQ(base::ASCIIToUTF16("user"), form.username_value); |
3178 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value); | 3132 EXPECT_EQ(base::ASCIIToUTF16("password"), form.password_value); |
3179 EXPECT_TRUE(form.skip_zero_click); | 3133 EXPECT_TRUE(form.skip_zero_click); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3310 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(), | 3264 ASSERT_TRUE(content::ExecuteScriptWithoutUserGesture(RenderFrameHost(), |
3311 "var noop = 'noop';")); | 3265 "var noop = 'noop';")); |
3312 // Ensure the warning was not triggered. | 3266 // Ensure the warning was not triggered. |
3313 content::RunAllBlockingPoolTasksUntilIdle(); | 3267 content::RunAllBlockingPoolTasksUntilIdle(); |
3314 ASSERT_FALSE(observing_autofill_client->popup_shown()); | 3268 ASSERT_FALSE(observing_autofill_client->popup_shown()); |
3315 // Ensure the histogram remains empty. | 3269 // Ensure the histogram remains empty. |
3316 histograms.ExpectTotalCount(kHistogram, 0); | 3270 histograms.ExpectTotalCount(kHistogram, 0); |
3317 } | 3271 } |
3318 | 3272 |
3319 } // namespace password_manager | 3273 } // namespace password_manager |
OLD | NEW |