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 13 matching lines...) Expand all Loading... | |
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 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1630 | 1628 |
1631 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 1629 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
1632 InFrameNavigationDoesNotClearPopupState) { | 1630 InFrameNavigationDoesNotClearPopupState) { |
1633 // Mock out the AutofillClient so we know how long to wait. Unfortunately | 1631 // Mock out the AutofillClient so we know how long to wait. Unfortunately |
1634 // there isn't otherwise a good even to wait on to verify that the popup | 1632 // there isn't otherwise a good even to wait on to verify that the popup |
1635 // would have been shown. | 1633 // would have been shown. |
1636 password_manager::ContentPasswordManagerDriverFactory* driver_factory = | 1634 password_manager::ContentPasswordManagerDriverFactory* driver_factory = |
1637 password_manager::ContentPasswordManagerDriverFactory::FromWebContents( | 1635 password_manager::ContentPasswordManagerDriverFactory::FromWebContents( |
1638 WebContents()); | 1636 WebContents()); |
1639 ObservingAutofillClient observing_autofill_client; | 1637 ObservingAutofillClient observing_autofill_client; |
1640 driver_factory->TestingSetDriverForFrame( | 1638 password_manager::ContentPasswordManagerDriver* driver = |
leonhsl(Using Gerrit)
2016/08/23 08:23:48
The mojo connection has already been established b
| |
1641 RenderViewHost()->GetMainFrame(), | 1639 driver_factory->GetDriverForFrame(RenderViewHost()->GetMainFrame()); |
1642 base::WrapUnique(new password_manager::ContentPasswordManagerDriver( | 1640 DCHECK(driver); |
1643 RenderViewHost()->GetMainFrame(), | 1641 driver->GetPasswordAutofillManager()->TestingSetAutofillClient( |
1644 ChromePasswordManagerClient::FromWebContents(WebContents()), | 1642 &observing_autofill_client); |
1645 &observing_autofill_client))); | |
1646 | 1643 |
1647 NavigateToFile("/password/password_form.html"); | 1644 NavigateToFile("/password/password_form.html"); |
1648 | 1645 |
1649 NavigationObserver form_submit_observer(WebContents()); | 1646 NavigationObserver form_submit_observer(WebContents()); |
1650 std::unique_ptr<BubbleObserver> prompt_observer( | 1647 std::unique_ptr<BubbleObserver> prompt_observer( |
1651 new BubbleObserver(WebContents())); | 1648 new BubbleObserver(WebContents())); |
1652 std::string fill = | 1649 std::string fill = |
1653 "document.getElementById('username_field').value = 'temp';" | 1650 "document.getElementById('username_field').value = 'temp';" |
1654 "document.getElementById('password_field').value = 'random123';" | 1651 "document.getElementById('password_field').value = 'random123';" |
1655 "document.getElementById('input_submit_button').click();"; | 1652 "document.getElementById('input_submit_button').click();"; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2046 iframe_observer.Wait(); | 2043 iframe_observer.Wait(); |
2047 | 2044 |
2048 // The iframe should get its own process. | 2045 // The iframe should get its own process. |
2049 content::RenderFrameHost* main_frame = WebContents()->GetMainFrame(); | 2046 content::RenderFrameHost* main_frame = WebContents()->GetMainFrame(); |
2050 content::RenderFrameHost* iframe = iframe_observer.render_frame_host(); | 2047 content::RenderFrameHost* iframe = iframe_observer.render_frame_host(); |
2051 content::SiteInstance* main_site_instance = main_frame->GetSiteInstance(); | 2048 content::SiteInstance* main_site_instance = main_frame->GetSiteInstance(); |
2052 content::SiteInstance* iframe_site_instance = iframe->GetSiteInstance(); | 2049 content::SiteInstance* iframe_site_instance = iframe->GetSiteInstance(); |
2053 EXPECT_NE(main_site_instance, iframe_site_instance); | 2050 EXPECT_NE(main_site_instance, iframe_site_instance); |
2054 EXPECT_NE(main_frame->GetProcess(), iframe->GetProcess()); | 2051 EXPECT_NE(main_frame->GetProcess(), iframe->GetProcess()); |
2055 | 2052 |
2053 content::RenderProcessHostWatcher iframe_killed( | |
2054 iframe->GetProcess(), | |
2055 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | |
2056 | |
2056 // Try to get cross-site passwords from the subframe's process and wait for it | 2057 // Try to get cross-site passwords from the subframe's process and wait for it |
2057 // to be killed. | 2058 // to be killed. |
2058 std::vector<autofill::PasswordForm> password_forms; | 2059 std::vector<autofill::PasswordForm> password_forms; |
2059 password_forms.push_back(autofill::PasswordForm()); | 2060 password_forms.push_back(autofill::PasswordForm()); |
2060 password_forms.back().origin = main_frame_url; | 2061 password_forms.back().origin = main_frame_url; |
2061 AutofillHostMsg_PasswordFormsParsed illegal_forms_parsed( | 2062 ContentPasswordManagerDriverFactory* factory = |
2062 iframe->GetRoutingID(), password_forms); | 2063 ContentPasswordManagerDriverFactory::FromWebContents(WebContents()); |
2063 | 2064 EXPECT_TRUE(factory); |
2064 content::RenderProcessHostWatcher iframe_killed( | 2065 ContentPasswordManagerDriver* driver = factory->GetDriverForFrame(iframe); |
2065 iframe->GetProcess(), | 2066 EXPECT_TRUE(driver); |
2066 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 2067 driver->PasswordFormsParsed(password_forms); |
2067 | |
2068 IPC::IpcSecurityTestUtil::PwnMessageReceived( | |
2069 iframe->GetProcess()->GetChannel(), illegal_forms_parsed); | |
2070 | 2068 |
2071 iframe_killed.Wait(); | 2069 iframe_killed.Wait(); |
2072 } | 2070 } |
2073 | 2071 |
2074 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, | 2072 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase, |
2075 ChangePwdNoAccountStored) { | 2073 ChangePwdNoAccountStored) { |
2076 NavigateToFile("/password/password_form.html"); | 2074 NavigateToFile("/password/password_form.html"); |
2077 | 2075 |
2078 // Fill a form and submit through a <input type="submit"> button. | 2076 // Fill a form and submit through a <input type="submit"> button. |
2079 NavigationObserver observer(WebContents()); | 2077 NavigationObserver observer(WebContents()); |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3046 // about all frames, not just the main one. The factories should receive | 3044 // about all frames, not just the main one. The factories should receive |
3047 // messages for non-main frames, in particular | 3045 // messages for non-main frames, in particular |
3048 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the | 3046 // AutofillHostMsg_PasswordFormsParsed. If that were the first time the |
3049 // factories hear about such frames, this would crash. | 3047 // factories hear about such frames, this would crash. |
3050 tab_strip_model->AddWebContents(detached_web_contents.release(), -1, | 3048 tab_strip_model->AddWebContents(detached_web_contents.release(), -1, |
3051 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 3049 ::ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
3052 TabStripModel::ADD_ACTIVE); | 3050 TabStripModel::ADD_ACTIVE); |
3053 } | 3051 } |
3054 | 3052 |
3055 } // namespace password_manager | 3053 } // namespace password_manager |
OLD | NEW |