OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 | 6 |
7 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 7 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
8 | 8 |
9 #include "chrome/common/chrome_version_info.h" | 9 #include "chrome/common/chrome_version_info.h" |
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 | 259 |
260 // Adding disallow switch should cause sync credential to be filtered. | 260 // Adding disallow switch should cause sync credential to be filtered. |
261 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 261 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
262 command_line->AppendSwitch( | 262 command_line->AppendSwitch( |
263 password_manager::switches::kDisallowAutofillSyncCredential); | 263 password_manager::switches::kDisallowAutofillSyncCredential); |
264 client.reset(new TestChromePasswordManagerClient(web_contents())); | 264 client.reset(new TestChromePasswordManagerClient(web_contents())); |
265 client->set_is_sync_account_credential(true); | 265 client->set_is_sync_account_credential(true); |
266 NavigateAndCommit(GURL("https://accounts.google.com/Login")); | 266 NavigateAndCommit(GURL("https://accounts.google.com/Login")); |
267 EXPECT_TRUE(client->ShouldFilterAutofillResult(form)); | 267 EXPECT_TRUE(client->ShouldFilterAutofillResult(form)); |
268 } | 268 } |
269 | |
270 TEST_F(ChromePasswordManagerClientTest, | |
271 IsPasswordManagerEnabledForCurrentPage) { | |
272 ChromePasswordManagerClient* client = GetClient(); | |
273 NavigateAndCommit( | |
274 GURL("https://accounts.google.com/ServiceLogin?continue=" | |
275 "https://passwords.google.com/settings&rart=123")); | |
276 EXPECT_FALSE(client->IsPasswordManagerEnabledForCurrentPage()); | |
277 | |
278 // Password site is inaccesible via HTTP, but because of HSTS the following | |
279 // link should still continue to https://passwords.google.com. | |
280 NavigateAndCommit( | |
281 GURL("https://accounts.google.com/ServiceLogin?continue=" | |
282 "http://passwords.google.com/settings&rart=123")); | |
283 EXPECT_FALSE(client->IsPasswordManagerEnabledForCurrentPage()); | |
284 | |
285 // Specifying default port still passes. | |
286 NavigateAndCommit( | |
287 GURL("https://accounts.google.com/ServiceLogin?continue=" | |
288 "https://passwords.google.com:443/settings&rart=123")); | |
289 EXPECT_FALSE(client->IsPasswordManagerEnabledForCurrentPage()); | |
290 | |
291 // Encoded URL is considered the same. | |
292 NavigateAndCommit( | |
293 GURL("https://accounts.google.com/ServiceLogin?continue=" | |
294 "https://passwords.%67oogle.com/settings&rart=123")); | |
295 EXPECT_FALSE(client->IsPasswordManagerEnabledForCurrentPage()); | |
296 | |
297 // Fully qualified domain name is considered a different hostname by GURL. | |
298 // Ideally this would not be the case, but this quirk can be avoided by | |
299 // verification on the server. This test is simply documentation of this | |
300 // behavior. | |
301 NavigateAndCommit( | |
302 GURL("https://accounts.google.com/ServiceLogin?continue=" | |
303 "https://passwords.google.com./settings&rart=123")); | |
304 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
| |
305 | |
306 // Not a transactional reauth page. | |
307 NavigateAndCommit( | |
308 GURL("https://accounts.google.com/ServiceLogin?continue=" | |
309 "https://passwords.google.com/settings")); | |
310 EXPECT_TRUE(client->IsPasswordManagerEnabledForCurrentPage()); | |
311 | |
312 // Should be enabled for other transactional reauth pages. | |
313 NavigateAndCommit( | |
314 GURL("https://accounts.google.com/ServiceLogin?continue=" | |
315 "https://mail.google.com&rart=234")); | |
316 EXPECT_TRUE(client->IsPasswordManagerEnabledForCurrentPage()); | |
317 | |
318 // Reauth pages are only on accounts.google.com | |
319 NavigateAndCommit( | |
320 GURL("https://other.site.com/ServiceLogin?continue=" | |
321 "https://passwords.google.com&rart=234")); | |
322 EXPECT_TRUE(client->IsPasswordManagerEnabledForCurrentPage()); | |
323 } | |
OLD | NEW |