| 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.
|
| *
|
|
|