| Index: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java
|
| diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java
|
| index 4edf7552470af9597665b7992dab4492811a89b5..0058471eb1d3b3bf528fd3a1b269240c3c8ada6c 100644
|
| --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java
|
| +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java
|
| @@ -349,6 +349,39 @@ public class AwContentsClientShouldInterceptRequestTest extends AwTestBase {
|
| executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, syncGetJs));
|
| }
|
|
|
| + @SmallTest
|
| + @Feature({"AndroidWebView"})
|
| + public void testHttpResponseClientHeader() throws Throwable {
|
| + final String clientResponseHeaderName = "Client-Via";
|
| + // JSON stringification applied by executeJavaScriptAndWaitForResult adds quotes
|
| + // around returned strings.
|
| + final String clientResponseHeaderValue = "\"shouldInterceptRequest\"";
|
| + final String syncGetUrl = mWebServer.getResponseUrl("/intercept_me");
|
| + final String syncGetJs =
|
| + "(function() {" +
|
| + " var xhr = new XMLHttpRequest();" +
|
| + " xhr.open('GET', '" + syncGetUrl + "', false);" +
|
| + " xhr.send(null);" +
|
| + " console.info(xhr.getAllResponseHeaders());" +
|
| + " return xhr.getResponseHeader('" + clientResponseHeaderName + "');" +
|
| + "})();";
|
| + 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 InterceptedRequestData("text/html", "UTF-8", null));
|
| + assertEquals(clientResponseHeaderValue,
|
| + executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, syncGetJs));
|
| + mShouldInterceptRequestHelper.setReturnValue(
|
| + new InterceptedRequestData("text/html", "UTF-8", new EmptyInputStream()));
|
| + assertEquals(clientResponseHeaderValue,
|
| + executeJavaScriptAndWaitForResult(mAwContents, mContentsClient, syncGetJs));
|
| + }
|
| +
|
|
|
| private String makePageWithTitle(String title) {
|
| return CommonResources.makeHtmlPageFrom("<title>" + title + "</title>",
|
|
|