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

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

Issue 582833005: Save password infobar should only work on schemes on which the bubble does (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing with Nits addressed Created 6 years, 2 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
« no previous file with comments | « chrome/browser/password_manager/chrome_password_manager_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/path_service.h"
10 #include "base/run_loop.h" 11 #include "base/run_loop.h"
11 #include "base/stl_util.h" 12 #include "base/stl_util.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/infobars/infobar_service.h" 16 #include "chrome/browser/infobars/infobar_service.h"
16 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 17 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
17 #include "chrome/browser/password_manager/password_store_factory.h" 18 #include "chrome/browser/password_manager/password_store_factory.h"
18 #include "chrome/browser/password_manager/test_password_store_service.h" 19 #include "chrome/browser/password_manager/test_password_store_service.h"
19 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/login/login_prompt.h" 21 #include "chrome/browser/ui/login/login_prompt.h"
21 #include "chrome/browser/ui/login/login_prompt_test_utils.h" 22 #include "chrome/browser/ui/login/login_prompt_test_utils.h"
22 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 23 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/chrome_version_info.h" 27 #include "chrome/common/chrome_version_info.h"
26 #include "chrome/test/base/in_process_browser_test.h" 28 #include "chrome/test/base/in_process_browser_test.h"
27 #include "chrome/test/base/test_switches.h" 29 #include "chrome/test/base/test_switches.h"
28 #include "chrome/test/base/ui_test_utils.h" 30 #include "chrome/test/base/ui_test_utils.h"
29 #include "components/autofill/core/browser/autofill_test_utils.h" 31 #include "components/autofill/core/browser/autofill_test_utils.h"
30 #include "components/infobars/core/confirm_infobar_delegate.h" 32 #include "components/infobars/core/confirm_infobar_delegate.h"
31 #include "components/infobars/core/infobar.h" 33 #include "components/infobars/core/infobar.h"
32 #include "components/infobars/core/infobar_manager.h" 34 #include "components/infobars/core/infobar_manager.h"
33 #include "components/password_manager/core/browser/test_password_store.h" 35 #include "components/password_manager/core/browser/test_password_store.h"
34 #include "components/password_manager/core/common/password_manager_switches.h" 36 #include "components/password_manager/core/common/password_manager_switches.h"
35 #include "content/public/browser/navigation_controller.h" 37 #include "content/public/browser/navigation_controller.h"
36 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/render_frame_host.h" 39 #include "content/public/browser/render_frame_host.h"
38 #include "content/public/browser/render_view_host.h" 40 #include "content/public/browser/render_view_host.h"
39 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
40 #include "content/public/browser/web_contents_observer.h" 42 #include "content/public/browser/web_contents_observer.h"
41 #include "content/public/common/content_switches.h" 43 #include "content/public/common/content_switches.h"
42 #include "content/public/test/browser_test_utils.h" 44 #include "content/public/test/browser_test_utils.h"
43 #include "content/public/test/test_utils.h" 45 #include "content/public/test/test_utils.h"
46 #include "net/base/filename_util.h"
44 #include "net/test/embedded_test_server/embedded_test_server.h" 47 #include "net/test/embedded_test_server/embedded_test_server.h"
45 #include "net/test/embedded_test_server/http_request.h" 48 #include "net/test/embedded_test_server/http_request.h"
46 #include "net/test/embedded_test_server/http_response.h" 49 #include "net/test/embedded_test_server/http_response.h"
47 #include "net/test/spawned_test_server/spawned_test_server.h" 50 #include "net/test/spawned_test_server/spawned_test_server.h"
48 #include "net/url_request/test_url_fetcher_factory.h" 51 #include "net/url_request/test_url_fetcher_factory.h"
49 #include "testing/gmock/include/gmock/gmock.h" 52 #include "testing/gmock/include/gmock/gmock.h"
50 #include "third_party/WebKit/public/web/WebInputEvent.h" 53 #include "third_party/WebKit/public/web/WebInputEvent.h"
51 #include "ui/events/keycodes/keyboard_codes.h" 54 #include "ui/events/keycodes/keyboard_codes.h"
52 #include "ui/gfx/geometry/point.h" 55 #include "ui/gfx/geometry/point.h"
53 56
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 virtual void AcceptImpl() const OVERRIDE { 204 virtual void AcceptImpl() const OVERRIDE {
202 ui_controller_->SavePassword(); 205 ui_controller_->SavePassword();
203 EXPECT_FALSE(IsShowingPrompt()); 206 EXPECT_FALSE(IsShowingPrompt());
204 } 207 }
205 208
206 ManagePasswordsUIController* const ui_controller_; 209 ManagePasswordsUIController* const ui_controller_;
207 210
208 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); 211 DISALLOW_COPY_AND_ASSIGN(BubbleObserver);
209 }; 212 };
210 213
214 GURL GetFileURL(const char* filename) {
215 base::FilePath path;
216 PathService::Get(chrome::DIR_TEST_DATA, &path);
217 path = path.AppendASCII("password").AppendASCII(filename);
218 CHECK(base::PathExists(path));
219 return net::FilePathToFileURL(path);
220 }
221
211 // static 222 // static
212 scoped_ptr<PromptObserver> PromptObserver::Create( 223 scoped_ptr<PromptObserver> PromptObserver::Create(
213 content::WebContents* web_contents) { 224 content::WebContents* web_contents) {
214 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) { 225 if (ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled()) {
215 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents)); 226 return scoped_ptr<PromptObserver>(new BubbleObserver(web_contents));
216 } else { 227 } else {
217 return scoped_ptr<PromptObserver>(new InfoBarObserver(web_contents)); 228 return scoped_ptr<PromptObserver>(new InfoBarObserver(web_contents));
218 } 229 }
219 } 230 }
220 231
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 "var username = form.children[0];" 829 "var username = form.children[0];"
819 "username.value = 'temp';" 830 "username.value = 'temp';"
820 "var password = form.children[1];" 831 "var password = form.children[1];"
821 "password.value = 'random';" 832 "password.value = 'random';"
822 "form.children[2].click()"; // form.children[2] is the submit button. 833 "form.children[2].click()"; // form.children[2] is the submit button.
823 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 834 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
824 observer.Wait(); 835 observer.Wait();
825 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); 836 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
826 } 837 }
827 838
839 // Test for checking that no prompt is shown for URLs with file: scheme.
840 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
841 NoPromptForFileSchemeURLs) {
842 GURL url = GetFileURL("password_form.html");
843 ui_test_utils::NavigateToURL(browser(), url);
844
845 NavigationObserver observer(WebContents());
846 scoped_ptr<PromptObserver> prompt_observer(
847 PromptObserver::Create(WebContents()));
848 std::string fill_and_submit =
849 "document.getElementById('username_field').value = 'temp';"
850 "document.getElementById('password_field').value = 'random';"
851 "document.getElementById('input_submit_button').click();";
852 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
853 observer.Wait();
854 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
855 }
856
828 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, DeleteFrameBeforeSubmit) { 857 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, DeleteFrameBeforeSubmit) {
829 NavigateToFile("/password/multi_frames.html"); 858 NavigateToFile("/password/multi_frames.html");
830 859
831 NavigationObserver observer(WebContents()); 860 NavigationObserver observer(WebContents());
832 // Make sure we save some password info from an iframe and then destroy it. 861 // Make sure we save some password info from an iframe and then destroy it.
833 std::string save_and_remove = 862 std::string save_and_remove =
834 "var first_frame = document.getElementById('first_frame');" 863 "var first_frame = document.getElementById('first_frame');"
835 "var frame_doc = first_frame.contentDocument;" 864 "var frame_doc = first_frame.contentDocument;"
836 "frame_doc.getElementById('username_field').value = 'temp';" 865 "frame_doc.getElementById('username_field').value = 'temp';"
837 "frame_doc.getElementById('password_field').value = 'random';" 866 "frame_doc.getElementById('password_field').value = 'random';"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 NavigationObserver observer(WebContents()); 1201 NavigationObserver observer(WebContents());
1173 scoped_ptr<PromptObserver> prompt_observer( 1202 scoped_ptr<PromptObserver> prompt_observer(
1174 PromptObserver::Create(WebContents())); 1203 PromptObserver::Create(WebContents()));
1175 ui_test_utils::NavigateToURL(browser(), https_url); 1204 ui_test_utils::NavigateToURL(browser(), https_url);
1176 1205
1177 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); 1206 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html");
1178 observer.Wait(); 1207 observer.Wait();
1179 1208
1180 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); 1209 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
1181 } 1210 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/chrome_password_manager_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698