Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / android_webview / javatests / src / org / chromium / android_webview / test / AwContentsClientShouldInterceptRequestTest.java
index 9efd185..de8e625 100644 (file)
@@ -1,33 +1,33 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 package org.chromium.android_webview.test;
 
 import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
 import android.util.Pair;
 
-import org.chromium.android_webview.AndroidProtocolHandler;
 import org.chromium.android_webview.AwContents;
-import org.chromium.android_webview.InterceptedRequestData;
+import org.chromium.android_webview.AwContentsClient.ShouldInterceptRequestParams;
+import org.chromium.android_webview.AwWebResourceResponse;
 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.base.test.util.TestFileUtil;
 import org.chromium.content.browser.test.util.CallbackHelper;
-import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper;
-import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageStartedHelper;
 import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnReceivedErrorHelper;
 import org.chromium.net.test.util.TestWebServer;
 
 import java.io.ByteArrayInputStream;
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.HashMap;
 import java.util.List;
-import java.util.Random;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
 
 /**
  * Tests for the WebViewClient.shouldInterceptRequest() method.
@@ -39,27 +39,35 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
 
         public static class ShouldInterceptRequestHelper extends CallbackHelper {
             private List<String> mShouldInterceptRequestUrls = new ArrayList<String>();
-            private ConcurrentHashMap<String, InterceptedRequestData> mReturnValuesByUrls
-                = new ConcurrentHashMap<String, InterceptedRequestData>();
+            private ConcurrentHashMap<String, AwWebResourceResponse> mReturnValuesByUrls
+                = new ConcurrentHashMap<String, AwWebResourceResponse>();
+            private ConcurrentHashMap<String, ShouldInterceptRequestParams> mParamsByUrls
+                = new ConcurrentHashMap<String, ShouldInterceptRequestParams>();
             // This is read from the IO thread, so needs to be marked volatile.
-            private volatile InterceptedRequestData mShouldInterceptRequestReturnValue = null;
-            void setReturnValue(InterceptedRequestData value) {
+            private volatile AwWebResourceResponse mShouldInterceptRequestReturnValue = null;
+            void setReturnValue(AwWebResourceResponse value) {
                 mShouldInterceptRequestReturnValue = value;
             }
-            void setReturnValueForUrl(String url, InterceptedRequestData value) {
+            void setReturnValueForUrl(String url, AwWebResourceResponse value) {
                 mReturnValuesByUrls.put(url, value);
             }
             public List<String> getUrls() {
                 assert getCallCount() > 0;
                 return mShouldInterceptRequestUrls;
             }
-            public InterceptedRequestData getReturnValue(String url) {
-                InterceptedRequestData value = mReturnValuesByUrls.get(url);
+            public AwWebResourceResponse getReturnValue(String url) {
+                AwWebResourceResponse value = mReturnValuesByUrls.get(url);
                 if (value != null) return value;
                 return mShouldInterceptRequestReturnValue;
             }
-            public void notifyCalled(String url) {
-                mShouldInterceptRequestUrls.add(url);
+            public ShouldInterceptRequestParams getParamsForUrl(String url) {
+                assert getCallCount() > 0;
+                assert mParamsByUrls.containsKey(url);
+                return mParamsByUrls.get(url);
+            }
+            public void notifyCalled(ShouldInterceptRequestParams params) {
+                mShouldInterceptRequestUrls.add(params.url);
+                mParamsByUrls.put(params.url, params);
                 notifyCalled();
             }
         }
@@ -79,9 +87,10 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
         }
 
         @Override
-        public InterceptedRequestData shouldInterceptRequest(String url) {
-            InterceptedRequestData returnValue = mShouldInterceptRequestHelper.getReturnValue(url);
-            mShouldInterceptRequestHelper.notifyCalled(url);
+        public AwWebResourceResponse shouldInterceptRequest(ShouldInterceptRequestParams params) {
+            AwWebResourceResponse returnValue =
+                mShouldInterceptRequestHelper.getReturnValue(params.url);
+            mShouldInterceptRequestHelper.notifyCalled(params);
             return returnValue;
         }
 
@@ -108,6 +117,9 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
         }
     }
 
+    final int teapotStatusCode = 418;
+    final String teapotResponsePhrase = "I'm a teapot";
+
     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"));
@@ -120,11 +132,11 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
                 CommonResources.ABOUT_HTML);
     }
 
-    private InterceptedRequestData stringToInterceptedRequestData(String input) throws Throwable {
+    private AwWebResourceResponse stringToAwWebResourceResponse(String input) throws Throwable {
         final String mimeType = "text/html";
         final String encoding = "UTF-8";
 
-        return new InterceptedRequestData(
+        return new AwWebResourceResponse(
                 mimeType, encoding, new ByteArrayInputStream(input.getBytes(encoding)));
     }
 
@@ -154,14 +166,13 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
 
     @SmallTest
     @Feature({"AndroidWebView"})
-    public void testCalledWithCorrectUrl() throws Throwable {
+    public void testCalledWithCorrectUrlParam() throws Throwable {
         final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
 
-        int callCount = mShouldInterceptRequestHelper.getCallCount();
         int onPageFinishedCallCount = mContentsClient.getOnPageFinishedHelper().getCallCount();
 
+        int callCount = mShouldInterceptRequestHelper.getCallCount();
         loadUrlAsync(mAwContents, aboutPageUrl);
-
         mShouldInterceptRequestHelper.waitForCallback(callCount);
         assertEquals(1, mShouldInterceptRequestHelper.getUrls().size());
         assertEquals(aboutPageUrl,
@@ -173,6 +184,95 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
 
     @SmallTest
     @Feature({"AndroidWebView"})
+    public void testCalledWithCorrectIsMainFrameParam() throws Throwable {
+        final String subframeUrl = addAboutPageToTestServer(mWebServer);
+        final String pageWithIframeUrl = addPageToTestServer(mWebServer, "/page_with_iframe.html",
+                CommonResources.makeHtmlPageFrom("",
+                    "<iframe src=\"" + subframeUrl + "\"/>"));
+
+        int callCount = mShouldInterceptRequestHelper.getCallCount();
+        loadUrlAsync(mAwContents, pageWithIframeUrl);
+        mShouldInterceptRequestHelper.waitForCallback(callCount, 2);
+        assertEquals(2, mShouldInterceptRequestHelper.getUrls().size());
+        assertEquals(false,
+                mShouldInterceptRequestHelper.getParamsForUrl(subframeUrl).isMainFrame);
+        assertEquals(true,
+                mShouldInterceptRequestHelper.getParamsForUrl(pageWithIframeUrl).isMainFrame);
+    }
+
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testCalledWithCorrectMethodParam() throws Throwable {
+        final String pageToPostToUrl = addAboutPageToTestServer(mWebServer);
+        final String pageWithFormUrl = addPageToTestServer(mWebServer, "/page_with_form.html",
+                CommonResources.makeHtmlPageWithSimplePostFormTo(pageToPostToUrl));
+        enableJavaScriptOnUiThread(mAwContents);
+
+        int callCount = mShouldInterceptRequestHelper.getCallCount();
+        loadUrlAsync(mAwContents, pageWithFormUrl);
+        mShouldInterceptRequestHelper.waitForCallback(callCount);
+        assertEquals("GET",
+                mShouldInterceptRequestHelper.getParamsForUrl(pageWithFormUrl).method);
+
+        callCount = mShouldInterceptRequestHelper.getCallCount();
+        JSUtils.clickOnLinkUsingJs(this, mAwContents,
+                mContentsClient.getOnEvaluateJavaScriptResultHelper(), "link");
+        mShouldInterceptRequestHelper.waitForCallback(callCount);
+        assertEquals("POST",
+                mShouldInterceptRequestHelper.getParamsForUrl(pageToPostToUrl).method);
+    }
+
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testCalledWithCorrectHasUserGestureParam() throws Throwable {
+        final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
+        final String pageWithLinkUrl = addPageToTestServer(mWebServer, "/page_with_link.html",
+                CommonResources.makeHtmlPageWithSimpleLinkTo(aboutPageUrl));
+        enableJavaScriptOnUiThread(mAwContents);
+
+        int callCount = mShouldInterceptRequestHelper.getCallCount();
+        loadUrlAsync(mAwContents, pageWithLinkUrl);
+        mShouldInterceptRequestHelper.waitForCallback(callCount);
+        assertEquals(false,
+                mShouldInterceptRequestHelper.getParamsForUrl(pageWithLinkUrl).hasUserGesture);
+
+        callCount = mShouldInterceptRequestHelper.getCallCount();
+        JSUtils.clickOnLinkUsingJs(this, mAwContents,
+                mContentsClient.getOnEvaluateJavaScriptResultHelper(), "link");
+        mShouldInterceptRequestHelper.waitForCallback(callCount);
+        assertEquals(true,
+                mShouldInterceptRequestHelper.getParamsForUrl(aboutPageUrl).hasUserGesture);
+    }
+
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testCalledWithCorrectHeadersParam() throws Throwable {
+        final String headerName = "X-Test-Header-Name";
+        final String headerValue = "TestHeaderValue";
+        final String syncGetUrl = addPageToTestServer(mWebServer, "/intercept_me",
+                CommonResources.ABOUT_HTML);
+        final String mainPageUrl = addPageToTestServer(mWebServer, "/main",
+                CommonResources.makeHtmlPageFrom("",
+                "<script>" +
+                "  var xhr = new XMLHttpRequest();" +
+                "  xhr.open('GET', '" + syncGetUrl + "', false);" +
+                "  xhr.setRequestHeader('" + headerName + "', '" + headerValue + "'); " +
+                "  xhr.send(null);" +
+                "</script>"));
+        enableJavaScriptOnUiThread(mAwContents);
+
+        int callCount = mShouldInterceptRequestHelper.getCallCount();
+        loadUrlAsync(mAwContents, mainPageUrl);
+        mShouldInterceptRequestHelper.waitForCallback(callCount, 2);
+
+        Map<String, String> headers =
+            mShouldInterceptRequestHelper.getParamsForUrl(syncGetUrl).requestHeaders;
+        assertTrue(headers.containsKey(headerName));
+        assertEquals(headerValue, headers.get(headerName));
+    }
+
+    @SmallTest
+    @Feature({"AndroidWebView"})
     public void testOnLoadResourceCalledWithCorrectUrl() throws Throwable {
         final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
         final TestAwContentsClient.OnLoadResourceHelper onLoadResourceHelper =
@@ -192,19 +292,19 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
         final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
 
         mShouldInterceptRequestHelper.setReturnValue(
-                new InterceptedRequestData("text/html", "UTF-8", null));
+                new AwWebResourceResponse("text/html", "UTF-8", null));
         int callCount = mShouldInterceptRequestHelper.getCallCount();
         loadUrlAsync(mAwContents, aboutPageUrl);
         mShouldInterceptRequestHelper.waitForCallback(callCount);
 
         mShouldInterceptRequestHelper.setReturnValue(
-                new InterceptedRequestData(null, null, new ByteArrayInputStream(new byte[0])));
+                new AwWebResourceResponse(null, null, new ByteArrayInputStream(new byte[0])));
         callCount = mShouldInterceptRequestHelper.getCallCount();
         loadUrlAsync(mAwContents, aboutPageUrl);
         mShouldInterceptRequestHelper.waitForCallback(callCount);
 
         mShouldInterceptRequestHelper.setReturnValue(
-                new InterceptedRequestData(null, null, null));
+                new AwWebResourceResponse(null, null, null));
         callCount = mShouldInterceptRequestHelper.getCallCount();
         loadUrlAsync(mAwContents, aboutPageUrl);
         mShouldInterceptRequestHelper.waitForCallback(callCount);
@@ -245,7 +345,50 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
         final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
 
         mShouldInterceptRequestHelper.setReturnValue(
-                new InterceptedRequestData("text/html", "UTF-8", new EmptyInputStream()));
+                new AwWebResourceResponse("text/html", "UTF-8", new EmptyInputStream()));
+        int shouldInterceptRequestCallCount = mShouldInterceptRequestHelper.getCallCount();
+        int onPageFinishedCallCount = mContentsClient.getOnPageFinishedHelper().getCallCount();
+
+        loadUrlAsync(mAwContents, aboutPageUrl);
+
+        mShouldInterceptRequestHelper.waitForCallback(shouldInterceptRequestCallCount);
+        mContentsClient.getOnPageFinishedHelper().waitForCallback(onPageFinishedCallCount);
+    }
+
+    private static class ThrowingInputStream extends EmptyInputStream {
+        @Override
+        public int available() {
+            return 100;
+        }
+
+        @Override
+        public int read() throws IOException {
+            throw new IOException("test exception");
+        }
+
+        @Override
+        public int read(byte b[]) throws IOException {
+            throw new IOException("test exception");
+        }
+
+        @Override
+        public int read(byte b[], int off, int len) throws IOException {
+            throw new IOException("test exception");
+        }
+
+        @Override
+        public long skip(long n) throws IOException {
+            return n;
+        }
+    }
+
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testDoesNotCrashOnThrowingStream() throws Throwable {
+        final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
+
+        mShouldInterceptRequestHelper.setReturnValue(
+                new AwWebResourceResponse("text/html", "UTF-8", new ThrowingInputStream()));
         int shouldInterceptRequestCallCount = mShouldInterceptRequestHelper.getCallCount();
         int onPageFinishedCallCount = mContentsClient.getOnPageFinishedHelper().getCallCount();
 
@@ -255,9 +398,73 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
         mContentsClient.getOnPageFinishedHelper().waitForCallback(onPageFinishedCallCount);
     }
 
+    private static class SlowAwWebResourceResponse extends AwWebResourceResponse {
+        private CallbackHelper mReadStartedCallbackHelper = new CallbackHelper();
+        private CountDownLatch mLatch = new CountDownLatch(1);
+
+        public SlowAwWebResourceResponse(String mimeType, String encoding, InputStream data) {
+            super(mimeType, encoding, data);
+        }
+
+        @Override
+        public InputStream getData() {
+            mReadStartedCallbackHelper.notifyCalled();
+            try {
+                mLatch.await();
+            } catch (InterruptedException e) {
+                // ignore
+            }
+            return super.getData();
+        }
+
+        public void unblockReads() {
+            mLatch.countDown();
+        }
+
+        public CallbackHelper getReadStartedCallbackHelper() {
+            return mReadStartedCallbackHelper;
+        }
+    }
+
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testDoesNotCrashOnSlowStream() throws Throwable {
+        final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
+        final String aboutPageData = makePageWithTitle("some title");
+        final String encoding = "UTF-8";
+        final SlowAwWebResourceResponse slowAwWebResourceResponse =
+            new SlowAwWebResourceResponse("text/html", encoding,
+                    new ByteArrayInputStream(aboutPageData.getBytes(encoding)));
+
+        mShouldInterceptRequestHelper.setReturnValue(slowAwWebResourceResponse);
+        int callCount = slowAwWebResourceResponse.getReadStartedCallbackHelper().getCallCount();
+        loadUrlAsync(mAwContents, aboutPageUrl);
+        slowAwWebResourceResponse.getReadStartedCallbackHelper().waitForCallback(callCount);
+
+        // Now the AwContents is "stuck" waiting for the SlowInputStream to finish reading so we
+        // delete it to make sure that the dangling 'read' task doesn't cause a crash. Unfortunately
+        // this will not always lead to a crash but it should happen often enough for us to notice.
+
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                getActivity().removeAllViews();
+            }
+        });
+        destroyAwContentsOnMainSync(mAwContents);
+        pollOnUiThread(new Callable<Boolean>() {
+            @Override
+            public Boolean call() {
+                return AwContents.getNativeInstanceCount() == 0;
+            }
+        });
+
+        slowAwWebResourceResponse.unblockReads();
+    }
+
     @SmallTest
     @Feature({"AndroidWebView"})
-    public void testHttpStatusField() throws Throwable {
+    public void testHttpStatusCodeAndText() throws Throwable {
         final String syncGetUrl = mWebServer.getResponseUrl("/intercept_me");
         final String syncGetJs =
             "(function() {" +
@@ -265,7 +472,8 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
             "  xhr.open('GET', '" + syncGetUrl + "', false);" +
             "  xhr.send(null);" +
             "  console.info('xhr.status = ' + xhr.status);" +
-            "  return xhr.status;" +
+            "  console.info('xhr.statusText = ' + xhr.statusText);" +
+            "  return '[' + xhr.status + '][' + xhr.statusText + ']';" +
             "})();";
         enableJavaScriptOnUiThread(mAwContents);
 
@@ -273,16 +481,100 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
         loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), aboutPageUrl);
 
         mShouldInterceptRequestHelper.setReturnValue(
-                new InterceptedRequestData("text/html", "UTF-8", null));
-        assertEquals("404",
+                new AwWebResourceResponse("text/html", "UTF-8", null));
+        assertEquals("\"[404][Not Found]\"",
                 executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, syncGetJs));
 
         mShouldInterceptRequestHelper.setReturnValue(
-                new InterceptedRequestData("text/html", "UTF-8", new EmptyInputStream()));
-        assertEquals("200",
+                new AwWebResourceResponse("text/html", "UTF-8", new EmptyInputStream()));
+        assertEquals("\"[200][OK]\"",
+                executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, syncGetJs));
+
+        mShouldInterceptRequestHelper.setReturnValue(
+                new AwWebResourceResponse("text/html", "UTF-8", new EmptyInputStream(),
+                    teapotStatusCode, teapotResponsePhrase, new HashMap<String, String>()));
+        assertEquals("\"[" + teapotStatusCode + "][" + teapotResponsePhrase + "]\"",
                 executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, syncGetJs));
     }
 
+    private String getHeaderValue(AwContents awContents, TestAwContentsClient contentsClient,
+            String url, String headerName) throws Exception {
+        final String syncGetJs =
+            "(function() {" +
+            "  var xhr = new XMLHttpRequest();" +
+            "  xhr.open('GET', '" + url + "', false);" +
+            "  xhr.send(null);" +
+            "  console.info(xhr.getAllResponseHeaders());" +
+            "  return xhr.getResponseHeader('" + headerName + "');" +
+            "})();";
+        String header = executeJavaScriptAndWaitForResult(awContents, contentsClient, syncGetJs);
+
+        if (header.equals("null"))
+            return null;
+        // JSON stringification applied by executeJavaScriptAndWaitForResult adds quotes
+        // around returned strings.
+        assertTrue(header.length() > 2);
+        assertEquals('"', header.charAt(0));
+        assertEquals('"', header.charAt(header.length() - 1));
+        return header.substring(1, header.length() - 1);
+    }
+
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testHttpResponseClientViaHeader() throws Throwable {
+        final String clientResponseHeaderName = "Client-Via";
+        final String clientResponseHeaderValue = "shouldInterceptRequest";
+        final String syncGetUrl = mWebServer.getResponseUrl("/intercept_me");
+        enableJavaScriptOnUiThread(mAwContents);
+
+        final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
+        loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), aboutPageUrl);
+
+        // The response header is set regardless of whether the embedder has provided a
+        // valid resource stream.
+        mShouldInterceptRequestHelper.setReturnValue(
+                new AwWebResourceResponse("text/html", "UTF-8", null));
+        assertEquals(clientResponseHeaderValue,
+                getHeaderValue(mAwContents, mContentsClient, syncGetUrl, clientResponseHeaderName));
+        mShouldInterceptRequestHelper.setReturnValue(
+                new AwWebResourceResponse("text/html", "UTF-8", new EmptyInputStream()));
+        assertEquals(clientResponseHeaderValue,
+                getHeaderValue(mAwContents, mContentsClient, syncGetUrl, clientResponseHeaderName));
+
+    }
+
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testHttpResponseHeader() throws Throwable {
+        final String clientResponseHeaderName = "X-Test-Header-Name";
+        final String clientResponseHeaderValue = "TestHeaderValue";
+        final String syncGetUrl = mWebServer.getResponseUrl("/intercept_me");
+        final Map<String, String> headers = new HashMap<String, String>();
+        headers.put(clientResponseHeaderName, clientResponseHeaderValue);
+        enableJavaScriptOnUiThread(mAwContents);
+
+        final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
+        loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), aboutPageUrl);
+
+        mShouldInterceptRequestHelper.setReturnValue(
+                new AwWebResourceResponse("text/html", "UTF-8", null, 0, null, headers));
+        assertEquals(clientResponseHeaderValue,
+                getHeaderValue(mAwContents, mContentsClient, syncGetUrl, clientResponseHeaderName));
+    }
+
+    @SmallTest
+    @Feature({"AndroidWebView"})
+    public void testNullHttpResponseHeaders() throws Throwable {
+        final String syncGetUrl = mWebServer.getResponseUrl("/intercept_me");
+        enableJavaScriptOnUiThread(mAwContents);
+
+        final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
+        loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), aboutPageUrl);
+
+        mShouldInterceptRequestHelper.setReturnValue(
+                new AwWebResourceResponse("text/html", "UTF-8", null, 0, null, null));
+        assertEquals(null, getHeaderValue(mAwContents, mContentsClient, syncGetUrl, "Some-Header"));
+    }
 
     private String makePageWithTitle(String title) {
         return CommonResources.makeHtmlPageFrom("<title>" + title + "</title>",
@@ -296,7 +588,7 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
         final String expectedPage = makePageWithTitle(expectedTitle);
 
         mShouldInterceptRequestHelper.setReturnValue(
-                stringToInterceptedRequestData(expectedPage));
+                stringToAwWebResourceResponse(expectedPage));
 
         final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
 
@@ -310,7 +602,7 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
     @Feature({"AndroidWebView"})
     public void testDoesNotChangeReportedUrl() throws Throwable {
         mShouldInterceptRequestHelper.setReturnValue(
-                stringToInterceptedRequestData(makePageWithTitle("some title")));
+                stringToAwWebResourceResponse(makePageWithTitle("some title")));
 
         final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
 
@@ -327,7 +619,7 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
             mContentsClient.getOnReceivedErrorHelper();
 
         mShouldInterceptRequestHelper.setReturnValue(
-                new InterceptedRequestData("text/html", "UTF-8", null));
+                new AwWebResourceResponse("text/html", "UTF-8", null));
 
         final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
         final int callCount = onReceivedErrorHelper.getCallCount();
@@ -358,7 +650,7 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
     @SmallTest
     @Feature({"AndroidWebView"})
     public void testOnReceivedErrorCallback() throws Throwable {
-        mShouldInterceptRequestHelper.setReturnValue(new InterceptedRequestData(null, null, null));
+        mShouldInterceptRequestHelper.setReturnValue(new AwWebResourceResponse(null, null, null));
         OnReceivedErrorHelper onReceivedErrorHelper = mContentsClient.getOnReceivedErrorHelper();
         int onReceivedErrorHelperCallCount = onReceivedErrorHelper.getCallCount();
         loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), "foo://bar");
@@ -375,7 +667,7 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
                 addPageToTestServer(mWebServer, "/page_with_image.html",
                         CommonResources.getOnImageLoadedHtml(CommonResources.FAVICON_FILENAME));
         mShouldInterceptRequestHelper.setReturnValueForUrl(
-                imageUrl, new InterceptedRequestData(null, null, null));
+                imageUrl, new AwWebResourceResponse(null, null, null));
         OnReceivedErrorHelper onReceivedErrorHelper = mContentsClient.getOnReceivedErrorHelper();
         int onReceivedErrorHelperCallCount = onReceivedErrorHelper.getCallCount();
         loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), pageWithImage);
@@ -386,12 +678,12 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
     @Feature({"AndroidWebView"})
     public void testCalledForIframe() throws Throwable {
         final String aboutPageUrl = addAboutPageToTestServer(mWebServer);
-        final String pageWithIframe = addPageToTestServer(mWebServer, "/page_with_iframe.html",
+        final String pageWithIframeUrl = addPageToTestServer(mWebServer, "/page_with_iframe.html",
                 CommonResources.makeHtmlPageFrom("",
                     "<iframe src=\"" + aboutPageUrl + "\"/>"));
 
         int callCount = mShouldInterceptRequestHelper.getCallCount();
-        loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), pageWithIframe);
+        loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), pageWithIframeUrl);
         mShouldInterceptRequestHelper.waitForCallback(callCount, 2);
         assertEquals(2, mShouldInterceptRequestHelper.getUrls().size());
         assertEquals(aboutPageUrl, mShouldInterceptRequestHelper.getUrls().get(1));