Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/chrome/browser/passwords/password_controller.h" | 5 #import "ios/chrome/browser/passwords/password_controller.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 #include "components/password_manager/core/browser/log_manager.h" | 22 #include "components/password_manager/core/browser/log_manager.h" |
| 23 #include "components/password_manager/core/browser/mock_password_store.h" | 23 #include "components/password_manager/core/browser/mock_password_store.h" |
| 24 #include "components/password_manager/core/browser/stub_password_manager_client. h" | 24 #include "components/password_manager/core/browser/stub_password_manager_client. h" |
| 25 #include "components/password_manager/core/common/password_manager_pref_names.h" | 25 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 26 #include "components/prefs/pref_registry_simple.h" | 26 #include "components/prefs/pref_registry_simple.h" |
| 27 #include "components/prefs/testing_pref_service.h" | 27 #include "components/prefs/testing_pref_service.h" |
| 28 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" | 28 #import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h" |
| 29 #import "ios/chrome/browser/autofill/form_suggestion_controller.h" | 29 #import "ios/chrome/browser/autofill/form_suggestion_controller.h" |
| 30 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 30 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 31 #import "ios/chrome/browser/passwords/js_password_manager.h" | 31 #import "ios/chrome/browser/passwords/js_password_manager.h" |
| 32 #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+
| |
| 33 #include "ios/web/public/navigation_manager.h" | |
|
Eugene But (OOO till 7-30)
2016/12/08 01:48:43
ditto
| |
| 32 #import "ios/web/public/web_state/web_state.h" | 34 #import "ios/web/public/web_state/web_state.h" |
| 35 #include "ios/web/public/ssl_status.h" | |
| 33 #import "ios/web/public/test/web_test_with_web_state.h" | 36 #import "ios/web/public/test/web_test_with_web_state.h" |
| 34 #import "ios/web/public/test/test_web_state.h" | 37 #import "ios/web/public/test/test_web_state.h" |
| 35 #include "testing/gmock/include/gmock/gmock.h" | 38 #include "testing/gmock/include/gmock/gmock.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 39 #include "testing/gtest/include/gtest/gtest.h" |
| 37 #include "testing/gtest_mac.h" | 40 #include "testing/gtest_mac.h" |
| 38 #import "third_party/ocmock/OCMock/OCMock.h" | 41 #import "third_party/ocmock/OCMock/OCMock.h" |
| 39 #import "third_party/ocmock/OCMock/OCPartialMockObject.h" | 42 #import "third_party/ocmock/OCMock/OCPartialMockObject.h" |
| 40 #include "url/gurl.h" | 43 #include "url/gurl.h" |
| 41 | 44 |
| 42 using autofill::PasswordForm; | 45 using autofill::PasswordForm; |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 980 "<input id='pw0' type='password' name='p0'>" | 983 "<input id='pw0' type='password' name='p0'>" |
| 981 "</form>")); | 984 "</form>")); |
| 982 // Form fill should fail with 'readonly' attribute on password. | 985 // Form fill should fail with 'readonly' attribute on password. |
| 983 EXPECT_FALSE(BasicFormFill( | 986 EXPECT_FALSE(BasicFormFill( |
| 984 @"<form>" | 987 @"<form>" |
| 985 "<input id='un0' type='text' name='u0'>" | 988 "<input id='un0' type='text' name='u0'>" |
| 986 "<input id='pw0' type='password' name='p0' readonly='readonly'>" | 989 "<input id='pw0' type='password' name='p0' readonly='readonly'>" |
| 987 "</form>")); | 990 "</form>")); |
| 988 } | 991 } |
| 989 | 992 |
| 993 // An HTML page without a password form. | |
| 994 static NSString* kHtmlWithoutPasswordForm = | |
| 995 @"<h2>The rain in Spain stays <i>mainly</i> in the plain.</h2>"; | |
| 996 | |
| 990 // An HTML page containing one password form. The username input field | 997 // An HTML page containing one password form. The username input field |
| 991 // also has custom event handlers. We need to verify that those event | 998 // also has custom event handlers. We need to verify that those event |
| 992 // handlers are still triggered even though we override them with our own. | 999 // handlers are still triggered even though we override them with our own. |
| 993 static NSString* kHtmlWithPasswordForm = | 1000 static NSString* kHtmlWithPasswordForm = |
| 994 @"<form>" | 1001 @"<form>" |
| 995 "<input id='un' type='text' name=\"u'\"" | 1002 "<input id='un' type='text' name=\"u'\"" |
| 996 " onkeyup='window.onKeyUpCalled_=true'" | 1003 " onkeyup='window.onKeyUpCalled_=true'" |
| 997 " onchange='window.onChangeCalled_=true'>" | 1004 " onchange='window.onChangeCalled_=true'>" |
| 998 "<input id='pw' type='password' name=\"p'\">" | 1005 "<input id='pw' type='password' name=\"p'\">" |
| 999 "</form>"; | 1006 "</form>"; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1285 LogSavePasswordProgress(testing::Ne( | 1292 LogSavePasswordProgress(testing::Ne( |
| 1286 "Message: \"PasswordManager::OnPasswordFormsRendered\"\n"))) | 1293 "Message: \"PasswordManager::OnPasswordFormsRendered\"\n"))) |
| 1287 .Times(testing::AnyNumber()); | 1294 .Times(testing::AnyNumber()); |
| 1288 EXPECT_CALL(*weak_client, GetLogManager()) | 1295 EXPECT_CALL(*weak_client, GetLogManager()) |
| 1289 .WillRepeatedly(Return(&log_manager)); | 1296 .WillRepeatedly(Return(&log_manager)); |
| 1290 | 1297 |
| 1291 web_state.SetContentIsHTML(false); | 1298 web_state.SetContentIsHTML(false); |
| 1292 web_state.SetCurrentURL(GURL("https://example.com")); | 1299 web_state.SetCurrentURL(GURL("https://example.com")); |
| 1293 [passwordController webStateDidLoadPage:&web_state]; | 1300 [passwordController webStateDidLoadPage:&web_state]; |
| 1294 } | 1301 } |
| 1302 | |
| 1303 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,
| |
| 1304 LoadHtml(kHtmlWithoutPasswordForm, GURL("http://chromium.test")); | |
| 1305 | |
| 1306 web::SSLStatus ssl_status = | |
| 1307 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); | |
| 1308 EXPECT_FALSE(ssl_status.content_status & | |
| 1309 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | |
| 1310 } | |
| 1311 | |
| 1312 TEST_F(PasswordControllerTest, HTTPPassword) { | |
| 1313 LoadHtml(kHtmlWithPasswordForm, GURL("http://chromium.test")); | |
| 1314 | |
| 1315 web::SSLStatus ssl_status = | |
| 1316 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); | |
| 1317 EXPECT_TRUE(ssl_status.content_status & | |
| 1318 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | |
| 1319 } | |
| 1320 | |
| 1321 TEST_F(PasswordControllerTest, HTTPSNoPassword) { | |
| 1322 LoadHtml(kHtmlWithoutPasswordForm, GURL("https://chromium.test")); | |
| 1323 | |
| 1324 web::SSLStatus ssl_status = | |
| 1325 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); | |
| 1326 EXPECT_FALSE(ssl_status.content_status & | |
| 1327 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | |
| 1328 } | |
| 1329 | |
| 1330 TEST_F(PasswordControllerTest, HTTPSPassword) { | |
| 1331 LoadHtml(kHtmlWithPasswordForm, GURL("https://chromium.test")); | |
| 1332 | |
| 1333 web::SSLStatus ssl_status = | |
| 1334 web_state()->GetNavigationManager()->GetLastCommittedItem()->GetSSL(); | |
| 1335 EXPECT_FALSE(ssl_status.content_status & | |
| 1336 web::SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP); | |
| 1337 } | |
| OLD | NEW |