Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientShouldInterceptRequestTest.java

Issue 177423009: [Android WebView] Provide a response header for application-provided content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/browser/net/android_stream_reader_url_request_job.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>",
« no previous file with comments | « android_webview/browser/net/android_stream_reader_url_request_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698