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

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

Issue 2270333002: Reland: [Autofill] Migrate ContentPasswordManagerDriver<-->Password{Autofill,Generation}Agent IPCs … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 #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 13 matching lines...) Expand all
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_navigator_params.h" 25 #include "chrome/browser/ui/browser_navigator_params.h"
26 #include "chrome/browser/ui/login/login_handler.h" 26 #include "chrome/browser/ui/login/login_handler.h"
27 #include "chrome/browser/ui/login/login_handler_test_utils.h" 27 #include "chrome/browser/ui/login/login_handler_test_utils.h"
28 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 28 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
29 #include "chrome/browser/ui/tabs/tab_strip_model.h" 29 #include "chrome/browser/ui/tabs/tab_strip_model.h"
30 #include "chrome/common/channel_info.h" 30 #include "chrome/common/channel_info.h"
31 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
32 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/test/base/ui_test_utils.h" 33 #include "chrome/test/base/ui_test_utils.h"
34 #include "components/autofill/content/common/autofill_messages.h"
35 #include "components/autofill/core/browser/autofill_test_utils.h" 34 #include "components/autofill/core/browser/autofill_test_utils.h"
36 #include "components/autofill/core/browser/test_autofill_client.h" 35 #include "components/autofill/core/browser/test_autofill_client.h"
37 #include "components/autofill/core/common/password_form.h" 36 #include "components/autofill/core/common/password_form.h"
38 #include "components/password_manager/content/browser/content_password_manager_d river.h" 37 #include "components/password_manager/content/browser/content_password_manager_d river.h"
39 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h" 38 #include "components/password_manager/content/browser/content_password_manager_d river_factory.h"
40 #include "components/password_manager/core/browser/login_model.h" 39 #include "components/password_manager/core/browser/login_model.h"
41 #include "components/password_manager/core/browser/test_password_store.h" 40 #include "components/password_manager/core/browser/test_password_store.h"
42 #include "components/password_manager/core/common/password_manager_features.h" 41 #include "components/password_manager/core/common/password_manager_features.h"
43 #include "components/version_info/version_info.h" 42 #include "components/version_info/version_info.h"
44 #include "content/public/browser/navigation_controller.h" 43 #include "content/public/browser/navigation_controller.h"
45 #include "content/public/browser/notification_service.h" 44 #include "content/public/browser/notification_service.h"
46 #include "content/public/browser/render_frame_host.h" 45 #include "content/public/browser/render_frame_host.h"
47 #include "content/public/browser/render_process_host.h" 46 #include "content/public/browser/render_process_host.h"
48 #include "content/public/browser/render_view_host.h" 47 #include "content/public/browser/render_view_host.h"
49 #include "content/public/browser/web_contents.h" 48 #include "content/public/browser/web_contents.h"
50 #include "content/public/browser/web_contents_observer.h" 49 #include "content/public/browser/web_contents_observer.h"
51 #include "content/public/common/content_switches.h" 50 #include "content/public/common/content_switches.h"
52 #include "content/public/test/browser_test_utils.h" 51 #include "content/public/test/browser_test_utils.h"
53 #include "content/public/test/test_utils.h" 52 #include "content/public/test/test_utils.h"
54 #include "ipc/ipc_security_test_util.h"
55 #include "net/base/filename_util.h" 53 #include "net/base/filename_util.h"
56 #include "net/dns/mock_host_resolver.h" 54 #include "net/dns/mock_host_resolver.h"
57 #include "net/test/embedded_test_server/embedded_test_server.h" 55 #include "net/test/embedded_test_server/embedded_test_server.h"
58 #include "net/test/embedded_test_server/http_request.h" 56 #include "net/test/embedded_test_server/http_request.h"
59 #include "net/test/embedded_test_server/http_response.h" 57 #include "net/test/embedded_test_server/http_response.h"
60 #include "net/url_request/test_url_fetcher_factory.h" 58 #include "net/url_request/test_url_fetcher_factory.h"
61 #include "testing/gmock/include/gmock/gmock.h" 59 #include "testing/gmock/include/gmock/gmock.h"
62 #include "third_party/WebKit/public/web/WebInputEvent.h" 60 #include "third_party/WebKit/public/web/WebInputEvent.h"
63 #include "ui/events/keycodes/keyboard_codes.h" 61 #include "ui/events/keycodes/keyboard_codes.h"
64 #include "ui/gfx/geometry/point.h" 62 #include "ui/gfx/geometry/point.h"
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 1627
1630 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 1628 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
1631 InFrameNavigationDoesNotClearPopupState) { 1629 InFrameNavigationDoesNotClearPopupState) {
1632 // Mock out the AutofillClient so we know how long to wait. Unfortunately 1630 // Mock out the AutofillClient so we know how long to wait. Unfortunately
1633 // there isn't otherwise a good even to wait on to verify that the popup 1631 // there isn't otherwise a good even to wait on to verify that the popup
1634 // would have been shown. 1632 // would have been shown.
1635 password_manager::ContentPasswordManagerDriverFactory* driver_factory = 1633 password_manager::ContentPasswordManagerDriverFactory* driver_factory =
1636 password_manager::ContentPasswordManagerDriverFactory::FromWebContents( 1634 password_manager::ContentPasswordManagerDriverFactory::FromWebContents(
1637 WebContents()); 1635 WebContents());
1638 ObservingAutofillClient observing_autofill_client; 1636 ObservingAutofillClient observing_autofill_client;
1639 driver_factory->TestingSetDriverForFrame( 1637 password_manager::ContentPasswordManagerDriver* driver =
1640 RenderViewHost()->GetMainFrame(), 1638 driver_factory->GetDriverForFrame(RenderViewHost()->GetMainFrame());
1641 base::WrapUnique(new password_manager::ContentPasswordManagerDriver( 1639 DCHECK(driver);
1642 RenderViewHost()->GetMainFrame(), 1640 driver->GetPasswordAutofillManager()->set_autofill_client(
1643 ChromePasswordManagerClient::FromWebContents(WebContents()), 1641 &observing_autofill_client);
1644 &observing_autofill_client)));
1645 1642
1646 NavigateToFile("/password/password_form.html"); 1643 NavigateToFile("/password/password_form.html");
1647 1644
1648 NavigationObserver form_submit_observer(WebContents()); 1645 NavigationObserver form_submit_observer(WebContents());
1649 std::unique_ptr<BubbleObserver> prompt_observer( 1646 std::unique_ptr<BubbleObserver> prompt_observer(
1650 new BubbleObserver(WebContents())); 1647 new BubbleObserver(WebContents()));
1651 std::string fill = 1648 std::string fill =
1652 "document.getElementById('username_field').value = 'temp';" 1649 "document.getElementById('username_field').value = 'temp';"
1653 "document.getElementById('password_field').value = 'random123';" 1650 "document.getElementById('password_field').value = 'random123';"
1654 "document.getElementById('input_submit_button').click();"; 1651 "document.getElementById('input_submit_button').click();";
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 iframe_observer.Wait(); 2042 iframe_observer.Wait();
2046 2043
2047 // The iframe should get its own process. 2044 // The iframe should get its own process.
2048 content::RenderFrameHost* main_frame = WebContents()->GetMainFrame(); 2045 content::RenderFrameHost* main_frame = WebContents()->GetMainFrame();
2049 content::RenderFrameHost* iframe = iframe_observer.render_frame_host(); 2046 content::RenderFrameHost* iframe = iframe_observer.render_frame_host();
2050 content::SiteInstance* main_site_instance = main_frame->GetSiteInstance(); 2047 content::SiteInstance* main_site_instance = main_frame->GetSiteInstance();
2051 content::SiteInstance* iframe_site_instance = iframe->GetSiteInstance(); 2048 content::SiteInstance* iframe_site_instance = iframe->GetSiteInstance();
2052 EXPECT_NE(main_site_instance, iframe_site_instance); 2049 EXPECT_NE(main_site_instance, iframe_site_instance);
2053 EXPECT_NE(main_frame->GetProcess(), iframe->GetProcess()); 2050 EXPECT_NE(main_frame->GetProcess(), iframe->GetProcess());
2054 2051
2052 content::RenderProcessHostWatcher iframe_killed(
2053 iframe->GetProcess(),
2054 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
2055
2055 // Try to get cross-site passwords from the subframe's process and wait for it 2056 // Try to get cross-site passwords from the subframe's process and wait for it
2056 // to be killed. 2057 // to be killed.
2057 std::vector<autofill::PasswordForm> password_forms; 2058 std::vector<autofill::PasswordForm> password_forms;
2058 password_forms.push_back(autofill::PasswordForm()); 2059 password_forms.push_back(autofill::PasswordForm());
2059 password_forms.back().origin = main_frame_url; 2060 password_forms.back().origin = main_frame_url;
2060 AutofillHostMsg_PasswordFormsParsed illegal_forms_parsed( 2061 ContentPasswordManagerDriverFactory* factory =
2061 iframe->GetRoutingID(), password_forms); 2062 ContentPasswordManagerDriverFactory::FromWebContents(WebContents());
2062 2063 EXPECT_TRUE(factory);
2063 content::RenderProcessHostWatcher iframe_killed( 2064 ContentPasswordManagerDriver* driver = factory->GetDriverForFrame(iframe);
2064 iframe->GetProcess(), 2065 EXPECT_TRUE(driver);
2065 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 2066 driver->PasswordFormsParsed(password_forms);
2066
2067 IPC::IpcSecurityTestUtil::PwnMessageReceived(
2068 iframe->GetProcess()->GetChannel(), illegal_forms_parsed);
2069 2067
2070 iframe_killed.Wait(); 2068 iframe_killed.Wait();
2071 } 2069 }
2072 2070
2073 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, 2071 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
2074 ChangePwdNoAccountStored) { 2072 ChangePwdNoAccountStored) {
2075 NavigateToFile("/password/password_form.html"); 2073 NavigateToFile("/password/password_form.html");
2076 2074
2077 // Fill a form and submit through a <input type="submit"> button. 2075 // Fill a form and submit through a <input type="submit"> button.
2078 NavigationObserver observer(WebContents()); 2076 NavigationObserver observer(WebContents());
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
3047 // about all frames, not just the main one. The factories should receive 3045 // about all frames, not just the main one. The factories should receive
3048 // messages for non-main frames, in particular 3046 // messages for non-main frames, in particular
3049 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the 3047 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the
3050 // factories hear about such frames, this would crash. 3048 // factories hear about such frames, this would crash.
3051 tab_strip_model->AddWebContents(detached_web_contents.release(), -1, 3049 tab_strip_model->AddWebContents(detached_web_contents.release(), -1,
3052 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 3050 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
3053 TabStripModel::ADD_ACTIVE); 3051 TabStripModel::ADD_ACTIVE);
3054 } 3052 }
3055 3053
3056 } // namespace password_manager 3054 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698