Commit 44cd6300 authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] Fix crash in password settings on ios 13.2+

Popover now needs a sourceView or sourceRect.

Bug: 1023619
Change-Id: Ifcc65cf83c9afb26080c9baeb22dd9030b06ec9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036065
Commit-Queue: David Jean <djean@chromium.org>
Auto-Submit: David Jean <djean@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738501}
parent 099c13ee
......@@ -6,6 +6,7 @@
#import <UIKit/UIKit.h>
#include "base/ios/ios_util.h"
#include "base/mac/foundation_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/sys_string_conversions.h"
......@@ -456,6 +457,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
handler:nil];
[alertController addAction:okAction];
alertController.preferredAction = okAction;
[self presentViewController:alertController animated:YES completion:nil];
}
......@@ -502,6 +504,13 @@ typedef NS_ENUM(NSInteger, ItemType) {
}];
[_deleteConfirmation addAction:deleteAction];
// Starting with iOS13, alerts of style UIAlertControllerStyleActionSheet
// need a sourceView or sourceRect, or this crashes.
if (base::ios::IsRunningOnIOS13OrLater() && IsIPadIdiom()) {
_deleteConfirmation.popoverPresentationController.sourceView =
self.tableView;
}
[self presentViewController:_deleteConfirmation animated:YES completion:nil];
}
......
......@@ -558,11 +558,6 @@ void TapEdit() {
// Checks that deleting a saved password from password details view goes back
// to the list-of-passwords view which doesn't display that form anymore.
- (void)testSavedFormDeletionInDetailView {
// TODO(crbug.com/1023619): Enable the test on 13.2+ iPad once the bug is
// fixed.
if (base::ios::IsRunningOnOrLater(13, 2, 0) && [ChromeEarlGrey isIPadIdiom]) {
EARL_GREY_TEST_SKIPPED(@"Test disabled on iPad and iOS 13.2+");
}
// Save form to be deleted later.
SaveExamplePasswordForm();
......@@ -613,11 +608,6 @@ void TapEdit() {
// goes back to the list-of-passwords view which doesn't display that form
// anymore.
- (void)testDuplicatedSavedFormDeletionInDetailView {
// TODO(crbug.com/1023619): Enable the test on 13.2+ iPad once the bug is
// fixed.
if (base::ios::IsRunningOnOrLater(13, 2, 0) && [ChromeEarlGrey isIPadIdiom]) {
EARL_GREY_TEST_SKIPPED(@"Test disabled on iPad and iOS 13.2+");
}
// Save form to be deleted later.
SaveExamplePasswordForm();
// Save duplicate of the previously saved form to be deleted at the same time.
......@@ -675,11 +665,6 @@ void TapEdit() {
// Checks that deleting a blocked form from password details view goes
// back to the list-of-passwords view which doesn't display that form anymore.
- (void)testBlockedFormDeletionInDetailView {
// TODO(crbug.com/1023619): Enable the test on 13.2+ iPad once the bug is
// fixed.
if (base::ios::IsRunningOnOrLater(13, 2, 0) && [ChromeEarlGrey isIPadIdiom]) {
EARL_GREY_TEST_SKIPPED(@"Test disabled on iPad and iOS 13.2+");
}
// Save blacklisted form to be deleted later.
GREYAssert([PasswordSettingsAppInterface
saveExampleBlockedOrigin:@"https://blocked.com"],
......@@ -729,11 +714,6 @@ void TapEdit() {
// Checks that deleting a password from password details can be cancelled.
- (void)testCancelDeletionInDetailView {
// TODO(crbug.com/1023619): Enable the test on 13.2+ iPad once the bug is
// fixed.
if (base::ios::IsRunningOnOrLater(13, 2, 0) && [ChromeEarlGrey isIPadIdiom]) {
EARL_GREY_TEST_SKIPPED(@"Test disabled on iPad and iOS 13.2+");
}
// Save form to be deleted later.
SaveExamplePasswordForm();
......@@ -746,13 +726,19 @@ void TapEdit() {
performAction:grey_tap()];
// Tap the alert's Cancel button to cancel.
[[EarlGrey
selectElementWithMatcher:grey_allOf(
ButtonWithAccessibilityLabel(
l10n_util::GetNSString(
IDS_IOS_CANCEL_PASSWORD_DELETION)),
grey_interactable(), nullptr)]
performAction:grey_tap()];
if (base::ios::IsRunningOnOrLater(13, 2, 0) && [ChromeEarlGrey isIPadIdiom]) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kPasswordDetailsTableViewId)]
performAction:grey_tap()];
} else {
[[EarlGrey
selectElementWithMatcher:grey_allOf(
ButtonWithAccessibilityLabel(
l10n_util::GetNSString(
IDS_IOS_CANCEL_PASSWORD_DELETION)),
grey_interactable(), nullptr)]
performAction:grey_tap()];
}
// Check that the current view is still the detail view, by locating the Copy
// button.
......@@ -1408,11 +1394,6 @@ void TapEdit() {
// Test export flow
- (void)testExportFlow {
// TODO(crbug.com/1023619): Enable the test on 13.2+ iPad once the bug is
// fixed.
if (base::ios::IsRunningOnOrLater(13, 2, 0) && [ChromeEarlGrey isIPadIdiom]) {
EARL_GREY_TEST_SKIPPED(@"Test disabled on iPad and iOS 13.2+");
}
// Saving a form is needed for exporting passwords.
SaveExamplePasswordForm();
......
......@@ -6,6 +6,7 @@
#import <UIKit/UIKit.h>
#include "base/ios/ios_util.h"
#include "base/logging.h"
#include "base/mac/foundation_util.h"
#include "base/metrics/histogram_macros.h"
......@@ -782,6 +783,13 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
[exportConfirmation addAction:exportAction];
// Starting with iOS13, alerts of style UIAlertControllerStyleActionSheet
// need a sourceView or sourceRect, or this crashes.
if (base::ios::IsRunningOnIOS13OrLater() && IsIPadIdiom()) {
exportConfirmation.popoverPresentationController.sourceView =
self.tableView;
}
[self presentViewController:exportConfirmation animated:YES completion:nil];
}
......
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