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