| Index: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldOverrideUrlLoadingTest.java
|
| 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 5ccc6ebb3dc5dc120a30d9b8479960c7cb079db4..4024f28d4137e2f53aa2ead10d9a6db2ac6ef297 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
|
| @@ -68,13 +68,6 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| return CommonResources.makeHtmlPageFrom("<title>" + TITLE + "</title> " + headers, body);
|
| }
|
|
|
| - private String getHtmlForPageWithSimpleLinkTo(String destination) {
|
| - return makeHtmlPageFrom("",
|
| - "<a href=\"" + destination + "\" id=\"link\">" +
|
| - "<img class=\"big\" />" +
|
| - "</a>");
|
| - }
|
| -
|
| private String getHtmlForPageWithJsAssignLinkTo(String url) {
|
| return makeHtmlPageFrom("",
|
| "<img onclick=\"location.href='" + url + "'\" class=\"big\" id=\"link\" />");
|
| @@ -104,13 +97,6 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| method, timeout));
|
| }
|
|
|
| - private String getHtmlForPageWithSimplePostFormTo(String destination) {
|
| - return makeHtmlPageFrom("",
|
| - "<form action=\"" + destination + "\" method=\"post\">" +
|
| - "<input type=\"submit\" value=\"post\" id=\"link\">" +
|
| - "</form>");
|
| - }
|
| -
|
| private String addPageToTestServer(TestWebServer webServer, String httpPath, String html) {
|
| List<Pair<String, String>> headers = new ArrayList<Pair<String, String>>();
|
| headers.add(Pair.create("Content-Type", "text/html"));
|
| @@ -134,7 +120,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| contentsClient.getShouldOverrideUrlLoadingHelper();
|
|
|
| loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| - getHtmlForPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
|
|
| assertEquals(0, shouldOverrideUrlLoadingHelper.getCallCount());
|
| }
|
| @@ -217,7 +203,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| setShouldOverrideUrlLoadingReturnValueOnUiThread(shouldOverrideUrlLoadingHelper, true);
|
|
|
| loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| - getHtmlForPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
|
|
| assertEquals(TITLE, getTitleOnUiThread(awContents));
|
| }
|
| @@ -234,7 +220,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| OnPageStartedHelper onPageStartedHelper = contentsClient.getOnPageStartedHelper();
|
|
|
| loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| - getHtmlForPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
|
|
| final int shouldOverrideUrlLoadingCallCount = shouldOverrideUrlLoadingHelper.getCallCount();
|
| final int onPageStartedCallCount = onPageStartedHelper.getCallCount();
|
| @@ -259,7 +245,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| final int onReceivedErrorCallCount = onReceivedErrorHelper.getCallCount();
|
|
|
| loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| - getHtmlForPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
|
|
| final int shouldOverrideUrlLoadingCallCount = shouldOverrideUrlLoadingHelper.getCallCount();
|
|
|
| @@ -301,11 +287,11 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| final String anchorLinkPath = "/anchor_link.html";
|
| final String anchorLinkUrl = mWebServer.getResponseUrl(anchorLinkPath);
|
| addPageToTestServer(mWebServer, anchorLinkPath,
|
| - getHtmlForPageWithSimpleLinkTo(anchorLinkUrl + "#anchor"));
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(anchorLinkUrl + "#anchor"));
|
|
|
| if (useLoadData) {
|
| loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| - getHtmlForPageWithSimpleLinkTo("#anchor"), "text/html", false);
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo("#anchor"), "text/html", false);
|
| } else {
|
| loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), anchorLinkUrl);
|
| }
|
| @@ -335,7 +321,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
|
|
| // We can't go to about:blank from here because we'd get a cross-origin error.
|
| loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| - getHtmlForPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
|
|
|
| int callCount = shouldOverrideUrlLoadingHelper.getCallCount();
|
|
|
| @@ -357,7 +343,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| final String httpPath = "/page_with_about_blank_navigation";
|
| final String httpPathOnServer = mWebServer.getResponseUrl(httpPath);
|
| addPageToTestServer(mWebServer, httpPath,
|
| - getHtmlForPageWithSimpleLinkTo(ABOUT_BLANK_URL));
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(ABOUT_BLANK_URL));
|
|
|
| loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| httpPathOnServer);
|
| @@ -384,7 +370,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| final String httpPath = "/page_with_link_to_self.html";
|
| final String httpPathOnServer = mWebServer.getResponseUrl(httpPath);
|
| addPageToTestServer(mWebServer, httpPath,
|
| - getHtmlForPageWithSimpleLinkTo(httpPathOnServer));
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(httpPathOnServer));
|
|
|
| loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| httpPathOnServer);
|
| @@ -454,7 +440,8 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
|
|
| final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
|
| loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| - getHtmlForPageWithSimpleLinkTo(redirectTargetUrl), "text/html", false);
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(redirectTargetUrl), "text/html",
|
| + false);
|
|
|
| int callCount = shouldOverrideUrlLoadingHelper.getCallCount();
|
| clickOnLinkUsingJs(awContents, contentsClient);
|
| @@ -477,11 +464,11 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| final String pageWithLinkToIgnorePath = "/page_with_link_to_ignore.html";
|
| final String pageWithLinkToIgnoreUrl = addPageToTestServer(mWebServer,
|
| pageWithLinkToIgnorePath,
|
| - getHtmlForPageWithSimpleLinkTo(redirectTargetUrl));
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(redirectTargetUrl));
|
| final String synchronizationPath = "/sync.html";
|
| final String synchronizationUrl = addPageToTestServer(mWebServer,
|
| synchronizationPath,
|
| - getHtmlForPageWithSimpleLinkTo(redirectTargetUrl));
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(redirectTargetUrl));
|
|
|
| loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| pageWithLinkToIgnoreUrl);
|
| @@ -518,7 +505,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| TestAwContentsClient.ShouldOverrideUrlLoadingHelper shouldOverrideUrlLoadingHelper =
|
| contentsClient.getShouldOverrideUrlLoadingHelper();
|
| loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| - getHtmlForPageWithSimpleLinkTo(dataUrl), "text/html", false);
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(dataUrl), "text/html", false);
|
|
|
| int callCount = shouldOverrideUrlLoadingHelper.getCallCount();
|
| clickOnLinkUsingJs(awContents, contentsClient);
|
| @@ -541,7 +528,8 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| contentsClient.getShouldOverrideUrlLoadingHelper();
|
| final String unsupportedSchemeUrl = "foobar://resource/1";
|
| loadDataSync(awContents, contentsClient.getOnPageFinishedHelper(),
|
| - getHtmlForPageWithSimpleLinkTo(unsupportedSchemeUrl), "text/html", false);
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(unsupportedSchemeUrl), "text/html",
|
| + false);
|
|
|
| int callCount = shouldOverrideUrlLoadingHelper.getCallCount();
|
| clickOnLinkUsingJs(awContents, contentsClient);
|
| @@ -564,7 +552,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
|
|
| final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
|
| final String postLinkUrl = addPageToTestServer(mWebServer, "/page_with_post_link.html",
|
| - getHtmlForPageWithSimplePostFormTo(redirectTargetUrl));
|
| + CommonResources.makeHtmlPageWithSimplePostFormTo(redirectTargetUrl));
|
|
|
| loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), postLinkUrl);
|
|
|
| @@ -603,7 +591,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
|
| final String postToGetRedirectUrl = mWebServer.setRedirect("/302.html", redirectTargetUrl);
|
| final String postLinkUrl = addPageToTestServer(mWebServer, "/page_with_post_link.html",
|
| - getHtmlForPageWithSimplePostFormTo(postToGetRedirectUrl));
|
| + CommonResources.makeHtmlPageWithSimplePostFormTo(postToGetRedirectUrl));
|
|
|
| loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(), postLinkUrl);
|
|
|
| @@ -702,7 +690,7 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| final AwContents awContents = testContainerView.getAwContents();
|
| final String pageWithLinkToRedirectUrl = addPageToTestServer(webServer,
|
| "/page_with_link_to_redirect.html",
|
| - getHtmlForPageWithSimpleLinkTo(redirectUrl));
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(redirectUrl));
|
| enableJavaScriptOnUiThread(awContents);
|
|
|
| TestAwContentsClient.ShouldOverrideUrlLoadingHelper shouldOverrideUrlLoadingHelper =
|
| @@ -813,7 +801,8 @@ public class AwContentsClientShouldOverrideUrlLoadingTest extends AwTestBase {
|
| @Override
|
| public void run() {
|
| awContents.loadUrl(LoadUrlParams.createLoadDataParams(
|
| - getHtmlForPageWithSimpleLinkTo(DATA_URL), "text/html", false));
|
| + CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html",
|
| + false));
|
| awContents.loadUrl(new LoadUrlParams(jsUrl));
|
| }
|
| });
|
|
|