OLD | NEW |
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/process/process.h" | 6 #include "base/process/process.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/apps/app_browsertest_util.h" | 10 #include "chrome/browser/apps/app_browsertest_util.h" |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 *persistent_partition_contents3 = source7->GetWebContents(); | 533 *persistent_partition_contents3 = source7->GetWebContents(); |
534 } | 534 } |
535 } | 535 } |
536 | 536 |
537 // Handles |request| by serving a redirect response if the |User-Agent| is | 537 // Handles |request| by serving a redirect response if the |User-Agent| is |
538 // foobar. | 538 // foobar. |
539 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( | 539 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( |
540 const std::string& path, | 540 const std::string& path, |
541 const GURL& redirect_target, | 541 const GURL& redirect_target, |
542 const net::test_server::HttpRequest& request) { | 542 const net::test_server::HttpRequest& request) { |
543 if (!StartsWithASCII(path, request.relative_url, true)) | 543 if (!base::StartsWithASCII(path, request.relative_url, true)) |
544 return scoped_ptr<net::test_server::HttpResponse>(); | 544 return scoped_ptr<net::test_server::HttpResponse>(); |
545 | 545 |
546 std::map<std::string, std::string>::const_iterator it = | 546 std::map<std::string, std::string>::const_iterator it = |
547 request.headers.find("User-Agent"); | 547 request.headers.find("User-Agent"); |
548 EXPECT_TRUE(it != request.headers.end()); | 548 EXPECT_TRUE(it != request.headers.end()); |
549 if (!StartsWithASCII("foobar", it->second, true)) | 549 if (!base::StartsWithASCII("foobar", it->second, true)) |
550 return scoped_ptr<net::test_server::HttpResponse>(); | 550 return scoped_ptr<net::test_server::HttpResponse>(); |
551 | 551 |
552 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 552 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
553 new net::test_server::BasicHttpResponse); | 553 new net::test_server::BasicHttpResponse); |
554 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 554 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
555 http_response->AddCustomHeader("Location", redirect_target.spec()); | 555 http_response->AddCustomHeader("Location", redirect_target.spec()); |
556 return http_response.Pass(); | 556 return http_response.Pass(); |
557 } | 557 } |
558 | 558 |
559 // Handles |request| by serving a redirect response. | 559 // Handles |request| by serving a redirect response. |
560 static scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler( | 560 static scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler( |
561 const std::string& path, | 561 const std::string& path, |
562 const GURL& redirect_target, | 562 const GURL& redirect_target, |
563 const net::test_server::HttpRequest& request) { | 563 const net::test_server::HttpRequest& request) { |
564 if (!StartsWithASCII(path, request.relative_url, true)) | 564 if (!base::StartsWithASCII(path, request.relative_url, true)) |
565 return scoped_ptr<net::test_server::HttpResponse>(); | 565 return scoped_ptr<net::test_server::HttpResponse>(); |
566 | 566 |
567 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 567 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
568 new net::test_server::BasicHttpResponse); | 568 new net::test_server::BasicHttpResponse); |
569 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 569 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
570 http_response->AddCustomHeader("Location", redirect_target.spec()); | 570 http_response->AddCustomHeader("Location", redirect_target.spec()); |
571 return http_response.Pass(); | 571 return http_response.Pass(); |
572 } | 572 } |
573 | 573 |
574 // Handles |request| by serving an empty response. | 574 // Handles |request| by serving an empty response. |
575 static scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( | 575 static scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( |
576 const std::string& path, | 576 const std::string& path, |
577 const net::test_server::HttpRequest& request) { | 577 const net::test_server::HttpRequest& request) { |
578 if (StartsWithASCII(path, request.relative_url, true)) | 578 if (base::StartsWithASCII(path, request.relative_url, true)) |
579 return scoped_ptr<net::test_server::HttpResponse>(new EmptyHttpResponse); | 579 return scoped_ptr<net::test_server::HttpResponse>(new EmptyHttpResponse); |
580 | 580 |
581 return scoped_ptr<net::test_server::HttpResponse>(); | 581 return scoped_ptr<net::test_server::HttpResponse>(); |
582 } | 582 } |
583 | 583 |
584 // Handles |request| by serving cache-able response. | 584 // Handles |request| by serving cache-able response. |
585 static scoped_ptr<net::test_server::HttpResponse> CacheControlResponseHandler( | 585 static scoped_ptr<net::test_server::HttpResponse> CacheControlResponseHandler( |
586 const std::string& path, | 586 const std::string& path, |
587 const net::test_server::HttpRequest& request) { | 587 const net::test_server::HttpRequest& request) { |
588 if (!StartsWithASCII(path, request.relative_url, true)) | 588 if (!base::StartsWithASCII(path, request.relative_url, true)) |
589 return scoped_ptr<net::test_server::HttpResponse>(); | 589 return scoped_ptr<net::test_server::HttpResponse>(); |
590 | 590 |
591 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 591 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
592 new net::test_server::BasicHttpResponse); | 592 new net::test_server::BasicHttpResponse); |
593 http_response->AddCustomHeader("Cache-control", "max-age=3600"); | 593 http_response->AddCustomHeader("Cache-control", "max-age=3600"); |
594 http_response->set_content_type("text/plain"); | 594 http_response->set_content_type("text/plain"); |
595 http_response->set_content("dummy text"); | 595 http_response->set_content("dummy text"); |
596 return http_response.Pass(); | 596 return http_response.Pass(); |
597 } | 597 } |
598 | 598 |
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. | 2626 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
2627 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/post_message/basic")) | 2627 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/post_message/basic")) |
2628 << message_; | 2628 << message_; |
2629 } | 2629 } |
2630 | 2630 |
2631 // Tests that webviews do get garbage collected. | 2631 // Tests that webviews do get garbage collected. |
2632 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestGarbageCollect) { | 2632 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestGarbageCollect) { |
2633 TestHelper("testGarbageCollect", "web_view/shim", NO_TEST_SERVER); | 2633 TestHelper("testGarbageCollect", "web_view/shim", NO_TEST_SERVER); |
2634 GetGuestViewManager()->WaitForSingleViewGarbageCollected(); | 2634 GetGuestViewManager()->WaitForSingleViewGarbageCollected(); |
2635 } | 2635 } |
OLD | NEW |