Commit 6cf75df2 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[Passwords] Don't Trigger Touch To Fill on readonly fields

This change disables triggering Touch To Fill on readonly passwords
fields that wouldn't be able to be filled in.

Bug: 1013119
Change-Id: Ie0425e8d2d30bf77fbb791f220b379071f12e766
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1852292
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705520}
parent 5ffc4694
......@@ -1715,39 +1715,49 @@ TEST_F(PasswordAutofillAgentTest, TryToShowTouchToFillUsername) {
// have no fill data, though.
SimulateOnFillPasswordForm(fill_data_);
EXPECT_CALL(fake_driver_, ShowTouchToFill);
EXPECT_TRUE(
password_autofill_agent_->TryToShowTouchToFill(username_element_));
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_CALL(fake_driver_, ShowTouchToFill);
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, TryToShowTouchToFillPassword) {
SimulateOnFillPasswordForm(fill_data_);
EXPECT_CALL(fake_driver_, ShowTouchToFill);
EXPECT_TRUE(
password_autofill_agent_->TryToShowTouchToFill(password_element_));
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_CALL(fake_driver_, ShowTouchToFill);
base::RunLoop().RunUntilIdle();
}
TEST_F(PasswordAutofillAgentTest, DontTryToShowTouchToFillReadonlyPassword) {
SetElementReadOnly(password_element_, true);
SimulateOnFillPasswordForm(fill_data_);
EXPECT_FALSE(
password_autofill_agent_->TryToShowTouchToFill(password_element_));
}
TEST_F(PasswordAutofillAgentTest, TouchToFillDismissed) {
SimulateOnFillPasswordForm(fill_data_);
// Touch to fill will be shown multiple times until TouchToFillDismissed()
// gets called.
EXPECT_CALL(fake_driver_, ShowTouchToFill);
EXPECT_TRUE(
password_autofill_agent_->TryToShowTouchToFill(password_element_));
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_CALL(fake_driver_, ShowTouchToFill);
base::RunLoop().RunUntilIdle();
password_autofill_agent_->TouchToFillDismissed();
EXPECT_FALSE(
password_autofill_agent_->TryToShowTouchToFill(password_element_));
EXPECT_FALSE(password_autofill_agent_->ShouldSuppressKeyboard());
base::RunLoop().RunUntilIdle();
// Reload the page and simulate fill.
LoadHTML(kFormHTML);
......@@ -1756,10 +1766,11 @@ TEST_F(PasswordAutofillAgentTest, TouchToFillDismissed) {
SimulateOnFillPasswordForm(fill_data_);
// After the reload touch to fill is shown again.
EXPECT_CALL(fake_driver_, ShowTouchToFill);
EXPECT_TRUE(
password_autofill_agent_->TryToShowTouchToFill(password_element_));
EXPECT_TRUE(password_autofill_agent_->ShouldSuppressKeyboard());
EXPECT_CALL(fake_driver_, ShowTouchToFill);
base::RunLoop().RunUntilIdle();
}
......
......@@ -794,6 +794,10 @@ bool PasswordAutofillAgent::TryToShowTouchToFill(
return false;
}
DCHECK(!password_element.IsNull());
if (!IsElementEditable(password_element))
return false;
GetPasswordManagerDriver()->ShowTouchToFill();
touch_to_fill_state_ = TouchToFillState::kIsShowing;
return true;
......
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