| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/guest_view/web_view/web_view_apitest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_apitest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 const char kEmptyResponsePath[] = "/close-socket"; | 42 const char kEmptyResponsePath[] = "/close-socket"; |
| 43 const char kRedirectResponsePath[] = "/server-redirect"; | 43 const char kRedirectResponsePath[] = "/server-redirect"; |
| 44 const char kRedirectResponseFullPath[] = "/guest_redirect.html"; | 44 const char kRedirectResponseFullPath[] = "/guest_redirect.html"; |
| 45 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent"; | 45 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent"; |
| 46 const char kTestDataDirectory[] = "testDataDirectory"; | 46 const char kTestDataDirectory[] = "testDataDirectory"; |
| 47 const char kTestServerPort[] = "testServer.port"; | 47 const char kTestServerPort[] = "testServer.port"; |
| 48 const char kTestWebSocketPort[] = "testWebSocketPort"; | 48 const char kTestWebSocketPort[] = "testWebSocketPort"; |
| 49 const char kSitePerProcess[] = "sitePerProcess"; | 49 const char kSitePerProcess[] = "sitePerProcess"; |
| 50 | 50 |
| 51 class EmptyHttpResponse : public net::test_server::HttpResponse { | |
| 52 public: | |
| 53 std::string ToResponseString() const override { return std::string(); } | |
| 54 }; | |
| 55 | |
| 56 // Handles |request| by serving a redirect response if the |User-Agent| is | 51 // Handles |request| by serving a redirect response if the |User-Agent| is |
| 57 // foobar. | 52 // foobar. |
| 58 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( | 53 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( |
| 59 const std::string& path, | 54 const std::string& path, |
| 60 const GURL& redirect_target, | 55 const GURL& redirect_target, |
| 61 const net::test_server::HttpRequest& request) { | 56 const net::test_server::HttpRequest& request) { |
| 62 if (!base::StartsWith(path, request.relative_url, | 57 if (!base::StartsWith(path, request.relative_url, |
| 63 base::CompareCase::SENSITIVE)) | 58 base::CompareCase::SENSITIVE)) |
| 64 return scoped_ptr<net::test_server::HttpResponse>(); | 59 return scoped_ptr<net::test_server::HttpResponse>(); |
| 65 | 60 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 http_response->AddCustomHeader("Location", redirect_target.spec()); | 110 http_response->AddCustomHeader("Location", redirect_target.spec()); |
| 116 return http_response.Pass(); | 111 return http_response.Pass(); |
| 117 } | 112 } |
| 118 | 113 |
| 119 // Handles |request| by serving an empty response. | 114 // Handles |request| by serving an empty response. |
| 120 scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( | 115 scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( |
| 121 const std::string& path, | 116 const std::string& path, |
| 122 const net::test_server::HttpRequest& request) { | 117 const net::test_server::HttpRequest& request) { |
| 123 if (base::StartsWith(path, request.relative_url, | 118 if (base::StartsWith(path, request.relative_url, |
| 124 base::CompareCase::SENSITIVE)) { | 119 base::CompareCase::SENSITIVE)) { |
| 125 return scoped_ptr<net::test_server::HttpResponse>(new EmptyHttpResponse); | 120 return scoped_ptr<net::test_server::HttpResponse>( |
| 121 new net::test_server::RawHttpResponse("", "")); |
| 126 } | 122 } |
| 127 | 123 |
| 128 return scoped_ptr<net::test_server::HttpResponse>(); | 124 return scoped_ptr<net::test_server::HttpResponse>(); |
| 129 } | 125 } |
| 130 | 126 |
| 131 } // namespace | 127 } // namespace |
| 132 | 128 |
| 133 namespace extensions { | 129 namespace extensions { |
| 134 | 130 |
| 135 WebViewAPITest::WebViewAPITest() { | 131 WebViewAPITest::WebViewAPITest() { |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest"); | 725 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest"); |
| 730 } | 726 } |
| 731 | 727 |
| 732 // This test verifies that webview.contentWindow works inside an iframe | 728 // This test verifies that webview.contentWindow works inside an iframe |
| 733 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { | 729 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { |
| 734 LaunchApp("web_view/inside_iframe"); | 730 LaunchApp("web_view/inside_iframe"); |
| 735 } | 731 } |
| 736 | 732 |
| 737 | 733 |
| 738 } // namespace extensions | 734 } // namespace extensions |
| OLD | NEW |