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

Unified Diff: chrome/browser/apps/web_view_browsertest.cc

Issue 640603005: <webview>: Add additional WebRequest API test coverage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix appshell test Created 6 years, 2 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 | « no previous file | chrome/test/data/extensions/platform_apps/web_view/shim/main.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/apps/web_view_browsertest.cc
diff --git a/chrome/browser/apps/web_view_browsertest.cc b/chrome/browser/apps/web_view_browsertest.cc
index 87f9fcdb59a8dab5612259873fddf0800757d77c..ed11fef02ea71cc5cf67d05d9ae9933b4f1e07ae 100644
--- a/chrome/browser/apps/web_view_browsertest.cc
+++ b/chrome/browser/apps/web_view_browsertest.cc
@@ -69,6 +69,7 @@ using ui::MenuModel;
namespace {
const char kEmptyResponsePath[] = "/close-socket";
const char kRedirectResponsePath[] = "/server-redirect";
+const char kUserAgentRedirectResponsePath[] = "/detect-user-agent";
const char kRedirectResponseFullPath[] =
"/extensions/platform_apps/web_view/shim/guest_redirect.html";
@@ -470,6 +471,28 @@ class WebViewTest : public extensions::PlatformAppBrowserTest {
}
}
+ // Handles |request| by serving a redirect response if the |User-Agent| is
+ // foobar.
+ static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler(
+ const std::string& path,
+ const GURL& redirect_target,
+ const net::test_server::HttpRequest& request) {
+ if (!StartsWithASCII(path, request.relative_url, true))
+ return scoped_ptr<net::test_server::HttpResponse>();
+
+ std::map<std::string, std::string>::const_iterator it =
+ request.headers.find("User-Agent");
+ EXPECT_TRUE(it != request.headers.end());
+ if (!StartsWithASCII("foobar", it->second, true))
+ return scoped_ptr<net::test_server::HttpResponse>();
+
+ scoped_ptr<net::test_server::BasicHttpResponse> http_response(
+ new net::test_server::BasicHttpResponse);
+ http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
+ http_response->AddCustomHeader("Location", redirect_target.spec());
+ return http_response.PassAs<net::test_server::HttpResponse>();
+ }
+
// Handles |request| by serving a redirect response.
static scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
const std::string& path,
@@ -537,6 +560,12 @@ class WebViewTest : public extensions::PlatformAppBrowserTest {
embedded_test_server()->RegisterRequestHandler(
base::Bind(&WebViewTest::EmptyResponseHandler, kEmptyResponsePath));
+
+ embedded_test_server()->RegisterRequestHandler(
+ base::Bind(
+ &WebViewTest::UserAgentResponseHandler,
+ kUserAgentRedirectResponsePath,
+ embedded_test_server()->GetURL(kRedirectResponseFullPath)));
}
LoadAndLaunchPlatformApp(app_location.c_str(), "Launched");
@@ -1028,6 +1057,12 @@ IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestWebRequestAPI) {
TestHelper("testWebRequestAPI", "web_view/shim", NEEDS_TEST_SERVER);
}
+IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestWebRequestAPIWithHeaders) {
+ TestHelper("testWebRequestAPIWithHeaders",
+ "web_view/shim",
+ NEEDS_TEST_SERVER);
+}
+
IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestWebRequestAPIGoogleProperty) {
TestHelper("testWebRequestAPIGoogleProperty",
"web_view/shim",
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/shim/main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698