summaryrefslogtreecommitdiffstats
path: root/android_webview/javatests
diff options
context:
space:
mode:
authormkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-13 21:47:25 +0000
committermkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-13 21:47:25 +0000
commit3d4abb97289b8c26f4a959deea6f12e5f24ad3e0 (patch)
treed8e8f29049cc6c1e1c6b7576c7de17758195ee42 /android_webview/javatests
parentfb40727385c743327d114ebaa4a0cba975da72d6 (diff)
downloadchromium_src-3d4abb97289b8c26f4a959deea6f12e5f24ad3e0.zip
chromium_src-3d4abb97289b8c26f4a959deea6f12e5f24ad3e0.tar.gz
chromium_src-3d4abb97289b8c26f4a959deea6f12e5f24ad3e0.tar.bz2
[android_webview] Suppress shouldOverrideUrlLoading on history navigation.
We suppress the WebViewClient.shouldOverrideUrlLoading for navigations initiated by the loadUrl method. This change extends the behavior to the goBack, goForward and goBackOrForward methods. BUG=179336 Review URL: https://chromiumcodereview.appspot.com/12461014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/javatests')
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldIgnoreNavigationTest.java65
1 files changed, 65 insertions, 0 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 182c82b..3e24b6d 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
@@ -203,6 +203,71 @@ public class AwContentsClientShouldIgnoreNavigationTest extends AndroidWebViewTe
assertEquals(0, shouldIgnoreNavigationHelper.getCallCount());
}
+ private void waitForNavigationRunnableAndAssertTitleChanged(AwContents awContents,
+ CallbackHelper onPageFinishedHelper,
+ Runnable navigationRunnable) throws Exception {
+ final int callCount = onPageFinishedHelper.getCallCount();
+ final String oldTitle = getTitleOnUiThread(awContents);
+ getInstrumentation().runOnMainSync(navigationRunnable);
+ onPageFinishedHelper.waitForCallback(callCount);
+ assertFalse(oldTitle.equals(getTitleOnUiThread(awContents)));
+ }
+
+ @SmallTest
+ @Feature({"AndroidWebView", "Navigation"})
+ public void testNotCalledOnBackForwardNavigation() throws Throwable {
+ final TestAwContentsClient contentsClient = new TestAwContentsClient();
+ final AwTestContainerView testContainerView =
+ createAwTestContainerViewOnMainSync(contentsClient);
+ final AwContents awContents = testContainerView.getAwContents();
+ TestAwContentsClient.ShouldIgnoreNavigationHelper shouldIgnoreNavigationHelper =
+ contentsClient.getShouldIgnoreNavigationHelper();
+ final String[] pageTitles = new String[] { "page1", "page2", "page3" };
+
+ for (String title: pageTitles) {
+ loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
+ CommonResources.makeHtmlPageFrom("<title>" + title + "</title>", ""),
+ "text/html", false);
+ }
+ assertEquals(0, shouldIgnoreNavigationHelper.getCallCount());
+
+ waitForNavigationRunnableAndAssertTitleChanged(awContents,
+ contentsClient.getOnPageFinishedHelper(), new Runnable() {
+ @Override
+ public void run() {
+ awContents.goBack();
+ }
+ });
+ assertEquals(0, shouldIgnoreNavigationHelper.getCallCount());
+
+ waitForNavigationRunnableAndAssertTitleChanged(awContents,
+ contentsClient.getOnPageFinishedHelper(), new Runnable() {
+ @Override
+ public void run() {
+ awContents.goForward();
+ }
+ });
+ assertEquals(0, shouldIgnoreNavigationHelper.getCallCount());
+
+ waitForNavigationRunnableAndAssertTitleChanged(awContents,
+ contentsClient.getOnPageFinishedHelper(), new Runnable() {
+ @Override
+ public void run() {
+ awContents.goBackOrForward(-2);
+ }
+ });
+ assertEquals(0, shouldIgnoreNavigationHelper.getCallCount());
+
+ waitForNavigationRunnableAndAssertTitleChanged(awContents,
+ contentsClient.getOnPageFinishedHelper(), new Runnable() {
+ @Override
+ public void run() {
+ awContents.goBackOrForward(1);
+ }
+ });
+ assertEquals(0, shouldIgnoreNavigationHelper.getCallCount());
+ }
+
@SmallTest
@Feature({"AndroidWebView", "Navigation"})
public void testCantBlockLoads() throws Throwable {