Chromium Code Reviews| Index: ios/chrome/browser/passwords/password_controller_unittest.mm |
| diff --git a/ios/chrome/browser/passwords/password_controller_unittest.mm b/ios/chrome/browser/passwords/password_controller_unittest.mm |
| index f02a0f737cd6ffc30275302cb945cbc54c213d1f..0471fa80fb846db4d4b1d81e139ae2b6dd95846e 100644 |
| --- a/ios/chrome/browser/passwords/password_controller_unittest.mm |
| +++ b/ios/chrome/browser/passwords/password_controller_unittest.mm |
| @@ -29,7 +29,10 @@ |
| #import "ios/chrome/browser/autofill/form_suggestion_controller.h" |
| #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| #import "ios/chrome/browser/passwords/js_password_manager.h" |
| +#include "ios/web/public/navigation_item.h" |
|
Eugene But (OOO till 7-30)
2016/12/08 01:48:43
s/include/import
lgarron
2016/12/15 03:04:31
I originally had import, but all these three impor
Eugene But (OOO till 7-30)
2016/12/15 03:45:36
Style Guide sais "#import Objective-C/Objective-C+
|
| +#include "ios/web/public/navigation_manager.h" |
|
Eugene But (OOO till 7-30)
2016/12/08 01:48:43
ditto
|
| #import "ios/web/public/web_state/web_state.h" |
| +#include "ios/web/public/ssl_status.h" |
| #import "ios/web/public/test/web_test_with_web_state.h" |
| #import "ios/web/public/test/test_web_state.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| @@ -987,6 +990,10 @@ TEST_F(PasswordControllerTest, FLAKY_DontFillReadOnly) { |
| "</form>")); |
| } |
| +// An HTML page without a password form. |
| +static NSString* kHtmlWithoutPasswordForm = |
| + @"<h2>The rain in Spain stays <i>mainly</i> in the plain.</h2>"; |
| + |
| // An HTML page containing one password form. The username input field |
| // also has custom event handlers. We need to verify that those event |
| // handlers are still triggered even though we override them with our own. |
| @@ -1292,3 +1299,39 @@ TEST(PasswordControllerTestSimple, SaveOnNonHTMLLandingPage) { |
| web_state.SetCurrentURL(GURL("https://example.com")); |
| [passwordController webStateDidLoadPage:&web_state]; |
| } |
| + |
| +TEST_F(PasswordControllerTest, HTTPNoPassword) { |
|
Eugene But (OOO till 7-30)
2016/12/08 01:48:43
s/HTTPNoPassword/HttpNoPassword
Eugene But (OOO till 7-30)
2016/12/08 01:48:43
Please add comments for test methods
lgarron
2016/12/15 03:04:31
Comments added.
This file also has a test called
Eugene But (OOO till 7-30)
2016/12/15 03:45:36
Camel case is correct choice per C++ Style Guide,
|
| + LoadHtml(kHtmlWithoutPasswordForm, GURL("http://chromium.test")); |
| + |
| + web::SSLStatus ssl_status = |
| + web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); |
| + EXPECT_FALSE(ssl_status.content_status & |
| + web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
| +} |
| + |
| +TEST_F(PasswordControllerTest, HTTPPassword) { |
| + LoadHtml(kHtmlWithPasswordForm, GURL("http://chromium.test")); |
| + |
| + web::SSLStatus ssl_status = |
| + web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); |
| + EXPECT_TRUE(ssl_status.content_status & |
| + web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
| +} |
| + |
| +TEST_F(PasswordControllerTest, HTTPSNoPassword) { |
| + LoadHtml(kHtmlWithoutPasswordForm, GURL("https://chromium.test")); |
| + |
| + web::SSLStatus ssl_status = |
| + web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); |
| + EXPECT_FALSE(ssl_status.content_status & |
| + web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
| +} |
| + |
| +TEST_F(PasswordControllerTest, HTTPSPassword) { |
| + LoadHtml(kHtmlWithPasswordForm, GURL("https://chromium.test")); |
| + |
| + web::SSLStatus ssl_status = |
| + web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); |
| + EXPECT_FALSE(ssl_status.content_status & |
| + web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); |
| +} |