Index: chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
diff --git a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
index 802bdcef1797161c2ab75ee008efb0b534f841b8..157aaee2e67d06d3e7a08d3f75a5d6fba41eb830 100644 |
--- a/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
+++ b/chrome/browser/password_manager/chrome_password_manager_client_unittest.cc |
@@ -266,3 +266,58 @@ TEST_F(ChromePasswordManagerClientTest, ShouldFilterAutofillResult) { |
NavigateAndCommit(GURL("https://accounts.google.com/Login")); |
EXPECT_TRUE(client->ShouldFilterAutofillResult(form)); |
} |
+ |
+TEST_F(ChromePasswordManagerClientTest, |
+ IsPasswordManagerEnabledForCurrentPage) { |
+ ChromePasswordManagerClient* client = GetClient(); |
+ NavigateAndCommit( |
+ GURL("https://accounts.google.com/ServiceLogin?continue=" |
+ "https://passwords.google.com/settings&rart=123")); |
+ EXPECT_FALSE(client->IsPasswordManagerEnabledForCurrentPage()); |
+ |
+ // Password site is inaccesible via HTTP, but because of HSTS the following |
+ // link should still continue to https://passwords.google.com. |
+ NavigateAndCommit( |
+ GURL("https://accounts.google.com/ServiceLogin?continue=" |
+ "http://passwords.google.com/settings&rart=123")); |
+ EXPECT_FALSE(client->IsPasswordManagerEnabledForCurrentPage()); |
+ |
+ // Specifying default port still passes. |
+ NavigateAndCommit( |
+ GURL("https://accounts.google.com/ServiceLogin?continue=" |
+ "https://passwords.google.com:443/settings&rart=123")); |
+ EXPECT_FALSE(client->IsPasswordManagerEnabledForCurrentPage()); |
+ |
+ // Encoded URL is considered the same. |
+ NavigateAndCommit( |
+ GURL("https://accounts.google.com/ServiceLogin?continue=" |
+ "https://passwords.%67oogle.com/settings&rart=123")); |
+ EXPECT_FALSE(client->IsPasswordManagerEnabledForCurrentPage()); |
+ |
+ // Fully qualified domain name is considered a different hostname by GURL. |
+ // Ideally this would not be the case, but this quirk can be avoided by |
+ // verification on the server. This test is simply documentation of this |
+ // behavior. |
+ NavigateAndCommit( |
+ GURL("https://accounts.google.com/ServiceLogin?continue=" |
+ "https://passwords.google.com./settings&rart=123")); |
+ EXPECT_TRUE(client->IsPasswordManagerEnabledForCurrentPage()); |
Ilya Sherman
2014/08/26 01:46:08
Wat. Can you check with the GURL maintainers whet
Garrett Casto
2014/08/26 18:27:58
Sure, I'll follow up with Brett. My guess is that
|
+ |
+ // Not a transactional reauth page. |
+ NavigateAndCommit( |
+ GURL("https://accounts.google.com/ServiceLogin?continue=" |
+ "https://passwords.google.com/settings")); |
+ EXPECT_TRUE(client->IsPasswordManagerEnabledForCurrentPage()); |
+ |
+ // Should be enabled for other transactional reauth pages. |
+ NavigateAndCommit( |
+ GURL("https://accounts.google.com/ServiceLogin?continue=" |
+ "https://mail.google.com&rart=234")); |
+ EXPECT_TRUE(client->IsPasswordManagerEnabledForCurrentPage()); |
+ |
+ // Reauth pages are only on accounts.google.com |
+ NavigateAndCommit( |
+ GURL("https://other.site.com/ServiceLogin?continue=" |
+ "https://passwords.google.com&rart=234")); |
+ EXPECT_TRUE(client->IsPasswordManagerEnabledForCurrentPage()); |
+} |