diff options
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()); + } } |