Commit f88882e9 authored by Kurt Horimoto's avatar Kurt Horimoto Committed by Commit Bot

[iOS] Fix JS dialog egtests.

This CL updates the JS dialog egtests to work with both modal and non-
modal dialog implementations in preparation for updating the non-modal
dialog feature to be enabled by default.

This required introducing a11y identifier functionality to the
AlertConsumer protocol to allow the tests to properly wait for the
dialogs to be displayed.

Bug: none
Change-Id: I26010b73501442db729f8c561d925d70b8c5eca5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925775
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718384}
parent 17b00560
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
// Sets the actions for this alert. // Sets the actions for this alert.
- (void)setActions:(NSArray<AlertAction*>*)actions; - (void)setActions:(NSArray<AlertAction*>*)actions;
// Sets the accessibility identifier for the alert view.
- (void)setAlertAccessibilityIdentifier:(NSString*)identifier;
@end @end
#endif // IOS_CHROME_BROWSER_UI_ALERT_VIEW_CONTROLLER_ALERT_CONSUMER_H_ #endif // IOS_CHROME_BROWSER_UI_ALERT_VIEW_CONTROLLER_ALERT_CONSUMER_H_
...@@ -86,6 +86,9 @@ constexpr NSUInteger kUIViewAnimationCurveToOptionsShift = 16; ...@@ -86,6 +86,9 @@ constexpr NSUInteger kUIViewAnimationCurveToOptionsShift = 16;
@property(nonatomic, copy) @property(nonatomic, copy)
NSArray<TextFieldConfiguration*>* textFieldConfigurations; NSArray<TextFieldConfiguration*>* textFieldConfigurations;
// The alert view's accessibility identifier.
@property(nonatomic, copy) NSString* alertAccessibilityIdentifier;
// The text fields that had been added to this alert. // The text fields that had been added to this alert.
@property(nonatomic, strong) NSArray<UITextField*>* textFields; @property(nonatomic, strong) NSArray<UITextField*>* textFields;
...@@ -137,6 +140,7 @@ constexpr NSUInteger kUIViewAnimationCurveToOptionsShift = 16; ...@@ -137,6 +140,7 @@ constexpr NSUInteger kUIViewAnimationCurveToOptionsShift = 16;
[self.view addGestureRecognizer:self.tapRecognizer]; [self.view addGestureRecognizer:self.tapRecognizer];
self.contentView = [[UIView alloc] init]; self.contentView = [[UIView alloc] init];
self.contentView.accessibilityIdentifier = self.alertAccessibilityIdentifier;
self.contentView.clipsToBounds = YES; self.contentView.clipsToBounds = YES;
self.contentView.backgroundColor = UIColor.cr_systemBackgroundColor; self.contentView.backgroundColor = UIColor.cr_systemBackgroundColor;
self.contentView.layer.cornerRadius = kCornerRadius; self.contentView.layer.cornerRadius = kCornerRadius;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
@property(nonatomic, copy) @property(nonatomic, copy)
NSArray<TextFieldConfiguration*>* textFieldConfigurations; NSArray<TextFieldConfiguration*>* textFieldConfigurations;
@property(nonatomic, copy) NSArray<AlertAction*>* actions; @property(nonatomic, copy) NSArray<AlertAction*>* actions;
@property(nonatomic, copy) NSString* alertAccessibilityIdentifier;
@end @end
......
...@@ -137,6 +137,7 @@ source_set("eg_tests") { ...@@ -137,6 +137,7 @@ source_set("eg_tests") {
] ]
deps = [ deps = [
":constants", ":constants",
":feature_flags",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//components/strings", "//components/strings",
...@@ -175,6 +176,7 @@ source_set("eg2_tests") { ...@@ -175,6 +176,7 @@ source_set("eg2_tests") {
] ]
deps = [ deps = [
":constants", ":constants",
":feature_flags",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//components/strings", "//components/strings",
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
// Accessibility identifier for a JavaScript dialog.
extern NSString* const kJavaScriptDialogAccessibilityIdentifier;
// Accessibility identifier added to the text field of JavaScript prompts. // Accessibility identifier added to the text field of JavaScript prompts.
extern NSString* const kJavaScriptDialogTextFieldAccessibilityIdentifier; extern NSString* const kJavaScriptDialogTextFieldAccessibilityIdentifier;
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
// Externed accessibility identifier. // Externed accessibility identifiers.
NSString* const kJavaScriptDialogAccessibilityIdentifier =
@"JavaScriptDialogAccessibilityIdentifier";
NSString* const kJavaScriptDialogTextFieldAccessibilityIdentifier = NSString* const kJavaScriptDialogTextFieldAccessibilityIdentifier =
@"JavaScriptDialogTextFieldAccessibilityIdentifier"; @"JavaScriptDialogTextFieldAccessibiltyIdentifier";
...@@ -442,6 +442,8 @@ using completion_block_util::GetSafeHTTPAuthCompletion; ...@@ -442,6 +442,8 @@ using completion_block_util::GetSafeHTTPAuthCompletion;
[self.delegate dialogPresenter:self [self.delegate dialogPresenter:self
willShowDialogForWebState:self.presentedDialogWebState]; willShowDialogForWebState:self.presentedDialogWebState];
[self.presentedDialogCoordinator start]; [self.presentedDialogCoordinator start];
self.presentedDialogCoordinator.alertController.view.accessibilityIdentifier =
kJavaScriptDialogAccessibilityIdentifier;
} }
- (void)dialogCoordinatorWasStopped:(AlertCoordinator*)coordinator { - (void)dialogCoordinatorWasStopped:(AlertCoordinator*)coordinator {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/url_formatter/elide_url.h" #include "components/url_formatter/elide_url.h"
#import "ios/chrome/browser/ui/dialogs/dialog_constants.h" #import "ios/chrome/browser/ui/dialogs/dialog_constants.h"
#import "ios/chrome/browser/ui/dialogs/dialog_features.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/earl_grey/chrome_actions.h" #import "ios/chrome/test/earl_grey/chrome_actions.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
...@@ -44,6 +45,11 @@ using base::test::ios::WaitUntilConditionOrTimeout; ...@@ -44,6 +45,11 @@ using base::test::ios::WaitUntilConditionOrTimeout;
namespace { namespace {
// Whether non-modal dialogs are being used.
bool AreDialogsNonModal() {
return base::FeatureList::IsEnabled(dialogs::kNonModalDialogs);
}
// Body script for test page that shows an alert with kAlertMessage and returns // Body script for test page that shows an alert with kAlertMessage and returns
// kAlertResult. // kAlertResult.
const char kAlertURLPath[] = "/alert"; const char kAlertURLPath[] = "/alert";
...@@ -95,13 +101,15 @@ std::string GetPromptScriptBody() { ...@@ -95,13 +101,15 @@ std::string GetPromptScriptBody() {
// Script to inject that will show a JavaScript alert in a loop 20 times, then // Script to inject that will show a JavaScript alert in a loop 20 times, then
// returns kAlertLoopFinishedText. // returns kAlertLoopFinishedText.
const char kAlertLoopURLPath[] = "/loop"; const char kAlertLoopURLPath[] = "/loop";
const char kAlertLoopMessage[] = "This is a looped alert.";
const char kAlertLoopFinishedText[] = "Loop Finished"; const char kAlertLoopFinishedText[] = "Loop Finished";
const char kAlertLoopScriptBodyFormat[] = "for (i = 0; i < 20; ++i) {" const char kAlertLoopScriptBodyFormat[] = "for (i = 0; i < 20; ++i) {"
" alert(\"ALERT TEXT\");" " alert(\"%s\");"
"}" "}"
"return \"%s\";"; "return \"%s\";";
std::string GetAlertLoopScriptBody() { std::string GetAlertLoopScriptBody() {
return base::StringPrintf(kAlertLoopScriptBodyFormat, kAlertLoopFinishedText); return base::StringPrintf(kAlertLoopScriptBodyFormat, kAlertLoopMessage,
kAlertLoopFinishedText);
} }
// HTTP server constants. // HTTP server constants.
...@@ -133,8 +141,12 @@ std::string GetTestPageContents(std::string script_body) { ...@@ -133,8 +141,12 @@ std::string GetTestPageContents(std::string script_body) {
} }
// The URL path for a page that shows an alert onload. // The URL path for a page that shows an alert onload.
const char kOnLoadURLPath[] = "/onload"; const char kOnLoadURLPath[] = "/onload";
const char kOnLoadContents[] = const char kOnLoadAlertMessage[] = "onload Alert";
"<!DOCTYPE html><html><body onload=\"alert('alert')\"></body></html>"; const char kOnLoadContentsFormat[] =
"<!DOCTYPE html><html><body onload=\"alert('%s')\"></body></html>";
std::string GetOnLoadPageContents() {
return base::StringPrintf(kOnLoadContentsFormat, kOnLoadAlertMessage);
}
// The URL path for a page with a link to kOnLoadURLPath. // The URL path for a page with a link to kOnLoadURLPath.
const char kLinkPageURLPath[] = "/link"; const char kLinkPageURLPath[] = "/link";
const char kLinkPageContentsFormat[] = const char kLinkPageContentsFormat[] =
...@@ -165,7 +177,7 @@ std::unique_ptr<net::test_server::HttpResponse> LoadTestPage( ...@@ -165,7 +177,7 @@ std::unique_ptr<net::test_server::HttpResponse> LoadTestPage(
// net::EmbeddedTestServer handler for kOnLoadURLPath. // net::EmbeddedTestServer handler for kOnLoadURLPath.
std::unique_ptr<net::test_server::HttpResponse> LoadPageWithOnLoadAlert( std::unique_ptr<net::test_server::HttpResponse> LoadPageWithOnLoadAlert(
const net::test_server::HttpRequest& request) { const net::test_server::HttpRequest& request) {
return GetHttpResponseWithContent(kOnLoadContents); return GetHttpResponseWithContent(GetOnLoadPageContents());
} }
// net::EmbeddedTestServer handler for kLinkPageURLPath. // net::EmbeddedTestServer handler for kLinkPageURLPath.
std::unique_ptr<net::test_server::HttpResponse> LoadPageWithLinkToOnLoadPage( std::unique_ptr<net::test_server::HttpResponse> LoadPageWithLinkToOnLoadPage(
...@@ -193,13 +205,45 @@ void WaitForAlertWithText(NSString* alert_text, bool visible) { ...@@ -193,13 +205,45 @@ void WaitForAlertWithText(NSString* alert_text, bool visible) {
error_text_format, alert_text); error_text_format, alert_text);
} }
// Waits for a JavaScript dialog from |url| to be shown or hidden. // Waits for a JavaScript dialog from |url| with |message| to be shown or
void WaitForJavaScriptDialog(const GURL& url, bool visible) { // hidden.
base::string16 URLString = url_formatter::FormatUrlForSecurityDisplay( void WaitForJavaScriptDialog(const GURL& url,
url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); const char* message,
NSString* expectedTitle = bool visible,
l10n_util::GetNSStringF(IDS_JAVASCRIPT_MESSAGEBOX_TITLE, URLString); bool is_main_frame) {
WaitForAlertWithText(expectedTitle, visible); // Wait for the JavaScript dialog identifier.
id<GREYMatcher> visibility_matcher = visible ? grey_notNil() : grey_nil();
ConditionBlock condition = ^{
NSError* error = nil;
id<GREYMatcher> dialog_matcher =
grey_accessibilityID(kJavaScriptDialogAccessibilityIdentifier);
[[EarlGrey selectElementWithMatcher:dialog_matcher]
assertWithMatcher:visibility_matcher
error:&error];
return !error;
};
NSString* error_text = visible ? @"JavaScript dialog was not shown."
: @"JavaScript dialog was not hidden.";
GREYAssert(WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, condition),
error_text);
// Check the title. Non-modal main-frame dialogs do not have a title label.
if (!AreDialogsNonModal() || !is_main_frame) {
base::string16 url_string = url_formatter::FormatUrlForSecurityDisplay(
url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
NSString* expected_title =
l10n_util::GetNSStringF(IDS_JAVASCRIPT_MESSAGEBOX_TITLE, url_string);
id<GREYMatcher> title_matcher =
chrome_test_util::StaticTextWithAccessibilityLabel(expected_title);
[[EarlGrey selectElementWithMatcher:title_matcher]
assertWithMatcher:visibility_matcher];
}
// Check the message.
id<GREYMatcher> message_matcher =
chrome_test_util::StaticTextWithAccessibilityLabel(@(message));
[[EarlGrey selectElementWithMatcher:message_matcher]
assertWithMatcher:visibility_matcher];
} }
// Types |input| in the prompt. // Types |input| in the prompt.
...@@ -288,17 +332,13 @@ void TapSuppressDialogsButton() { ...@@ -288,17 +332,13 @@ void TapSuppressDialogsButton() {
[ChromeEarlGrey waitForWebStateContainingElement: [ChromeEarlGrey waitForWebStateContainingElement:
[ElementSelector selectorWithElementID:kTestPageLinkID]]; [ElementSelector selectorWithElementID:kTestPageLinkID]];
[ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)]; [ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)];
WaitForJavaScriptDialog(kURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kAlertMessage, /*visible=*/true,
/*is_main_frame=*/true);
// Check the message of the alert.
id<GREYMatcher> messageLabel =
chrome_test_util::StaticTextWithAccessibilityLabel(@(kAlertMessage));
[[EarlGrey selectElementWithMatcher:messageLabel]
assertWithMatcher:grey_notNil()];
// Tap the OK button to close the alert. // Tap the OK button to close the alert.
[[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()]; [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
WaitForJavaScriptDialog(kURL, /*visible=*/false); WaitForJavaScriptDialog(kURL, kAlertMessage, /*visible=*/false,
/*is_main_frame=*/true);
// Wait for the expected text to be added to the test page. // Wait for the expected text to be added to the test page.
[ChromeEarlGrey waitForWebStateContainingText:kAlertResult]; [ChromeEarlGrey waitForWebStateContainingText:kAlertResult];
...@@ -313,18 +353,13 @@ void TapSuppressDialogsButton() { ...@@ -313,18 +353,13 @@ void TapSuppressDialogsButton() {
[ChromeEarlGrey waitForWebStateContainingElement: [ChromeEarlGrey waitForWebStateContainingElement:
[ElementSelector selectorWithElementID:kTestPageLinkID]]; [ElementSelector selectorWithElementID:kTestPageLinkID]];
[ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)]; [ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)];
WaitForJavaScriptDialog(kURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kConfirmationMessage, /*visible=*/true,
/*is_main_frame=*/true);
// Check the message of the dialog.
id<GREYMatcher> messageLabel =
chrome_test_util::StaticTextWithAccessibilityLabel(
@(kConfirmationMessage));
[[EarlGrey selectElementWithMatcher:messageLabel]
assertWithMatcher:grey_notNil()];
// Tap the OK button to close the confirmation. // Tap the OK button to close the confirmation.
[[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()]; [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
WaitForJavaScriptDialog(kURL, /*visible=*/false); WaitForJavaScriptDialog(kURL, kConfirmationMessage, /*visible=*/false,
/*is_main_frame=*/true);
// Wait for the expected text to be added to the test page. // Wait for the expected text to be added to the test page.
[ChromeEarlGrey waitForWebStateContainingText:kConfirmationResultOK]; [ChromeEarlGrey waitForWebStateContainingText:kConfirmationResultOK];
...@@ -339,18 +374,14 @@ void TapSuppressDialogsButton() { ...@@ -339,18 +374,14 @@ void TapSuppressDialogsButton() {
[ChromeEarlGrey waitForWebStateContainingElement: [ChromeEarlGrey waitForWebStateContainingElement:
[ElementSelector selectorWithElementID:kTestPageLinkID]]; [ElementSelector selectorWithElementID:kTestPageLinkID]];
[ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)]; [ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)];
WaitForJavaScriptDialog(kURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kConfirmationMessage, /*visible=*/true,
/*is_main_frame=*/true);
// Check the message of the dialog.
id<GREYMatcher> messageLabel =
chrome_test_util::StaticTextWithAccessibilityLabel(
@(kConfirmationMessage));
[[EarlGrey selectElementWithMatcher:messageLabel]
assertWithMatcher:grey_notNil()];
// Tap the OK button to close the confirmation. // Tap the OK button to close the confirmation.
[[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()]; [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
WaitForJavaScriptDialog(kURL, /*visible=*/false);
WaitForJavaScriptDialog(kURL, kConfirmationMessage, /*visible=*/false,
/*is_main_frame=*/true);
// Wait for the expected text to be added to the test page. // Wait for the expected text to be added to the test page.
[ChromeEarlGrey waitForWebStateContainingText:kConfirmationResultCancelled]; [ChromeEarlGrey waitForWebStateContainingText:kConfirmationResultCancelled];
...@@ -371,20 +402,16 @@ void TapSuppressDialogsButton() { ...@@ -371,20 +402,16 @@ void TapSuppressDialogsButton() {
[ChromeEarlGrey waitForWebStateContainingElement: [ChromeEarlGrey waitForWebStateContainingElement:
[ElementSelector selectorWithElementID:kTestPageLinkID]]; [ElementSelector selectorWithElementID:kTestPageLinkID]];
[ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)]; [ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)];
WaitForJavaScriptDialog(kURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kPromptMessage, /*visible=*/true,
/*is_main_frame=*/true);
// Check the message of the dialog.
id<GREYMatcher> messageLabel =
chrome_test_util::StaticTextWithAccessibilityLabel(@(kPromptMessage));
[[EarlGrey selectElementWithMatcher:messageLabel]
assertWithMatcher:grey_notNil()];
// Enter text into text field. // Enter text into text field.
TypeInPrompt(@(kPromptTestUserInput)); TypeInPrompt(@(kPromptTestUserInput));
// Tap the OK button to close the confirmation. // Tap the OK button to close the confirmation.
[[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()]; [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
WaitForJavaScriptDialog(kURL, /*visible=*/false); WaitForJavaScriptDialog(kURL, kPromptMessage, /*visible=*/false,
/*is_main_frame=*/true);
// Wait for the html to be reset to the input text. // Wait for the html to be reset to the input text.
[ChromeEarlGrey waitForWebStateContainingText:kPromptTestUserInput]; [ChromeEarlGrey waitForWebStateContainingText:kPromptTestUserInput];
...@@ -405,20 +432,16 @@ void TapSuppressDialogsButton() { ...@@ -405,20 +432,16 @@ void TapSuppressDialogsButton() {
[ChromeEarlGrey waitForWebStateContainingElement: [ChromeEarlGrey waitForWebStateContainingElement:
[ElementSelector selectorWithElementID:kTestPageLinkID]]; [ElementSelector selectorWithElementID:kTestPageLinkID]];
[ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)]; [ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)];
WaitForJavaScriptDialog(kURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kPromptMessage, /*visible=*/true,
/*is_main_frame=*/true);
// Check the message of the dialog.
id<GREYMatcher> messageLabel =
chrome_test_util::StaticTextWithAccessibilityLabel(@(kPromptMessage));
[[EarlGrey selectElementWithMatcher:messageLabel]
assertWithMatcher:grey_notNil()];
// Enter text into text field. // Enter text into text field.
TypeInPrompt(@(kPromptTestUserInput)); TypeInPrompt(@(kPromptTestUserInput));
// Tap the Cancel button. // Tap the Cancel button.
TapCancel(); TapCancel();
WaitForJavaScriptDialog(kURL, /*visible=*/false); WaitForJavaScriptDialog(kURL, kPromptMessage, /*visible=*/false,
/*is_main_frame=*/true);
// Wait for the html to be reset to the cancel text. // Wait for the html to be reset to the cancel text.
[ChromeEarlGrey waitForWebStateContainingText:kPromptResultCancelled]; [ChromeEarlGrey waitForWebStateContainingText:kPromptResultCancelled];
...@@ -432,25 +455,31 @@ void TapSuppressDialogsButton() { ...@@ -432,25 +455,31 @@ void TapSuppressDialogsButton() {
[ChromeEarlGrey waitForWebStateContainingElement: [ChromeEarlGrey waitForWebStateContainingElement:
[ElementSelector selectorWithElementID:kTestPageLinkID]]; [ElementSelector selectorWithElementID:kTestPageLinkID]];
[ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)]; [ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)];
WaitForJavaScriptDialog(kURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kAlertLoopMessage, /*visible=*/true,
/*is_main_frame=*/true);
// Tap the OK button to close the alert, then verify that the next alert in // Tap the OK button to close the alert, then verify that the next alert in
// the loop is shown. // the loop is shown.
[[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()]; [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
WaitForJavaScriptDialog(kURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kAlertLoopMessage, /*visible=*/true,
/*is_main_frame=*/true);
// Tap the suppress dialogs button. // Tap the suppress dialogs button.
TapSuppressDialogsButton(); TapSuppressDialogsButton();
WaitForJavaScriptDialog(kURL, /*visible=*/false); WaitForJavaScriptDialog(kURL, kAlertLoopMessage, /*visible=*/false,
/*is_main_frame=*/true);
// Wait for confirmation action sheet to be shown.
NSString* alertLabel = // Modal dialogs have an additional action sheet for dialog suppression.
l10n_util::GetNSString(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION); if (!AreDialogsNonModal()) {
WaitForAlertWithText(alertLabel, /*visible=*/true); // Wait for confirmation action sheet to be shown.
NSString* alertLabel =
// Tap the suppress dialogs confirmation button. l10n_util::GetNSString(IDS_JAVASCRIPT_MESSAGEBOX_SUPPRESS_OPTION);
TapSuppressDialogsButton(); WaitForAlertWithText(alertLabel, /*visible=*/true);
WaitForAlertWithText(alertLabel, /*visible=*/false);
// Tap the suppress dialogs confirmation button.
TapSuppressDialogsButton();
WaitForAlertWithText(alertLabel, /*visible=*/false);
}
// Wait for the html to be reset to the loop finished text. // Wait for the html to be reset to the loop finished text.
[ChromeEarlGrey waitForWebStateContainingText:kAlertLoopFinishedText]; [ChromeEarlGrey waitForWebStateContainingText:kAlertLoopFinishedText];
...@@ -480,18 +509,23 @@ void TapSuppressDialogsButton() { ...@@ -480,18 +509,23 @@ void TapSuppressDialogsButton() {
// Tap the link to trigger the dialog. // Tap the link to trigger the dialog.
[ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)]; [ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)];
// Make sure the alert is not present. // Make sure the alert is not presented modally over settings.
WaitForJavaScriptDialog(kURL, /*visible=*/false); if (!AreDialogsNonModal()) {
WaitForJavaScriptDialog(kURL, kAlertMessage, /*visible=*/false,
/*is_main_frame=*/true);
}
// Close the settings. // Close the settings.
[[EarlGrey selectElementWithMatcher:SettingsDoneButton()] [[EarlGrey selectElementWithMatcher:SettingsDoneButton()]
performAction:grey_tap()]; performAction:grey_tap()];
// Make sure the alert is present. // Make sure the alert is present.
WaitForJavaScriptDialog(kURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kAlertMessage, /*visible=*/true,
/*is_main_frame=*/true);
[[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()]; [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
WaitForJavaScriptDialog(kURL, /*visible=*/false); WaitForJavaScriptDialog(kURL, kAlertMessage, /*visible=*/false,
/*is_main_frame=*/true);
// Wait for the expected text to be added to the test page. // Wait for the expected text to be added to the test page.
[ChromeEarlGrey waitForWebStateContainingText:kAlertResult]; [ChromeEarlGrey waitForWebStateContainingText:kAlertResult];
...@@ -519,10 +553,12 @@ void TapSuppressDialogsButton() { ...@@ -519,10 +553,12 @@ void TapSuppressDialogsButton() {
// Show an alert and assert it is present. // Show an alert and assert it is present.
[ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)]; [ChromeEarlGrey tapWebStateElementWithID:@(kTestPageLinkID)];
WaitForJavaScriptDialog(kURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kAlertMessage, /*visible=*/true,
/*is_main_frame=*/true);
[[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()]; [[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
WaitForJavaScriptDialog(kURL, /*visible=*/false); WaitForJavaScriptDialog(kURL, kAlertMessage, /*visible=*/false,
/*is_main_frame=*/true);
// Wait for the expected text to be added to the test page. // Wait for the expected text to be added to the test page.
[ChromeEarlGrey waitForWebStateContainingText:kAlertResult]; [ChromeEarlGrey waitForWebStateContainingText:kAlertResult];
...@@ -536,7 +572,8 @@ void TapSuppressDialogsButton() { ...@@ -536,7 +572,8 @@ void TapSuppressDialogsButton() {
} }
// Load the test page with a link to kOnLoadAlertURL and long tap on the link. // Load the test page with a link to kOnLoadAlertURL and long tap on the link.
[ChromeEarlGrey loadURL:self.testServer->GetURL(kLinkPageURLPath)]; const GURL kURL = self.testServer->GetURL(kLinkPageURLPath);
[ChromeEarlGrey loadURL:kURL];
[ChromeEarlGrey waitForWebStateContainingText:kLinkPageLinkText]; [ChromeEarlGrey waitForWebStateContainingText:kLinkPageLinkText];
// TODO(crbug.com/712358): Use method LongPressElementAndTapOnButton once // TODO(crbug.com/712358): Use method LongPressElementAndTapOnButton once
...@@ -568,7 +605,8 @@ void TapSuppressDialogsButton() { ...@@ -568,7 +605,8 @@ void TapSuppressDialogsButton() {
// Wait for the alert to be shown. // Wait for the alert to be shown.
GURL kOnLoadURL = self.testServer->GetURL(kOnLoadURLPath); GURL kOnLoadURL = self.testServer->GetURL(kOnLoadURLPath);
WaitForJavaScriptDialog(kOnLoadURL, /*visible=*/true); WaitForJavaScriptDialog(kURL, kOnLoadAlertMessage, /*visible=*/true,
/*is_main_frame=*/true);
// Verify that the omnibox shows the correct URL when the dialog is visible. // Verify that the omnibox shows the correct URL when the dialog is visible.
std::string title = std::string title =
......
...@@ -14,20 +14,24 @@ ...@@ -14,20 +14,24 @@
// implement these functions using the data from their request configurations. // implement these functions using the data from their request configurations.
@interface AlertOverlayMediator (Subclassing) @interface AlertOverlayMediator (Subclassing)
// The title to supply to the AlertConsumer. Default values is nil. // The title to supply to the AlertConsumer. Default value is nil.
@property(nonatomic, readonly) NSString* alertTitle; @property(nonatomic, readonly) NSString* alertTitle;
// The message to supply to the AlertConsumer. Default values is nil. // The message to supply to the AlertConsumer. Default value is nil.
@property(nonatomic, readonly) NSString* alertMessage; @property(nonatomic, readonly) NSString* alertMessage;
// The text field configurations to supply to the AlertConsumer. Default values // The text field configurations to supply to the AlertConsumer. Default value
// is nil. // is nil.
@property(nonatomic, readonly) @property(nonatomic, readonly)
NSArray<TextFieldConfiguration*>* alertTextFieldConfigurations; NSArray<TextFieldConfiguration*>* alertTextFieldConfigurations;
// The alert actions to supply to the AlertConsumer. Default values is nil. // The alert actions to supply to the AlertConsumer. Default value is nil.
@property(nonatomic, readonly) NSArray<AlertAction*>* alertActions; @property(nonatomic, readonly) NSArray<AlertAction*>* alertActions;
// The accessibility identifier to use for the alert view. Default value is
// nil.
@property(nonatomic, readonly) NSString* alertAccessibilityIdentifier;
@end @end
#endif // IOS_CHROME_BROWSER_UI_OVERLAYS_COMMON_ALERTS_ALERT_OVERLAY_MEDIATOR_SUBCLASSING_H_ #endif // IOS_CHROME_BROWSER_UI_OVERLAYS_COMMON_ALERTS_ALERT_OVERLAY_MEDIATOR_SUBCLASSING_H_
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
[_consumer setTextFieldConfigurations:self.alertTextFieldConfigurations]; [_consumer setTextFieldConfigurations:self.alertTextFieldConfigurations];
NSArray<AlertAction*>* alertActions = self.alertActions; NSArray<AlertAction*>* alertActions = self.alertActions;
[_consumer setActions:alertActions]; [_consumer setActions:alertActions];
[_consumer setAlertAccessibilityIdentifier:self.alertAccessibilityIdentifier];
DCHECK_GT(alertTitle.length + alertMessage.length, 0U); DCHECK_GT(alertTitle.length + alertMessage.length, 0U);
DCHECK_GT(alertActions.count, 0U); DCHECK_GT(alertActions.count, 0U);
} }
...@@ -55,4 +56,9 @@ ...@@ -55,4 +56,9 @@
return nil; return nil;
} }
- (NSString*)alertAccessibilityIdentifier {
// Subclasses implement.
return nil;
}
@end @end
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
@property(nonatomic, readwrite) @property(nonatomic, readwrite)
NSArray<TextFieldConfiguration*>* alertTextFieldConfigurations; NSArray<TextFieldConfiguration*>* alertTextFieldConfigurations;
@property(nonatomic, readwrite) NSArray<AlertAction*>* alertActions; @property(nonatomic, readwrite) NSArray<AlertAction*>* alertActions;
@property(nonatomic, readwrite) NSString* alertAccessibilityIdentifier;
@end @end
@implementation FakeAlertOverlayMediator @implementation FakeAlertOverlayMediator
...@@ -44,6 +45,7 @@ TEST_F(AlertOverlayMediatorTest, SetUpConsumer) { ...@@ -44,6 +45,7 @@ TEST_F(AlertOverlayMediatorTest, SetUpConsumer) {
@[ [AlertAction actionWithTitle:@"Title" @[ [AlertAction actionWithTitle:@"Title"
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:nil] ]; handler:nil] ];
mediator.alertAccessibilityIdentifier = @"identifier";
SetMediator(mediator); SetMediator(mediator);
EXPECT_NSEQ(mediator.alertTitle, consumer().title); EXPECT_NSEQ(mediator.alertTitle, consumer().title);
...@@ -51,4 +53,6 @@ TEST_F(AlertOverlayMediatorTest, SetUpConsumer) { ...@@ -51,4 +53,6 @@ TEST_F(AlertOverlayMediatorTest, SetUpConsumer) {
EXPECT_NSEQ(mediator.alertTextFieldConfigurations, EXPECT_NSEQ(mediator.alertTextFieldConfigurations,
consumer().textFieldConfigurations); consumer().textFieldConfigurations);
EXPECT_NSEQ(mediator.alertActions, consumer().actions); EXPECT_NSEQ(mediator.alertActions, consumer().actions);
EXPECT_NSEQ(mediator.alertAccessibilityIdentifier,
consumer().alertAccessibilityIdentifier);
} }
...@@ -46,6 +46,7 @@ source_set("alerts") { ...@@ -46,6 +46,7 @@ source_set("alerts") {
"//ios/chrome/browser/overlays", "//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/public/web_content_area", "//ios/chrome/browser/overlays/public/web_content_area",
"//ios/chrome/browser/ui/alert_view_controller", "//ios/chrome/browser/ui/alert_view_controller",
"//ios/chrome/browser/ui/dialogs:constants",
"//ios/chrome/browser/ui/elements", "//ios/chrome/browser/ui/elements",
"//ios/chrome/browser/ui/overlays:coordinators", "//ios/chrome/browser/ui/overlays:coordinators",
"//ios/chrome/browser/ui/overlays/common/alerts", "//ios/chrome/browser/ui/overlays/common/alerts",
...@@ -71,6 +72,7 @@ source_set("confirmations") { ...@@ -71,6 +72,7 @@ source_set("confirmations") {
"//ios/chrome/browser/overlays", "//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/public/web_content_area", "//ios/chrome/browser/overlays/public/web_content_area",
"//ios/chrome/browser/ui/alert_view_controller", "//ios/chrome/browser/ui/alert_view_controller",
"//ios/chrome/browser/ui/dialogs:constants",
"//ios/chrome/browser/ui/elements", "//ios/chrome/browser/ui/elements",
"//ios/chrome/browser/ui/overlays:coordinators", "//ios/chrome/browser/ui/overlays:coordinators",
"//ios/chrome/browser/ui/overlays/common/alerts", "//ios/chrome/browser/ui/overlays/common/alerts",
...@@ -96,6 +98,7 @@ source_set("prompts") { ...@@ -96,6 +98,7 @@ source_set("prompts") {
"//ios/chrome/browser/overlays", "//ios/chrome/browser/overlays",
"//ios/chrome/browser/overlays/public/web_content_area", "//ios/chrome/browser/overlays/public/web_content_area",
"//ios/chrome/browser/ui/alert_view_controller", "//ios/chrome/browser/ui/alert_view_controller",
"//ios/chrome/browser/ui/dialogs:constants",
"//ios/chrome/browser/ui/elements", "//ios/chrome/browser/ui/elements",
"//ios/chrome/browser/ui/overlays:coordinators", "//ios/chrome/browser/ui/overlays:coordinators",
"//ios/chrome/browser/ui/overlays/common/alerts", "//ios/chrome/browser/ui/overlays/common/alerts",
...@@ -128,6 +131,7 @@ source_set("unit_tests") { ...@@ -128,6 +131,7 @@ source_set("unit_tests") {
"//ios/chrome/browser/ui/alert_view_controller", "//ios/chrome/browser/ui/alert_view_controller",
"//ios/chrome/browser/ui/alert_view_controller/test", "//ios/chrome/browser/ui/alert_view_controller/test",
"//ios/chrome/browser/ui/dialogs", "//ios/chrome/browser/ui/dialogs",
"//ios/chrome/browser/ui/dialogs:constants",
"//ios/chrome/browser/ui/elements", "//ios/chrome/browser/ui/elements",
"//ios/chrome/browser/ui/overlays/common/alerts/test", "//ios/chrome/browser/ui/overlays/common/alerts/test",
"//ios/chrome/browser/ui/overlays/test", "//ios/chrome/browser/ui/overlays/test",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "ios/chrome/browser/overlays/public/web_content_area/java_script_alert_overlay.h" #import "ios/chrome/browser/overlays/public/web_content_area/java_script_alert_overlay.h"
#import "ios/chrome/browser/ui/alert_view_controller/alert_action.h" #import "ios/chrome/browser/ui/alert_view_controller/alert_action.h"
#import "ios/chrome/browser/ui/alert_view_controller/alert_consumer.h" #import "ios/chrome/browser/ui/alert_view_controller/alert_consumer.h"
#import "ios/chrome/browser/ui/dialogs/dialog_constants.h"
#import "ios/chrome/browser/ui/overlays/common/alerts/alert_overlay_mediator+subclassing.h" #import "ios/chrome/browser/ui/overlays/common/alerts/alert_overlay_mediator+subclassing.h"
#import "ios/chrome/browser/ui/overlays/web_content_area/java_script_dialogs/java_script_dialog_blocking_action.h" #import "ios/chrome/browser/ui/overlays/web_content_area/java_script_dialogs/java_script_dialog_blocking_action.h"
#import "ios/chrome/browser/ui/overlays/web_content_area/java_script_dialogs/java_script_overlay_mediator_util.h" #import "ios/chrome/browser/ui/overlays/web_content_area/java_script_dialogs/java_script_overlay_mediator_util.h"
...@@ -72,4 +73,8 @@ ...@@ -72,4 +73,8 @@
return actions; return actions;
} }
- (NSString*)alertAccessibilityIdentifier {
return kJavaScriptDialogAccessibilityIdentifier;
}
@end @end
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "ios/chrome/browser/overlays/public/web_content_area/java_script_confirmation_overlay.h" #import "ios/chrome/browser/overlays/public/web_content_area/java_script_confirmation_overlay.h"
#import "ios/chrome/browser/ui/alert_view_controller/alert_action.h" #import "ios/chrome/browser/ui/alert_view_controller/alert_action.h"
#import "ios/chrome/browser/ui/alert_view_controller/alert_consumer.h" #import "ios/chrome/browser/ui/alert_view_controller/alert_consumer.h"
#import "ios/chrome/browser/ui/dialogs/dialog_constants.h"
#import "ios/chrome/browser/ui/overlays/web_content_area/java_script_dialogs/java_script_dialog_blocking_action.h" #import "ios/chrome/browser/ui/overlays/web_content_area/java_script_dialogs/java_script_dialog_blocking_action.h"
#import "ios/chrome/browser/ui/overlays/web_content_area/java_script_dialogs/java_script_overlay_mediator_util.h" #import "ios/chrome/browser/ui/overlays/web_content_area/java_script_dialogs/java_script_overlay_mediator_util.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -95,4 +96,8 @@ ...@@ -95,4 +96,8 @@
return actions; return actions;
} }
- (NSString*)alertAccessibilityIdentifier {
return kJavaScriptDialogAccessibilityIdentifier;
}
@end @end
...@@ -9,9 +9,6 @@ ...@@ -9,9 +9,6 @@
class OverlayRequest; class OverlayRequest;
// The accessibility ID for prompt's text field.
extern NSString* const kJavaScriptPromptTextFieldAccessibilityIdentifier;
// Mediator object that uses a JavaScriptPromptOverlayRequestConfig to set // Mediator object that uses a JavaScriptPromptOverlayRequestConfig to set
// up the UI for a JavaScript prompt overlay. // up the UI for a JavaScript prompt overlay.
@interface JavaScriptPromptOverlayMediator : AlertOverlayMediator @interface JavaScriptPromptOverlayMediator : AlertOverlayMediator
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#import "ios/chrome/browser/overlays/public/web_content_area/java_script_prompt_overlay.h" #import "ios/chrome/browser/overlays/public/web_content_area/java_script_prompt_overlay.h"
#import "ios/chrome/browser/ui/alert_view_controller/alert_action.h" #import "ios/chrome/browser/ui/alert_view_controller/alert_action.h"
#import "ios/chrome/browser/ui/alert_view_controller/alert_view_controller.h" #import "ios/chrome/browser/ui/alert_view_controller/alert_view_controller.h"
#import "ios/chrome/browser/ui/dialogs/dialog_constants.h"
#import "ios/chrome/browser/ui/elements/text_field_configuration.h" #import "ios/chrome/browser/ui/elements/text_field_configuration.h"
#import "ios/chrome/browser/ui/overlays/common/alerts/alert_overlay_mediator+subclassing.h" #import "ios/chrome/browser/ui/overlays/common/alerts/alert_overlay_mediator+subclassing.h"
#import "ios/chrome/browser/ui/overlays/overlay_request_coordinator_delegate.h" #import "ios/chrome/browser/ui/overlays/overlay_request_coordinator_delegate.h"
...@@ -23,9 +24,6 @@ ...@@ -23,9 +24,6 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
NSString* const kJavaScriptPromptTextFieldAccessibilityIdentifier =
@"JavaScriptPromptTextFieldAccessibilityIdentifier";
@interface JavaScriptPromptOverlayMediator () @interface JavaScriptPromptOverlayMediator ()
@property(nonatomic, readonly) OverlayRequest* request; @property(nonatomic, readonly) OverlayRequest* request;
@property(nonatomic, readonly) JavaScriptPromptOverlayRequestConfig* config; @property(nonatomic, readonly) JavaScriptPromptOverlayRequestConfig* config;
...@@ -80,7 +78,7 @@ NSString* const kJavaScriptPromptTextFieldAccessibilityIdentifier = ...@@ -80,7 +78,7 @@ NSString* const kJavaScriptPromptTextFieldAccessibilityIdentifier =
return @[ [[TextFieldConfiguration alloc] return @[ [[TextFieldConfiguration alloc]
initWithText:defaultPromptValue initWithText:defaultPromptValue
placeholder:nil placeholder:nil
accessibilityIdentifier:kJavaScriptPromptTextFieldAccessibilityIdentifier accessibilityIdentifier:kJavaScriptDialogTextFieldAccessibilityIdentifier
secureTextEntry:NO] ]; secureTextEntry:NO] ];
} }
...@@ -111,4 +109,8 @@ NSString* const kJavaScriptPromptTextFieldAccessibilityIdentifier = ...@@ -111,4 +109,8 @@ NSString* const kJavaScriptPromptTextFieldAccessibilityIdentifier =
return actions; return actions;
} }
- (NSString*)alertAccessibilityIdentifier {
return kJavaScriptDialogAccessibilityIdentifier;
}
@end @end
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#import "ios/chrome/browser/overlays/public/web_content_area/java_script_prompt_overlay.h" #import "ios/chrome/browser/overlays/public/web_content_area/java_script_prompt_overlay.h"
#import "ios/chrome/browser/ui/alert_view_controller/alert_action.h" #import "ios/chrome/browser/ui/alert_view_controller/alert_action.h"
#import "ios/chrome/browser/ui/alert_view_controller/test/fake_alert_consumer.h" #import "ios/chrome/browser/ui/alert_view_controller/test/fake_alert_consumer.h"
#import "ios/chrome/browser/ui/dialogs/dialog_constants.h"
#import "ios/chrome/browser/ui/dialogs/java_script_dialog_blocking_state.h" #import "ios/chrome/browser/ui/dialogs/java_script_dialog_blocking_state.h"
#import "ios/chrome/browser/ui/elements/text_field_configuration.h" #import "ios/chrome/browser/ui/elements/text_field_configuration.h"
#import "ios/chrome/browser/ui/overlays/common/alerts/test/alert_overlay_mediator_test.h" #import "ios/chrome/browser/ui/overlays/common/alerts/test/alert_overlay_mediator_test.h"
...@@ -98,7 +99,7 @@ TEST_F(JavaScriptPromptOverlayMediatorTest, PromptSetupMainFrame) { ...@@ -98,7 +99,7 @@ TEST_F(JavaScriptPromptOverlayMediatorTest, PromptSetupMainFrame) {
EXPECT_NSEQ(base::SysUTF8ToNSString(default_prompt_value()), EXPECT_NSEQ(base::SysUTF8ToNSString(default_prompt_value()),
consumer().textFieldConfigurations[0].text); consumer().textFieldConfigurations[0].text);
EXPECT_FALSE(!!consumer().textFieldConfigurations[0].placeholder); EXPECT_FALSE(!!consumer().textFieldConfigurations[0].placeholder);
EXPECT_NSEQ(kJavaScriptPromptTextFieldAccessibilityIdentifier, EXPECT_NSEQ(kJavaScriptDialogTextFieldAccessibilityIdentifier,
consumer().textFieldConfigurations[0].accessibilityIdentifier); consumer().textFieldConfigurations[0].accessibilityIdentifier);
ASSERT_EQ(2U, consumer().actions.count); ASSERT_EQ(2U, consumer().actions.count);
EXPECT_EQ(UIAlertActionStyleDefault, consumer().actions[0].style); EXPECT_EQ(UIAlertActionStyleDefault, consumer().actions[0].style);
...@@ -117,7 +118,7 @@ TEST_F(JavaScriptPromptOverlayMediatorTest, PromptSetupIframe) { ...@@ -117,7 +118,7 @@ TEST_F(JavaScriptPromptOverlayMediatorTest, PromptSetupIframe) {
EXPECT_NSEQ(base::SysUTF8ToNSString(default_prompt_value()), EXPECT_NSEQ(base::SysUTF8ToNSString(default_prompt_value()),
consumer().textFieldConfigurations[0].text); consumer().textFieldConfigurations[0].text);
EXPECT_FALSE(!!consumer().textFieldConfigurations[0].placeholder); EXPECT_FALSE(!!consumer().textFieldConfigurations[0].placeholder);
EXPECT_NSEQ(kJavaScriptPromptTextFieldAccessibilityIdentifier, EXPECT_NSEQ(kJavaScriptDialogTextFieldAccessibilityIdentifier,
consumer().textFieldConfigurations[0].accessibilityIdentifier); consumer().textFieldConfigurations[0].accessibilityIdentifier);
ASSERT_EQ(2U, consumer().actions.count); ASSERT_EQ(2U, consumer().actions.count);
EXPECT_EQ(UIAlertActionStyleDefault, consumer().actions[0].style); EXPECT_EQ(UIAlertActionStyleDefault, consumer().actions[0].style);
...@@ -138,7 +139,7 @@ TEST_F(JavaScriptPromptOverlayMediatorTest, PromptSetupWithBlockingOption) { ...@@ -138,7 +139,7 @@ TEST_F(JavaScriptPromptOverlayMediatorTest, PromptSetupWithBlockingOption) {
EXPECT_NSEQ(base::SysUTF8ToNSString(default_prompt_value()), EXPECT_NSEQ(base::SysUTF8ToNSString(default_prompt_value()),
consumer().textFieldConfigurations[0].text); consumer().textFieldConfigurations[0].text);
EXPECT_FALSE(!!consumer().textFieldConfigurations[0].placeholder); EXPECT_FALSE(!!consumer().textFieldConfigurations[0].placeholder);
EXPECT_NSEQ(kJavaScriptPromptTextFieldAccessibilityIdentifier, EXPECT_NSEQ(kJavaScriptDialogTextFieldAccessibilityIdentifier,
consumer().textFieldConfigurations[0].accessibilityIdentifier); consumer().textFieldConfigurations[0].accessibilityIdentifier);
ASSERT_EQ(3U, consumer().actions.count); ASSERT_EQ(3U, consumer().actions.count);
EXPECT_EQ(UIAlertActionStyleDefault, consumer().actions[0].style); EXPECT_EQ(UIAlertActionStyleDefault, consumer().actions[0].style);
......
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