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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/path_service.h" 5 #include "base/path_service.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/apps/app_browsertest_util.h" 8 #include "chrome/browser/apps/app_browsertest_util.h"
9 #include "chrome/browser/chrome_content_browser_client.h" 9 #include "chrome/browser/chrome_content_browser_client.h"
10 #include "chrome/browser/prerender/prerender_link_manager.h" 10 #include "chrome/browser/prerender/prerender_link_manager.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 using task_manager::browsertest_util::MatchAnyWebView; 62 using task_manager::browsertest_util::MatchAnyWebView;
63 using task_manager::browsertest_util::MatchApp; 63 using task_manager::browsertest_util::MatchApp;
64 using task_manager::browsertest_util::MatchBackground; 64 using task_manager::browsertest_util::MatchBackground;
65 using task_manager::browsertest_util::MatchWebView; 65 using task_manager::browsertest_util::MatchWebView;
66 using task_manager::browsertest_util::WaitForTaskManagerRows; 66 using task_manager::browsertest_util::WaitForTaskManagerRows;
67 using ui::MenuModel; 67 using ui::MenuModel;
68 68
69 namespace { 69 namespace {
70 const char kEmptyResponsePath[] = "/close-socket"; 70 const char kEmptyResponsePath[] = "/close-socket";
71 const char kRedirectResponsePath[] = "/server-redirect"; 71 const char kRedirectResponsePath[] = "/server-redirect";
72 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent";
72 const char kRedirectResponseFullPath[] = 73 const char kRedirectResponseFullPath[] =
73 "/extensions/platform_apps/web_view/shim/guest_redirect.html"; 74 "/extensions/platform_apps/web_view/shim/guest_redirect.html";
74 75
75 // Platform-specific filename relative to the chrome executable. 76 // Platform-specific filename relative to the chrome executable.
76 #if defined(OS_WIN) 77 #if defined(OS_WIN)
77 const wchar_t library_name[] = L"ppapi_tests.dll"; 78 const wchar_t library_name[] = L"ppapi_tests.dll";
78 #elif defined(OS_MACOSX) 79 #elif defined(OS_MACOSX)
79 const char library_name[] = "ppapi_tests.plugin"; 80 const char library_name[] = "ppapi_tests.plugin";
80 #elif defined(OS_POSIX) 81 #elif defined(OS_POSIX)
81 const char library_name[] = "libppapi_tests.so"; 82 const char library_name[] = "libppapi_tests.so";
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 *persistent_partition_contents1 = source5->GetWebContents(); 464 *persistent_partition_contents1 = source5->GetWebContents();
464 } 465 }
465 if (persistent_partition_contents2) { 466 if (persistent_partition_contents2) {
466 *persistent_partition_contents2 = source6->GetWebContents(); 467 *persistent_partition_contents2 = source6->GetWebContents();
467 } 468 }
468 if (persistent_partition_contents3) { 469 if (persistent_partition_contents3) {
469 *persistent_partition_contents3 = source7->GetWebContents(); 470 *persistent_partition_contents3 = source7->GetWebContents();
470 } 471 }
471 } 472 }
472 473
474 // Handles |request| by serving a redirect response if the |User-Agent| is
475 // foobar.
476 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler(
477 const std::string& path,
478 const GURL& redirect_target,
479 const net::test_server::HttpRequest& request) {
480 if (!StartsWithASCII(path, request.relative_url, true))
481 return scoped_ptr<net::test_server::HttpResponse>();
482
483 std::map<std::string, std::string>::const_iterator it =
484 request.headers.find("User-Agent");
485 EXPECT_TRUE(it != request.headers.end());
486 if (!StartsWithASCII("foobar", it->second, true))
487 return scoped_ptr<net::test_server::HttpResponse>();
488
489 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
490 new net::test_server::BasicHttpResponse);
491 http_response->set_code(net::HTTP_MOVED_PERMANENTLY);
492 http_response->AddCustomHeader("Location", redirect_target.spec());
493 return http_response.PassAs<net::test_server::HttpResponse>();
494 }
495
473 // Handles |request| by serving a redirect response. 496 // Handles |request| by serving a redirect response.
474 static scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler( 497 static scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
475 const std::string& path, 498 const std::string& path,
476 const GURL& redirect_target, 499 const GURL& redirect_target,
477 const net::test_server::HttpRequest& request) { 500 const net::test_server::HttpRequest& request) {
478 if (!StartsWithASCII(path, request.relative_url, true)) 501 if (!StartsWithASCII(path, request.relative_url, true))
479 return scoped_ptr<net::test_server::HttpResponse>(); 502 return scoped_ptr<net::test_server::HttpResponse>();
480 503
481 scoped_ptr<net::test_server::BasicHttpResponse> http_response( 504 scoped_ptr<net::test_server::BasicHttpResponse> http_response(
482 new net::test_server::BasicHttpResponse); 505 new net::test_server::BasicHttpResponse);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 LOG(ERROR) << "FAILED TO START TEST SERVER."; 553 LOG(ERROR) << "FAILED TO START TEST SERVER.";
531 return; 554 return;
532 } 555 }
533 embedded_test_server()->RegisterRequestHandler( 556 embedded_test_server()->RegisterRequestHandler(
534 base::Bind(&WebViewTest::RedirectResponseHandler, 557 base::Bind(&WebViewTest::RedirectResponseHandler,
535 kRedirectResponsePath, 558 kRedirectResponsePath,
536 embedded_test_server()->GetURL(kRedirectResponseFullPath))); 559 embedded_test_server()->GetURL(kRedirectResponseFullPath)));
537 560
538 embedded_test_server()->RegisterRequestHandler( 561 embedded_test_server()->RegisterRequestHandler(
539 base::Bind(&WebViewTest::EmptyResponseHandler, kEmptyResponsePath)); 562 base::Bind(&WebViewTest::EmptyResponseHandler, kEmptyResponsePath));
563
564 embedded_test_server()->RegisterRequestHandler(
565 base::Bind(
566 &WebViewTest::UserAgentResponseHandler,
567 kUserAgentRedirectResponsePath,
568 embedded_test_server()->GetURL(kRedirectResponseFullPath)));
540 } 569 }
541 570
542 LoadAndLaunchPlatformApp(app_location.c_str(), "Launched"); 571 LoadAndLaunchPlatformApp(app_location.c_str(), "Launched");
543 572
544 // Flush any pending events to make sure we start with a clean slate. 573 // Flush any pending events to make sure we start with a clean slate.
545 content::RunAllPendingInMessageLoop(); 574 content::RunAllPendingInMessageLoop();
546 575
547 content::WebContents* embedder_web_contents = 576 content::WebContents* embedder_web_contents =
548 GetFirstAppWindowWebContents(); 577 GetFirstAppWindowWebContents();
549 if (!embedder_web_contents) { 578 if (!embedder_web_contents) {
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 Shim_TestDeclarativeWebRequestAPISendMessage) { 1050 Shim_TestDeclarativeWebRequestAPISendMessage) {
1022 TestHelper("testDeclarativeWebRequestAPISendMessage", 1051 TestHelper("testDeclarativeWebRequestAPISendMessage",
1023 "web_view/shim", 1052 "web_view/shim",
1024 NEEDS_TEST_SERVER); 1053 NEEDS_TEST_SERVER);
1025 } 1054 }
1026 1055
1027 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestWebRequestAPI) { 1056 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestWebRequestAPI) {
1028 TestHelper("testWebRequestAPI", "web_view/shim", NEEDS_TEST_SERVER); 1057 TestHelper("testWebRequestAPI", "web_view/shim", NEEDS_TEST_SERVER);
1029 } 1058 }
1030 1059
1060 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestWebRequestAPIWithHeaders) {
1061 TestHelper("testWebRequestAPIWithHeaders",
1062 "web_view/shim",
1063 NEEDS_TEST_SERVER);
1064 }
1065
1031 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestWebRequestAPIGoogleProperty) { 1066 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestWebRequestAPIGoogleProperty) {
1032 TestHelper("testWebRequestAPIGoogleProperty", 1067 TestHelper("testWebRequestAPIGoogleProperty",
1033 "web_view/shim", 1068 "web_view/shim",
1034 NO_TEST_SERVER); 1069 NO_TEST_SERVER);
1035 } 1070 }
1036 1071
1037 // This test is disabled due to being flaky. http://crbug.com/309451 1072 // This test is disabled due to being flaky. http://crbug.com/309451
1038 #if defined(OS_WIN) 1073 #if defined(OS_WIN)
1039 #define MAYBE_Shim_TestWebRequestListenerSurvivesReparenting \ 1074 #define MAYBE_Shim_TestWebRequestListenerSurvivesReparenting \
1040 DISABLED_Shim_TestWebRequestListenerSurvivesReparenting 1075 DISABLED_Shim_TestWebRequestListenerSurvivesReparenting
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 // http://crbug.com/403325 2307 // http://crbug.com/403325
2273 #define MAYBE_WebViewInBackgroundPage \ 2308 #define MAYBE_WebViewInBackgroundPage \
2274 DISABLED_WebViewInBackgroundPage 2309 DISABLED_WebViewInBackgroundPage
2275 #else 2310 #else
2276 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage 2311 #define MAYBE_WebViewInBackgroundPage WebViewInBackgroundPage
2277 #endif 2312 #endif
2278 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) { 2313 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_WebViewInBackgroundPage) {
2279 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background")) 2314 ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background"))
2280 << message_; 2315 << message_;
2281 } 2316 }
OLDNEW
« 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