diff options
author | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-04 23:23:21 +0000 |
---|---|---|
committer | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-04 23:23:21 +0000 |
commit | 8933c79756be35423a11ac3b405e173dbb3f6b5c (patch) | |
tree | 9482dcfad9718419b7a7228dd131e2ef83b1b429 /android_webview/javatests | |
parent | 460fff7d4363a9eb8f0f19fc98324c6bdd1656b5 (diff) | |
download | chromium_src-8933c79756be35423a11ac3b405e173dbb3f6b5c.zip chromium_src-8933c79756be35423a11ac3b405e173dbb3f6b5c.tar.gz chromium_src-8933c79756be35423a11ac3b405e173dbb3f6b5c.tar.bz2 |
Use page transition types to detect API initiated navs
This is more reliable than stashing the last navigated URL for
char-by-char comparison, and specifically deals with the case of a
second javascript: navigation racing in before the prior real navigation
has been processed.
BUG=b/9681730
Review URL: https://chromiumcodereview.appspot.com/18147012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210238 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/javatests')
-rw-r--r-- | android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldOverrideUrlLoadingTest.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldOverrideUrlLoadingTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldOverrideUrlLoadingTest.java index 4a1d2fe..09d9cbe 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldOverrideUrlLoadingTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldOverrideUrlLoadingTest.java @@ -16,6 +16,7 @@ import org.chromium.android_webview.test.util.CommonResources; import org.chromium.android_webview.test.util.JSUtils; import org.chromium.base.test.util.Feature; import org.chromium.content.browser.NavigationHistory; +import org.chromium.content.browser.LoadUrlParams; import org.chromium.content.browser.test.util.CallbackHelper; import org.chromium.content.browser.test.util.Criteria; import org.chromium.content.browser.test.util.CriteriaHelper; @@ -28,6 +29,7 @@ import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; /** * Tests for the WebViewClient.shouldOverrideUrlLoading() method. @@ -783,4 +785,32 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase { getHtmlForPageWithJsRedirectTo(redirectTargetUrl, "Replace", 100)); doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl); } + + @SmallTest + @Feature({"AndroidWebView", "Navigation"}) + public void testDoubleNavigateDoesNotSuppressInitialNavigate() throws Throwable { + final String jsUrl = "javascript:try{console.log('processed js loadUrl');}catch(e){};"; + final TestAwContentsClient contentsClient = new TestAwContentsClient(); + final AwTestContainerView testContainerView = + createAwTestContainerViewOnMainSync(contentsClient); + final AwContents awContents = testContainerView.getAwContents(); + TestAwContentsClient.ShouldOverrideUrlLoadingHelper shouldOverrideUrlLoadingHelper = + contentsClient.getShouldOverrideUrlLoadingHelper(); + + // Do a double navigagtion, the second being an effective no-op, in quick succession (i.e. + // without yielding the main thread inbetween). + int currentCallCount = contentsClient.getOnPageFinishedHelper().getCallCount(); + getInstrumentation().runOnMainSync(new Runnable() { + @Override + public void run() { + awContents.loadUrl(LoadUrlParams.createLoadDataParams( + getHtmlForPageWithSimpleLinkTo(DATA_URL), "text/html", false)); + awContents.loadUrl(new LoadUrlParams(jsUrl)); + } + }); + contentsClient.getOnPageFinishedHelper().waitForCallback(currentCallCount, 1, + WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS); + + assertEquals(0, shouldOverrideUrlLoadingHelper.getCallCount()); + } } |