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 @@ ...@@ -6,6 +6,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#include "base/ios/ios_util.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
...@@ -456,6 +457,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -456,6 +457,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
handler:nil]; handler:nil];
[alertController addAction:okAction]; [alertController addAction:okAction];
alertController.preferredAction = okAction; alertController.preferredAction = okAction;
[self presentViewController:alertController animated:YES completion:nil]; [self presentViewController:alertController animated:YES completion:nil];
} }
...@@ -502,6 +504,13 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -502,6 +504,13 @@ typedef NS_ENUM(NSInteger, ItemType) {
}]; }];
[_deleteConfirmation addAction:deleteAction]; [_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]; [self presentViewController:_deleteConfirmation animated:YES completion:nil];
} }
......
...@@ -558,11 +558,6 @@ void TapEdit() { ...@@ -558,11 +558,6 @@ void TapEdit() {
// Checks that deleting a saved password from password details view goes back // 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. // to the list-of-passwords view which doesn't display that form anymore.
- (void)testSavedFormDeletionInDetailView { - (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. // Save form to be deleted later.
SaveExamplePasswordForm(); SaveExamplePasswordForm();
...@@ -613,11 +608,6 @@ void TapEdit() { ...@@ -613,11 +608,6 @@ void TapEdit() {
// goes back to the list-of-passwords view which doesn't display that form // goes back to the list-of-passwords view which doesn't display that form
// anymore. // anymore.
- (void)testDuplicatedSavedFormDeletionInDetailView { - (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. // Save form to be deleted later.
SaveExamplePasswordForm(); SaveExamplePasswordForm();
// Save duplicate of the previously saved form to be deleted at the same time. // Save duplicate of the previously saved form to be deleted at the same time.
...@@ -675,11 +665,6 @@ void TapEdit() { ...@@ -675,11 +665,6 @@ void TapEdit() {
// Checks that deleting a blocked form from password details view goes // 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. // back to the list-of-passwords view which doesn't display that form anymore.
- (void)testBlockedFormDeletionInDetailView { - (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. // Save blacklisted form to be deleted later.
GREYAssert([PasswordSettingsAppInterface GREYAssert([PasswordSettingsAppInterface
saveExampleBlockedOrigin:@"https://blocked.com"], saveExampleBlockedOrigin:@"https://blocked.com"],
...@@ -729,11 +714,6 @@ void TapEdit() { ...@@ -729,11 +714,6 @@ void TapEdit() {
// Checks that deleting a password from password details can be cancelled. // Checks that deleting a password from password details can be cancelled.
- (void)testCancelDeletionInDetailView { - (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. // Save form to be deleted later.
SaveExamplePasswordForm(); SaveExamplePasswordForm();
...@@ -746,6 +726,11 @@ void TapEdit() { ...@@ -746,6 +726,11 @@ void TapEdit() {
performAction:grey_tap()]; performAction:grey_tap()];
// Tap the alert's Cancel button to cancel. // Tap the alert's Cancel button to cancel.
if (base::ios::IsRunningOnOrLater(13, 2, 0) && [ChromeEarlGrey isIPadIdiom]) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kPasswordDetailsTableViewId)]
performAction:grey_tap()];
} else {
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf( selectElementWithMatcher:grey_allOf(
ButtonWithAccessibilityLabel( ButtonWithAccessibilityLabel(
...@@ -753,6 +738,7 @@ void TapEdit() { ...@@ -753,6 +738,7 @@ void TapEdit() {
IDS_IOS_CANCEL_PASSWORD_DELETION)), IDS_IOS_CANCEL_PASSWORD_DELETION)),
grey_interactable(), nullptr)] grey_interactable(), nullptr)]
performAction:grey_tap()]; performAction:grey_tap()];
}
// Check that the current view is still the detail view, by locating the Copy // Check that the current view is still the detail view, by locating the Copy
// button. // button.
...@@ -1408,11 +1394,6 @@ void TapEdit() { ...@@ -1408,11 +1394,6 @@ void TapEdit() {
// Test export flow // Test export flow
- (void)testExportFlow { - (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. // Saving a form is needed for exporting passwords.
SaveExamplePasswordForm(); SaveExamplePasswordForm();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#include "base/ios/ios_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
...@@ -782,6 +783,13 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -782,6 +783,13 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
[exportConfirmation addAction:exportAction]; [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]; [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