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

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

Issue 137893009: [Password Autofill] Catch XHR submitted forms where onsubmit() wasn't called. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 NavigationObserver observer(WebContents()); 293 NavigationObserver observer(WebContents());
294 std::string fill_and_submit = 294 std::string fill_and_submit =
295 "document.getElementById('username_field').value = 'temp';" 295 "document.getElementById('username_field').value = 'temp';"
296 "document.getElementById('password_field').value = 'random';" 296 "document.getElementById('password_field').value = 'random';"
297 "document.getElementById('submit_button').click()"; 297 "document.getElementById('submit_button').click()";
298 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 298 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
299 observer.Wait(); 299 observer.Wait();
300 EXPECT_TRUE(observer.infobar_shown()); 300 EXPECT_TRUE(observer.infobar_shown());
301 } 301 }
302 302
303 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, NoPromptForOtherXHR) { 303 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
304 PromptForXHRWithoutOnSubmit) {
304 NavigateToFile("/password/password_xhr_submit.html"); 305 NavigateToFile("/password/password_xhr_submit.html");
305 306
306 // Verify that if random XHR navigation occurs, we don't try and save the 307 // Verify that if XHR navigation and the form is properly filled out, we
vabr (Chromium) 2014/01/16 09:22:10 nit: The sentence "if XHR navigation" seems to lac
Garrett Casto 2014/01/16 22:23:59 Done.
307 // password. 308 // try and save the password even though onsubmit hasn't been called.
308 //
309 // We may want to change this functionality in the future to account for
310 // cases where the element that users click on isn't a submit button.
311 NavigationObserver observer(WebContents()); 309 NavigationObserver observer(WebContents());
312 std::string fill_and_navigate = 310 std::string fill_and_navigate =
313 "document.getElementById('username_field').value = 'temp';" 311 "document.getElementById('username_field').value = 'temp';"
314 "document.getElementById('password_field').value = 'random';" 312 "document.getElementById('password_field').value = 'random';"
315 "send_xhr()"; 313 "send_xhr()";
316 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate)); 314 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_navigate));
317 observer.Wait(); 315 observer.Wait();
318 EXPECT_FALSE(observer.infobar_shown()); 316 EXPECT_TRUE(observer.infobar_shown());
319 } 317 }
320 318
321 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 319 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
320 NoPromptIfLinkClicked) {
321 NavigateToFile("/password/password_form.html");
322
323 std::string fill_and_click_link =
324 "document.getElementById('username_field').value = 'temp';"
325 "document.getElementById('password_field').value = 'random';"
326 "document.getElementById('link').click();";
327
328 }
vabr (Chromium) 2014/01/16 09:22:10 Did you forget to check that the prompt does not s
Garrett Casto 2014/01/16 22:23:59 Whoops, fixed.
329
330 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
322 VerifyPasswordGenerationUpload) { 331 VerifyPasswordGenerationUpload) {
323 // Prevent Autofill requests from actually going over the wire. 332 // Prevent Autofill requests from actually going over the wire.
324 net::TestURLFetcherFactory factory; 333 net::TestURLFetcherFactory factory;
325 // Disable Autofill requesting access to AddressBook data. This causes 334 // Disable Autofill requesting access to AddressBook data. This causes
326 // the test to hang on Mac. 335 // the test to hang on Mac.
327 autofill::test::DisableSystemServices(browser()->profile()); 336 autofill::test::DisableSystemServices(browser()->profile());
328 337
329 // Visit a signup form. 338 // Visit a signup form.
330 NavigateToFile("/password/signup_form.html"); 339 NavigateToFile("/password/signup_form.html");
331 340
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 "document.getElementById('username_field').value = 'temp';" 478 "document.getElementById('username_field').value = 'temp';"
470 "document.getElementById('password_field').value = 'random';" 479 "document.getElementById('password_field').value = 'random';"
471 "document.getElementById('input_submit_button').click();" 480 "document.getElementById('input_submit_button').click();"
472 "window.location.href = 'done.html';"; 481 "window.location.href = 'done.html';";
473 482
474 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), save_and_remove)); 483 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), save_and_remove));
475 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame)); 484 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), navigate_frame));
476 observer.Wait(); 485 observer.Wait();
477 // The only thing we check here is that there is no use-after-free reported. 486 // The only thing we check here is that there is no use-after-free reported.
478 } 487 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698