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

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwShouldIgnoreNavigationTest.java

Issue 11017075: Don't intercept POST navigation in android_webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | « android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/javatests/src/org/chromium/android_webview/test/AwShouldIgnoreNavigationTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwShouldIgnoreNavigationTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwShouldIgnoreNavigationTest.java
index 134b8c187411cd1d66fd71c6c387ca455a3404f1..3f895e72d54d1eb174b47367dab313de7265597d 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwShouldIgnoreNavigationTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwShouldIgnoreNavigationTest.java
@@ -190,6 +190,13 @@ public class AwShouldIgnoreNavigationTest extends AndroidWebViewTestBase {
method, timeout));
}
+ private String getHtmlForPageWithSimplePostFormTo(String destination) {
+ return makeHtmlPageFrom("",
+ "<form action=\"" + destination + "\" method=\"post\">" +
+ "<input type=\"submit\" value=\"post\" id=\"link\">"+
+ "</form>");
+ }
+
private String addPageToTestServer(TestWebServer webServer, String httpPath, String html) {
List<Pair<String, String>> headers = new ArrayList<Pair<String, String>>();
headers.add(Pair.create("Content-Type", "text/html"));
@@ -548,6 +555,82 @@ public class AwShouldIgnoreNavigationTest extends AndroidWebViewTestBase {
"data:"));
}
+ @SmallTest
+ @Feature({"Android-WebView", "Navigation"})
+ public void testShouldIgnoreNavigationNotCalledForPostNavigations() throws Throwable {
+ // The reason POST requests are excluded is BUG 155250.
+ final TestAwContentsClient contentsClient = new TestAwContentsClient();
+ final AwTestContainerView testContainerView =
+ createAwTestContainerViewOnMainSync(contentsClient);
+ final AwContents awContents = testContainerView.getAwContents();
+ final TestAwContentsClient.ShouldIgnoreNavigationHelper shouldIgnoreNavigationHelper =
+ contentsClient.getShouldIgnoreNavigationHelper();
+
+ TestWebServer webServer = null;
+ try {
+ // Set up the HTML page.
+ webServer = new TestWebServer(false);
+ final String redirectTargetUrl = createRedirectTargetPage(webServer);
+ final String postLinkUrl = addPageToTestServer(webServer, "/page_with_post_link.html",
+ getHtmlForPageWithSimplePostFormTo(redirectTargetUrl));
+
+ loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), postLinkUrl);
+
+ final int shouldIgnoreNavigationCallCount =
+ shouldIgnoreNavigationHelper.getCallCount();
+
+ clickOnLinkUsingJs(awContents, contentsClient);
+
+ // After we load this URL we're certain that any in-flight callbacks for the previous
+ // navigation have been delivered.
+ loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), ABOUT_BLANK_URL);
+
+ assertEquals(shouldIgnoreNavigationCallCount,
+ shouldIgnoreNavigationHelper.getCallCount());
+ assertEquals(1, webServer.getRequestCount(REDIRECT_TARGET_PATH));
+ } finally {
+ if (webServer != null) webServer.shutdown();
+ }
+ }
+
+ @SmallTest
+ @Feature({"Android-WebView", "Navigation"})
+ public void testShouldIgnoreNavigationNotCalledForIframeNavigations() throws Throwable {
+ final TestAwContentsClient contentsClient = new TestAwContentsClient();
+ final AwTestContainerView testContainerView =
+ createAwTestContainerViewOnMainSync(contentsClient);
+ final AwContents awContents = testContainerView.getAwContents();
+ final TestAwContentsClient.ShouldIgnoreNavigationHelper shouldIgnoreNavigationHelper =
+ contentsClient.getShouldIgnoreNavigationHelper();
+
+ TestWebServer webServer = null;
+ try {
+ // Set up the HTML page.
+ webServer = new TestWebServer(false);
+ final String iframeRedirectTargetUrl = createRedirectTargetPage(webServer);
+ final String iframeRedirectUrl =
+ webServer.setRedirect("/302.html", iframeRedirectTargetUrl);
+ final String pageWithIframeUrl =
+ addPageToTestServer(webServer, "/iframe_intercept.html",
+ makeHtmlPageFrom("", "<iframe src=\"" + iframeRedirectUrl + "\" />"));
+
+ final int shouldIgnoreNavigationCallCount =
+ shouldIgnoreNavigationHelper.getCallCount();
+
+ loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), pageWithIframeUrl);
+
+ // After we load this URL we're certain that any in-flight callbacks for the previous
+ // navigation have been delivered.
+ loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), ABOUT_BLANK_URL);
+
+ assertEquals(shouldIgnoreNavigationCallCount,
+ shouldIgnoreNavigationHelper.getCallCount());
+ assertEquals(1, webServer.getRequestCount(REDIRECT_TARGET_PATH));
+ } finally {
+ if (webServer != null) webServer.shutdown();
+ }
+ }
+
/**
* Worker method for the various redirect tests.
*
« no previous file with comments | « android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698