diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java index 177f8c73e89de..6fb0b3d6f36d4 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/LoadDataWithBaseUrlTest.java @@ -373,4 +373,37 @@ public void testLoadLargeData() throws Throwable { assertEquals("true", executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, "window.gotToEndOfBody")); } + + @SmallTest + @Feature({"AndroidWebView"}) + public void testOnPageFinishedWhenInterrupted() throws Throwable { + // See crbug.com/594001 -- when a javascript: URL is loaded, the pending entry + // gets discarded and the previous load goes through a different path + // inside NavigationController. + final String pageHtml = "
Hello, world!"; + final String baseUrl = "http://example.com/"; + final TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = + mContentsClient.getOnPageFinishedHelper(); + final int callCount = onPageFinishedHelper.getCallCount(); + loadDataWithBaseUrlAsync(mAwContents, pageHtml, "text/html", false, baseUrl, null); + loadUrlAsync(mAwContents, "javascript:42"); + onPageFinishedHelper.waitForCallback(callCount); + assertEquals(baseUrl, onPageFinishedHelper.getUrl()); + } + + @SmallTest + @Feature({"AndroidWebView"}) + public void testOnPageFinishedWithInvalidBaseUrlWhenInterrupted() throws Throwable { + final String pageHtml = CommonResources.ABOUT_HTML; + final String invalidBaseUrl = "http://"; + final TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = + mContentsClient.getOnPageFinishedHelper(); + final int callCount = onPageFinishedHelper.getCallCount(); + getAwSettingsOnUiThread(mAwContents).setJavaScriptEnabled(true); + loadDataWithBaseUrlAsync(mAwContents, pageHtml, "text/html", false, invalidBaseUrl, null); + loadUrlAsync(mAwContents, "javascript:42"); + onPageFinishedHelper.waitForCallback(callCount); + // Verify that the load succeeds. The actual base url is undefined. + assertEquals(CommonResources.ABOUT_TITLE, getTitleOnUiThread(mAwContents)); + } } diff --git a/content/browser/android/web_contents_observer_proxy.cc b/content/browser/android/web_contents_observer_proxy.cc index 4b5b388ce16f7..0483fd867f004 100644 --- a/content/browser/android/web_contents_observer_proxy.cc +++ b/content/browser/android/web_contents_observer_proxy.cc @@ -93,6 +93,9 @@ void WebContentsObserverProxy::DidStartLoading() { ScopedJavaLocalRef