Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Unified Diff: ios/chrome/browser/ui/dialogs/javascript_dialog_egtest.mm

Issue 2957423002: Check page URL origin to determine JavaScript alert titles. (Closed)
Patch Set: Small tweak Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/ui/dialogs/dialog_presenter_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/dialogs/javascript_dialog_egtest.mm
diff --git a/ios/chrome/browser/ui/dialogs/javascript_dialog_egtest.mm b/ios/chrome/browser/ui/dialogs/javascript_dialog_egtest.mm
index 9d4f449c8b122d9b98ba99b3ad43a94b136333ef..7f957a956abf4f2ec8744992c913679692e00409 100644
--- a/ios/chrome/browser/ui/dialogs/javascript_dialog_egtest.mm
+++ b/ios/chrome/browser/ui/dialogs/javascript_dialog_egtest.mm
@@ -200,11 +200,14 @@ void WaitForAlertToBeShown(NSString* alert_label) {
@"Alert with title was not present: %@", alert_label);
}
-void WaitForJavaScripDialogToBeShown() {
- NSString* alert_label = [DialogPresenter
- localizedTitleForJavaScriptAlertFromPage:HttpServer::MakeUrl(
- kJavaScriptTestURL)];
- WaitForAlertToBeShown(alert_label);
+void WaitForJavaScriptDialogToBeShown() {
+ GURL javaScriptURL = HttpServer::MakeUrl(kJavaScriptTestURL);
+
+ NSString* hostname = base::SysUTF8ToNSString(javaScriptURL.host());
+ NSString* expectedTitle = l10n_util::GetNSStringF(
+ IDS_JAVASCRIPT_MESSAGEBOX_TITLE, base::SysNSStringToUTF16(hostname));
+
+ WaitForAlertToBeShown(expectedTitle);
}
// Injects JavaScript to show a dialog with |type|, verifying that it was
@@ -212,7 +215,7 @@ void WaitForJavaScripDialogToBeShown() {
void ShowJavaScriptDialog(JavaScriptAlertType type) {
DisplayJavaScriptAlert(type);
- WaitForJavaScripDialogToBeShown();
+ WaitForJavaScriptDialogToBeShown();
// Check the message of the alert.
id<GREYMatcher> messageLabel =
@@ -226,11 +229,13 @@ void ShowJavaScriptDialog(JavaScriptAlertType type) {
void AssertJavaScriptAlertNotPresent() {
ConditionBlock condition = ^{
NSError* error = nil;
- NSString* alertLabel = [DialogPresenter
- localizedTitleForJavaScriptAlertFromPage:HttpServer::MakeUrl(
- kJavaScriptTestURL)];
+ GURL javaScriptURL = HttpServer::MakeUrl(kJavaScriptTestURL);
+ NSString* hostname = base::SysUTF8ToNSString(javaScriptURL.host());
+ NSString* expectedTitle = l10n_util::GetNSStringF(
+ IDS_JAVASCRIPT_MESSAGEBOX_TITLE, base::SysNSStringToUTF16(hostname));
+
id<GREYMatcher> titleLabel =
- chrome_test_util::StaticTextWithAccessibilityLabel(alertLabel);
+ chrome_test_util::StaticTextWithAccessibilityLabel(expectedTitle);
[[EarlGrey selectElementWithMatcher:titleLabel] assertWithMatcher:grey_nil()
error:&error];
return !error;
@@ -443,10 +448,10 @@ void TapSuppressDialogsButton() {
web::WebState* webState = chrome_test_util::GetCurrentWebState();
NSString* script = GetJavaScriptAlertLoopScript();
webState->ExecuteJavaScript(base::SysNSStringToUTF16(script));
- WaitForJavaScripDialogToBeShown();
+ WaitForJavaScriptDialogToBeShown();
[[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
- WaitForJavaScripDialogToBeShown();
+ WaitForJavaScriptDialogToBeShown();
// Tap the suppress dialogs button.
TapSuppressDialogsButton();
@@ -495,7 +500,7 @@ void TapSuppressDialogsButton() {
performAction:grey_tap()];
// Make sure the alert is present.
- WaitForJavaScripDialogToBeShown();
+ WaitForJavaScriptDialogToBeShown();
[[EarlGrey selectElementWithMatcher:OKButton()] performAction:grey_tap()];
@@ -574,10 +579,12 @@ void TapSuppressDialogsButton() {
}
// Wait for the alert to be shown.
- NSString* alertLabel = [DialogPresenter
- localizedTitleForJavaScriptAlertFromPage:HttpServer::MakeUrl(
- kJavaScriptTestURL)];
- WaitForAlertToBeShown(alertLabel);
+ GURL javaScriptURL = HttpServer::MakeUrl(kJavaScriptTestURL);
+ NSString* hostname = base::SysUTF8ToNSString(javaScriptURL.host());
+ NSString* expectedTitle = l10n_util::GetNSStringF(
+ IDS_JAVASCRIPT_MESSAGEBOX_TITLE, base::SysNSStringToUTF16(hostname));
+
+ WaitForAlertToBeShown(expectedTitle);
// Verify that the omnibox shows the correct URL when the dialog is visible.
GURL onloadURL = HttpServer::MakeUrl(kOnLoadAlertURL);
« no previous file with comments | « ios/chrome/browser/ui/dialogs/dialog_presenter_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698