| Index: android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java
|
| diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java
|
| index dc513fcc15017d9fd3d3c076902ff52409260769..cd9eb8a4176d7a276f815d9775e96d93300c37d7 100644
|
| --- a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java
|
| +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java
|
| @@ -313,6 +313,35 @@ public class AndroidScrollIntegrationTest extends AwTestBase {
|
| firstFrameObserver.waitForEvent(WAIT_TIMEOUT_MS);
|
| }
|
|
|
| + private void loadTestPageWithBaseUrlAndWaitForFirstFrame(
|
| + final ScrollTestContainerView testContainerView,
|
| + final TestAwContentsClient contentsClient, final String onscrollObserverName,
|
| + final String extraContent, final String baseUrl, final String historyUrl)
|
| + throws Throwable {
|
| + final JavascriptEventObserver firstFrameObserver = new JavascriptEventObserver();
|
| + final String firstFrameObserverName = "firstFrameObserver";
|
| + enableJavaScriptOnUiThread(testContainerView.getAwContents());
|
| +
|
| + getInstrumentation().runOnMainSync(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + firstFrameObserver.register(testContainerView.getContentViewCore(),
|
| + firstFrameObserverName);
|
| + }
|
| + });
|
| +
|
| + loadDataWithBaseUrlSync(testContainerView.getAwContents(),
|
| + contentsClient.getOnPageFinishedHelper(),
|
| + makeTestPage(onscrollObserverName, firstFrameObserverName, extraContent),
|
| + "text/html", false, baseUrl, historyUrl);
|
| +
|
| + // We wait for "a couple" of frames for the active tree in CC to stabilize and for pending
|
| + // tree activations to stop clobbering the root scroll layer's scroll offset. This wait
|
| + // doesn't strictly guarantee that but there isn't a good alternative and this seems to
|
| + // work fine.
|
| + firstFrameObserver.waitForEvent(WAIT_TIMEOUT_MS);
|
| + }
|
| +
|
| @SmallTest
|
| @Feature({"AndroidWebView"})
|
| public void testUiScrollReflectedInJs() throws Throwable {
|
| @@ -880,4 +909,40 @@ public class AndroidScrollIntegrationTest extends AwTestBase {
|
| }
|
| });
|
| }
|
| +
|
| + @SmallTest
|
| + @Feature("AndroidWebView")
|
| + public void testScrollOffsetAfterNewDataUrlWithNullBaseUrlNavigation() throws Throwable {
|
| + final TestAwContentsClient contentsClient = new TestAwContentsClient();
|
| + final ScrollTestContainerView testContainerView =
|
| + (ScrollTestContainerView) createAwTestContainerViewOnMainSync(contentsClient);
|
| + enableJavaScriptOnUiThread(testContainerView.getAwContents());
|
| +
|
| + // Load a Data URL page with specifying a base URL, and check the initial scroll position.
|
| + StringBuilder extraContent1 = new StringBuilder();
|
| + for (int i = 0; i < 10; ++i) {
|
| + extraContent1.append(i);
|
| + extraContent1.append("<br><br><br><br><br><br><br><br><br><br>");
|
| + }
|
| + final String baseUrl = null;
|
| + final String historyUrl = null;
|
| + loadTestPageWithBaseUrlAndWaitForFirstFrame(testContainerView, contentsClient, null,
|
| + extraContent1.toString(), baseUrl, historyUrl);
|
| + assertScrollOnMainSync(testContainerView, 0, 0);
|
| +
|
| + // Scroll down.
|
| + final int targetScrollYPix = 10;
|
| + scrollToOnMainSync(testContainerView, 0, targetScrollYPix);
|
| + assertScrollOnMainSync(testContainerView, 0, targetScrollYPix);
|
| +
|
| + // Load another Data URL page, and check if the scroll position is reset correctly.
|
| + StringBuilder extraContent2 = new StringBuilder();
|
| + for (int i = 10; i < 20; ++i) {
|
| + extraContent2.append(i);
|
| + extraContent2.append("<br><br><br><br><br><br><br><br><br><br>");
|
| + }
|
| + loadTestPageWithBaseUrlAndWaitForFirstFrame(testContainerView, contentsClient, null,
|
| + extraContent2.toString(), baseUrl, historyUrl);
|
| + assertScrollOnMainSync(testContainerView, 0, 0);
|
| + }
|
| }
|
|
|