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

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

Issue 11417061: [android_webview] Enable navigation interception for iframes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make findbugs happy? Created 8 years, 1 month 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: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldIgnoreNavigationTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldIgnoreNavigationTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldIgnoreNavigationTest.java
index 971a579ba1bee2712eed45d69a1ee5f81b4a277d..182c82b1eeb217016c6fbd20de480704125e297c 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldIgnoreNavigationTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldIgnoreNavigationTest.java
@@ -39,7 +39,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
private final static String TITLE = "TITLE";
private static final long TEST_TIMEOUT = 20000L;
- private static final int CHECK_INTERVAL = 100;
+ private static final long CHECK_INTERVAL = 100;
private static class TestAwContentsClient
extends org.chromium.android_webview.test.TestAwContentsClient {
@@ -189,7 +189,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationNotCalledOnLoadUrl() throws Throwable {
+ public void testNotCalledOnLoadUrl() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -205,7 +205,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCantBlockLoads() throws Throwable {
+ public void testCantBlockLoads() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -223,7 +223,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledBeforeOnPageStarted() throws Throwable {
+ public void testCalledBeforeOnPageStarted() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -247,7 +247,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationDoesNotCauseOnReceivedError() throws Throwable {
+ public void testDoesNotCauseOnReceivedError() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -279,7 +279,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationNotCalledForAnchorNavigations() throws Throwable {
+ public void testNotCalledForAnchorNavigations() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -309,7 +309,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledWhenLinkClicked() throws Throwable {
+ public void testCalledWhenLinkClicked() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -331,7 +331,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledWhenSelfLinkClicked() throws Throwable {
+ public void testCalledWhenSelfLinkClicked() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -358,7 +358,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledWhenNavigatingFromJavaScriptUsingAssign()
+ public void testCalledWhenNavigatingFromJavaScriptUsingAssign()
throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
@@ -381,7 +381,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledWhenNavigatingFromJavaScriptUsingReplace()
+ public void testCalledWhenNavigatingFromJavaScriptUsingReplace()
throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
@@ -402,7 +402,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationPassesCorrectUrl() throws Throwable {
+ public void testPassesCorrectUrl() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -423,7 +423,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCanIgnoreLoading() throws Throwable {
+ public void testCanIgnoreLoading() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -467,7 +467,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledForDataUrl() throws Throwable {
+ public void testCalledForDataUrl() throws Throwable {
final String dataUrl =
"data:text/html;base64," +
"PGh0bWw+PGhlYWQ+PHRpdGxlPmRhdGFVcmxUZXN0QmFzZTY0PC90aXRsZT48" +
@@ -493,7 +493,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledForUnsupportedSchemes() throws Throwable {
+ public void testCalledForUnsupportedSchemes() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -514,7 +514,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationNotCalledForPostNavigations() throws Throwable {
+ public void testNotCalledForPostNavigations() throws Throwable {
// The reason POST requests are excluded is BUG 155250.
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
@@ -532,6 +532,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
final int shouldIgnoreNavigationCallCount =
shouldIgnoreNavigationHelper.getCallCount();
+ assertEquals(0, mWebServer.getRequestCount(REDIRECT_TARGET_PATH));
clickOnLinkUsingJs(awContents, contentsClient);
// Wait for the target URL to be fetched from the server.
@@ -540,7 +541,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
public boolean isSatisfied() {
return mWebServer.getRequestCount(REDIRECT_TARGET_PATH) == 1;
}
- }, WAIT_TIMEOUT_SECONDS * 1000, CHECK_INTERVAL));
+ }, WAIT_TIMEOUT_SECONDS * 1000L, CHECK_INTERVAL));
// Since the targetURL was loaded from the test server it means all processing related
// to dispatching a shouldIgnoreNavigation callback had finished and checking the call
@@ -551,7 +552,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationNotCalledForIframeNavigations() throws Throwable {
+ public void testNotCalledForIframeHttpNavigations() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
@@ -569,15 +570,44 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
final int shouldIgnoreNavigationCallCount =
shouldIgnoreNavigationHelper.getCallCount();
+ assertEquals(0, mWebServer.getRequestCount(REDIRECT_TARGET_PATH));
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);
+ // Wait for the redirect target URL to be fetched from the server.
+ assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return mWebServer.getRequestCount(REDIRECT_TARGET_PATH) == 1;
+ }
+ }, WAIT_TIMEOUT_SECONDS * 1000L, CHECK_INTERVAL));
assertEquals(shouldIgnoreNavigationCallCount,
shouldIgnoreNavigationHelper.getCallCount());
- assertEquals(1, mWebServer.getRequestCount(REDIRECT_TARGET_PATH));
+ }
+
+ @SmallTest
+ @Feature({"AndroidWebView", "Navigation"})
+ public void testCalledForIframeUnsupportedSchemeNavigations() throws Throwable {
+ final TestAwContentsClient contentsClient = new TestAwContentsClient();
+ final AwTestContainerView testContainerView =
+ createAwTestContainerViewOnMainSync(contentsClient);
+ final AwContents awContents = testContainerView.getAwContents();
+ final TestAwContentsClient.ShouldIgnoreNavigationHelper shouldIgnoreNavigationHelper =
+ contentsClient.getShouldIgnoreNavigationHelper();
+
+ final String unsupportedSchemeUrl = "foobar://resource/1";
+ final String pageWithIframeUrl =
+ addPageToTestServer(mWebServer, "/iframe_intercept.html",
+ makeHtmlPageFrom("", "<iframe src=\"" + unsupportedSchemeUrl + "\" />"));
+
+ final int shouldIgnoreNavigationCallCount =
+ shouldIgnoreNavigationHelper.getCallCount();
+
+ loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), pageWithIframeUrl);
+
+ shouldIgnoreNavigationHelper.waitForCallback(shouldIgnoreNavigationCallCount);
+ assertEquals(unsupportedSchemeUrl,
+ shouldIgnoreNavigationHelper.getShouldIgnoreNavigationUrl());
}
/**
@@ -588,7 +618,7 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
* The second part of the test loads a page that contains a link which points at the redirect
* URL. We expect two callbacks - one for the redirect link and another for the destination.
*/
- private void doTestShouldIgnoreNavigationCalledOnRedirect(TestWebServer webServer,
+ private void doTestCalledOnRedirect(TestWebServer webServer,
String redirectUrl, String redirectTarget) throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
@@ -632,66 +662,60 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledOn302Redirect() throws Throwable {
+ public void testCalledOn302Redirect() throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
final String redirectUrl = mWebServer.setRedirect("/302.html", redirectTargetUrl);
- doTestShouldIgnoreNavigationCalledOnRedirect(mWebServer, redirectUrl,
- redirectTargetUrl);
+ doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
}
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledOnMetaRefreshRedirect() throws Throwable {
+ public void testCalledOnMetaRefreshRedirect() throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
final String redirectUrl = addPageToTestServer(mWebServer, "/meta_refresh.html",
getHtmlForPageWithMetaRefreshRedirectTo(redirectTargetUrl));
- doTestShouldIgnoreNavigationCalledOnRedirect(mWebServer, redirectUrl,
- redirectTargetUrl);
+ doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
}
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledOnJavaScriptLocationImmediateAssignRedirect()
+ public void testCalledOnJavaScriptLocationImmediateAssignRedirect()
throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
final String redirectUrl = addPageToTestServer(mWebServer, "/js_immediate_assign.html",
getHtmlForPageWithJsRedirectTo(redirectTargetUrl, "Assign", 0));
- doTestShouldIgnoreNavigationCalledOnRedirect(mWebServer, redirectUrl,
- redirectTargetUrl);
+ doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
}
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledOnJavaScriptLocationImmediateReplaceRedirect()
+ public void testCalledOnJavaScriptLocationImmediateReplaceRedirect()
throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
final String redirectUrl = addPageToTestServer(mWebServer, "/js_immediate_replace.html",
getHtmlForPageWithJsRedirectTo(redirectTargetUrl, "Replace", 0));
- doTestShouldIgnoreNavigationCalledOnRedirect(mWebServer, redirectUrl,
- redirectTargetUrl);
+ doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
}
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledOnJavaScriptLocationDelayedAssignRedirect()
+ public void testCalledOnJavaScriptLocationDelayedAssignRedirect()
throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
final String redirectUrl = addPageToTestServer(mWebServer, "/js_delayed_assign.html",
getHtmlForPageWithJsRedirectTo(redirectTargetUrl, "Assign", 100));
- doTestShouldIgnoreNavigationCalledOnRedirect(mWebServer, redirectUrl,
- redirectTargetUrl);
+ doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
}
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
- public void testShouldIgnoreNavigationCalledOnJavaScriptLocationDelayedReplaceRedirect()
+ public void testCalledOnJavaScriptLocationDelayedReplaceRedirect()
throws Throwable {
final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
final String redirectUrl = addPageToTestServer(mWebServer, "/js_delayed_replace.html",
getHtmlForPageWithJsRedirectTo(redirectTargetUrl, "Replace", 100));
- doTestShouldIgnoreNavigationCalledOnRedirect(mWebServer, redirectUrl,
- redirectTargetUrl);
+ doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
}
}

Powered by Google App Engine
This is Rietveld 408576698