| 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 |
| 51 // Handles |request| by serving a redirect response if the |User-Agent| is | 56 // Handles |request| by serving a redirect response if the |User-Agent| is |
| 52 // foobar. | 57 // foobar. |
| 53 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( | 58 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( |
| 54 const std::string& path, | 59 const std::string& path, |
| 55 const GURL& redirect_target, | 60 const GURL& redirect_target, |
| 56 const net::test_server::HttpRequest& request) { | 61 const net::test_server::HttpRequest& request) { |
| 57 if (!base::StartsWith(path, request.relative_url, | 62 if (!base::StartsWith(path, request.relative_url, |
| 58 base::CompareCase::SENSITIVE)) | 63 base::CompareCase::SENSITIVE)) |
| 59 return scoped_ptr<net::test_server::HttpResponse>(); | 64 return scoped_ptr<net::test_server::HttpResponse>(); |
| 60 | 65 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 http_response->AddCustomHeader("Location", redirect_target.spec()); | 115 http_response->AddCustomHeader("Location", redirect_target.spec()); |
| 111 return http_response.Pass(); | 116 return http_response.Pass(); |
| 112 } | 117 } |
| 113 | 118 |
| 114 // Handles |request| by serving an empty response. | 119 // Handles |request| by serving an empty response. |
| 115 scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( | 120 scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( |
| 116 const std::string& path, | 121 const std::string& path, |
| 117 const net::test_server::HttpRequest& request) { | 122 const net::test_server::HttpRequest& request) { |
| 118 if (base::StartsWith(path, request.relative_url, | 123 if (base::StartsWith(path, request.relative_url, |
| 119 base::CompareCase::SENSITIVE)) { | 124 base::CompareCase::SENSITIVE)) { |
| 120 return scoped_ptr<net::test_server::HttpResponse>( | 125 return scoped_ptr<net::test_server::HttpResponse>(new EmptyHttpResponse); |
| 121 new net::test_server::RawHttpResponse("", "")); | |
| 122 } | 126 } |
| 123 | 127 |
| 124 return scoped_ptr<net::test_server::HttpResponse>(); | 128 return scoped_ptr<net::test_server::HttpResponse>(); |
| 125 } | 129 } |
| 126 | 130 |
| 127 } // namespace | 131 } // namespace |
| 128 | 132 |
| 129 namespace extensions { | 133 namespace extensions { |
| 130 | 134 |
| 131 WebViewAPITest::WebViewAPITest() { | 135 WebViewAPITest::WebViewAPITest() { |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest"); | 729 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest"); |
| 726 } | 730 } |
| 727 | 731 |
| 728 // This test verifies that webview.contentWindow works inside an iframe | 732 // This test verifies that webview.contentWindow works inside an iframe |
| 729 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { | 733 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { |
| 730 LaunchApp("web_view/inside_iframe"); | 734 LaunchApp("web_view/inside_iframe"); |
| 731 } | 735 } |
| 732 | 736 |
| 733 | 737 |
| 734 } // namespace extensions | 738 } // namespace extensions |
| OLD | NEW |