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

Unified Diff: ios/chrome/browser/ui/toolbar/toolbar_egtest.mm

Issue 2761173002: Disallow JS execution on WebUI pages. (Closed)
Patch Set: Addressed review comments Created 3 years, 9 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
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.
« no previous file with comments | « ios/chrome/browser/ui/settings/block_popups_egtest.mm ('k') | ios/web/public/test/web_view_interaction_test_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698