summaryrefslogtreecommitdiffstats
path: root/android_webview/javatests
diff options
context:
space:
mode:
authormkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 16:40:25 +0000
committermkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 16:40:25 +0000
commitce861943aa69c125ef9b9fb9e51c321924a98387 (patch)
treeb28ce1e696501680d10dec996480e8089071c6fe /android_webview/javatests
parent0977214a0afeeb52a0eab97057c8f2a94f4e9e4c (diff)
downloadchromium_src-ce861943aa69c125ef9b9fb9e51c321924a98387.zip
chromium_src-ce861943aa69c125ef9b9fb9e51c321924a98387.tar.gz
chromium_src-ce861943aa69c125ef9b9fb9e51c321924a98387.tar.bz2
[android_webview] Enable navigation interception for iframes.
This enables navigation interception for navigations in iframes. The feature is limited to iframes that do not have a http(s) source. BUG=None Review URL: https://chromiumcodereview.appspot.com/11417061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168811 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/javatests')
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldIgnoreNavigationTest.java104
1 files changed, 64 insertions, 40 deletions
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 971a579..182c82b 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);
}
}