Commit 31c27383 authored by Viktor Semeniuk's avatar Viktor Semeniuk Committed by Commit Bot

[iOS] Saving empty username no longer crashed app

This change fixes the crash when username was changed to the empty one.

Bug: 1147046
Change-Id: I0c9e24bce474639499865c06f1d9007776bc5c6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526323
Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825816}
parent 377717ee
......@@ -38,7 +38,10 @@
_website = base::SysUTF8ToNSString(nameWithLink.second.spec());
_changePasswordURL = password_manager::CreateChangePasswordUrl(form.url);
}
_username = base::SysUTF16ToNSString(form.username_value);
if (!form.blocked_by_user) {
_username = base::SysUTF16ToNSString(form.username_value);
}
if (form.federation_origin.opaque()) {
_password = base::SysUTF16ToNSString(form.password_value);
......
......@@ -155,8 +155,8 @@ typedef NS_ENUM(NSInteger, ReauthenticationReason) {
[model addItem:[self websiteItem]
toSectionWithIdentifier:SectionIdentifierPassword];
// Blocked password forms don't have username value.
if ([self.password.username length]) {
// Blocked password forms have username equal to nil.
if (self.password.username != nil) {
self.usernameTextItem = [self usernameItem];
[model addItem:self.usernameTextItem
toSectionWithIdentifier:SectionIdentifierPassword];
......
......@@ -1482,6 +1482,21 @@ void CopyPasswordDetailWithID(int detail_id) {
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()]
assertWithMatcher:grey_textFieldValue(@"concrete username")];
// Empty username should work as well.
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()]
performAction:grey_replaceText(@"")];
[[EarlGrey selectElementWithMatcher:NavigationBarDoneButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:EditConfirmationButton()]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()]
assertWithMatcher:grey_textFieldValue(@"")];
TapEdit();
[[EarlGrey selectElementWithMatcher:PasswordDetailUsername()]
performAction:grey_replaceText(@"new username")];
......
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