Commit a85979f2 authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Fix crash on signout from managed account.

When the flag kClearSyncedData is enabled, the current code attempts to
add the new dialog option to the managed account alert. We only expect
the change to affect non-managed accounts, and so the app crashes.

Adds regression test for the case where a managed user signs out from
Chrome.

Bug: 1058662
Change-Id: Iaad9a13655a45653aa2e09e1428c03a37e412325
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2101008
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750537}
parent 9b8fdf58
...@@ -231,6 +231,31 @@ id<GREYMatcher> NoBookmarksLabel() { ...@@ -231,6 +231,31 @@ id<GREYMatcher> NoBookmarksLabel() {
assertWithMatcher:grey_notNil()]; assertWithMatcher:grey_notNil()];
} }
// Tests that signing out from a managed user account clears the user's data.
- (void)testsSignOutFromManagedAccount {
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeManagedIdentity];
// Sign In |fakeIdentity|.
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity isManagedAccount:YES];
// Add a bookmark after sync is initialized.
[ChromeEarlGrey waitForSyncInitialized:YES syncTimeout:kSyncOperationTimeout];
[ChromeEarlGrey waitForBookmarksToFinishLoading];
[SigninEarlGreyUtilsAppInterface addBookmark:@"http://youtube.com"
withTitle:@"cats"];
[SigninEarlGreyUI
signOutWithSignOutConfirmation:SignOutConfirmationManagedUser];
// Open the Bookmarks screen on the Tools menu.
[BookmarkEarlGreyUI openBookmarks];
[BookmarkEarlGreyUI openMobileBookmarks];
// Assert that there are no bookmarks.
[[EarlGrey selectElementWithMatcher:NoBookmarksLabel()]
assertWithMatcher:grey_notNil()];
}
// Tests that the user isn't signed out and the UI is correct when the // Tests that the user isn't signed out and the UI is correct when the
// disconnect is cancelled in the Account Settings screen. // disconnect is cancelled in the Account Settings screen.
- (void)testSignInDisconnectCancelled { - (void)testSignInDisconnectCancelled {
......
...@@ -399,7 +399,9 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -399,7 +399,9 @@ typedef NS_ENUM(NSInteger, ItemType) {
} }
style:UIAlertActionStyleDefault]; style:UIAlertActionStyleDefault];
if (base::FeatureList::IsEnabled(kClearSyncedData)) { if (base::FeatureList::IsEnabled(kClearSyncedData) &&
![self authService] -> IsAuthenticatedIdentityManaged()) {
DCHECK(clearDataButtonTitle);
[_alertCoordinator [_alertCoordinator
addItemWithTitle:clearDataButtonTitle addItemWithTitle:clearDataButtonTitle
action:^{ action:^{
......
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