Commit af397238 authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

[IOS Password Manager] Inform that no suggestions when no password forms.

On CL https://chromium-review.googlesource.com/c/chromium/src/+/921961
async retrieval of suggestions in Password Manager was implemented.
The problem that when there are no password forms PasswordController
doesn't call callback that there are no suggestions so in result
Autofill can't provide own suggestions. This CL fixes that.

Bug: 820072
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I4a7dce1540b2217b388caadb19fc2e563c79eb26
Reviewed-on: https://chromium-review.googlesource.com/955685
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541821}
parent 3eb94aa5
...@@ -667,6 +667,8 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) { ...@@ -667,6 +667,8 @@ bool GetPageURLAndCheckTrustLevel(web::WebState* web_state, GURL* page_url) {
// on the loaded page. // on the loaded page.
passwordManager_->OnPasswordFormsParsed(passwordManagerDriver_.get(), passwordManager_->OnPasswordFormsParsed(passwordManagerDriver_.get(),
forms); forms);
} else {
[self onNoSavedCredentials];
} }
// Invoke the password manager callback to check if password was // Invoke the password manager callback to check if password was
// accepted or rejected. If accepted, infobar is presented. If // accepted or rejected. If accepted, infobar is presented. If
......
...@@ -1712,3 +1712,31 @@ TEST_F(PasswordControllerTest, CheckNoAsyncSuggestionsOnNonUsernameField) { ...@@ -1712,3 +1712,31 @@ TEST_F(PasswordControllerTest, CheckNoAsyncSuggestionsOnNonUsernameField) {
EXPECT_FALSE(completion_handler_success); EXPECT_FALSE(completion_handler_success);
} }
// Tests that when there are no password forms on a page and the user clicks on
// a text field the completion callback is called with no suggestions result.
TEST_F(PasswordControllerTest, CheckNoAsyncSuggestionsOnNoPasswordForms) {
LoadHtml(kHtmlWithoutPasswordForm);
__block BOOL completion_handler_success = NO;
__block BOOL completion_handler_called = NO;
EXPECT_CALL(*store_, GetLogins(_, _)).Times(0);
[passwordController_ checkIfSuggestionsAvailableForForm:@"form"
field:@"address"
fieldType:@"text"
type:@"focus"
typedValue:@""
isMainFrame:YES
webState:web_state()
completionHandler:^(BOOL success) {
completion_handler_success = success;
completion_handler_called = YES;
}];
// Wait until the expected handler is called.
EXPECT_TRUE(WaitUntilConditionOrTimeout(kWaitForActionTimeout, ^bool() {
return completion_handler_called;
}));
EXPECT_FALSE(completion_handler_success);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment