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

Unified Diff: ios/web/web_state/ui/crw_web_controller_unittest.mm

Issue 2712643007: Added test case for crbug.com/694865 regression. (Closed)
Patch Set: Test case for loading invalid URL Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller_unittest.mm
diff --git a/ios/web/web_state/ui/crw_web_controller_unittest.mm b/ios/web/web_state/ui/crw_web_controller_unittest.mm
index 5f076056ecd182d9790b8bde6f0f268879f9eb6b..3a52ccdcb6c4c7aa005c2f8dace62358b52d9b78 100644
--- a/ios/web/web_state/ui/crw_web_controller_unittest.mm
+++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm
@@ -128,6 +128,9 @@ typedef BOOL (^openExternalURLBlockType)(const GURL&);
namespace {
+// Syntactically invalid URL per rfc3986.
+const char kInvalidURL[] = "http://%3";
+
const char kTestURLString[] = "http://www.google.com/";
const char kTestAppSpecificURL[] = "testwebui://test/";
@@ -687,6 +690,28 @@ TEST_F(CRWWebControllerNavigationTest, HTTPCreditCard) {
web::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP);
}
+// Real WKWebView is required for CRWWebControllerInvalidUrlTest.
+typedef web::WebTestWithWebState CRWWebControllerInvalidUrlTest;
+
+// Tests that web controller navigates to about:blank if invalid URL is loaded.
+TEST_F(CRWWebControllerInvalidUrlTest, LoadInvalidURL) {
+ GURL url(kInvalidURL);
+ ASSERT_FALSE(url.is_valid());
+ LoadHtml(@"<html><body></body></html>", url);
+ EXPECT_EQ(GURL(url::kAboutBlankURL), web_state()->GetLastCommittedURL());
+}
+
+// Tests that web controller does not navigate to about:blank if iframe src
+// has invalid url. Web controller loads about:blank if page navigates to
+// invalid url, but should do nothing if navigation is performed in iframe. This
+// test prevents crbug.com/694865 regression.
+TEST_F(CRWWebControllerInvalidUrlTest, IFrameWithInvalidURL) {
+ GURL url("http://chromium.test");
+ ASSERT_FALSE(GURL(kInvalidURL).is_valid());
+ LoadHtml([NSString stringWithFormat:@"<iframe src='%s'/>", kInvalidURL], url);
+ EXPECT_EQ(url, web_state()->GetLastCommittedURL());
+}
+
// Real WKWebView is required for CRWWebControllerFormActivityTest.
typedef web::WebTestWithWebController CRWWebControllerFormActivityTest;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698