Index: ios/chrome/browser/ui/toolbar/toolbar_egtest.mm |
diff --git a/ios/chrome/browser/ui/toolbar/toolbar_egtest.mm b/ios/chrome/browser/ui/toolbar/toolbar_egtest.mm |
index 35549a8af46f8308e3ba4a7eafef20725ab1ae5f..20370738f5094270dcab00e28aea35ff8a160436 100644 |
--- a/ios/chrome/browser/ui/toolbar/toolbar_egtest.mm |
+++ b/ios/chrome/browser/ui/toolbar/toolbar_egtest.mm |
@@ -340,7 +340,13 @@ void SelectNewTabPagePanel(NewTabPage::PanelIdentifier panel_type) { |
if (IsIPadIdiom() && base::ios::IsRunningOnIOS10OrLater()) { |
EARL_GREY_TEST_DISABLED(@"Disabled for iOS10 iPad due to a typing bug."); |
} |
- [ChromeEarlGrey loadURL:GURL("chrome://version")]; |
+ |
+ std::map<GURL, std::string> responses; |
+ GURL URL = web::test::HttpServer::MakeUrl("http://foo"); |
+ responses[URL] = "bar"; |
+ web::test::SetUpSimpleHttpServer(responses); |
+ [ChromeEarlGrey loadURL:GURL(URL)]; |
+ |
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] |
performAction:grey_typeText(@"javascript:alert('Hello');")]; |
@@ -351,6 +357,25 @@ void SelectNewTabPagePanel(NewTabPage::PanelIdentifier panel_type) { |
assertWithMatcher:grey_notNil()]; |
} |
+// Loads WebUI page, types JavaScript into Omnibox and verifies that alert is |
+// not displayed. WebUI pages have elevated privileges and should not allow |
+// script execution. |
+- (void)testTypeJavaScriptIntoOmniboxWithWebUIPage { |
+ // TODO(crbug.com/642544): Enable the test for iPad when typing bug is fixed. |
+ if (IsIPadIdiom() && base::ios::IsRunningOnIOS10OrLater()) { |
+ EARL_GREY_TEST_DISABLED(@"Disabled for iOS10 iPad due to a typing bug."); |
+ } |
+ [ChromeEarlGrey loadURL:GURL("chrome://version")]; |
+ [[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()] |
+ performAction:grey_typeText(@"javascript:alert('Hello');")]; |
+ |
+ [[EarlGrey selectElementWithMatcher:grey_accessibilityID(@"Go")] |
+ performAction:grey_tap()]; |
+ |
+ [[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Hello")] |
+ assertWithMatcher:grey_nil()]; |
+} |
+ |
// Tests typing in the omnibox. |
- (void)testToolbarOmniboxTyping { |
// TODO(crbug.com/642559): Enable this test for iPad when typing bug is fixed. |