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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 public: | 52 public: |
53 std::string ToResponseString() const override { return std::string(); } | 53 std::string ToResponseString() const override { return std::string(); } |
54 }; | 54 }; |
55 | 55 |
56 // 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 |
57 // foobar. | 57 // foobar. |
58 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( | 58 static scoped_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( |
59 const std::string& path, | 59 const std::string& path, |
60 const GURL& redirect_target, | 60 const GURL& redirect_target, |
61 const net::test_server::HttpRequest& request) { | 61 const net::test_server::HttpRequest& request) { |
62 if (!base::StartsWithASCII(path, request.relative_url, true)) | 62 if (!base::StartsWith(path, request.relative_url, |
| 63 base::CompareCase::SENSITIVE)) |
63 return scoped_ptr<net::test_server::HttpResponse>(); | 64 return scoped_ptr<net::test_server::HttpResponse>(); |
64 | 65 |
65 std::map<std::string, std::string>::const_iterator it = | 66 std::map<std::string, std::string>::const_iterator it = |
66 request.headers.find("User-Agent"); | 67 request.headers.find("User-Agent"); |
67 EXPECT_TRUE(it != request.headers.end()); | 68 EXPECT_TRUE(it != request.headers.end()); |
68 if (!base::StartsWithASCII("foobar", it->second, true)) | 69 if (!base::StartsWith("foobar", it->second, base::CompareCase::SENSITIVE)) |
69 return scoped_ptr<net::test_server::HttpResponse>(); | 70 return scoped_ptr<net::test_server::HttpResponse>(); |
70 | 71 |
71 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 72 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
72 new net::test_server::BasicHttpResponse); | 73 new net::test_server::BasicHttpResponse); |
73 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 74 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
74 http_response->AddCustomHeader("Location", redirect_target.spec()); | 75 http_response->AddCustomHeader("Location", redirect_target.spec()); |
75 return http_response.Pass(); | 76 return http_response.Pass(); |
76 } | 77 } |
77 | 78 |
78 class WebContentsHiddenObserver : public content::WebContentsObserver { | 79 class WebContentsHiddenObserver : public content::WebContentsObserver { |
(...skipping 18 matching lines...) Expand all Loading... |
97 bool hidden_observed_; | 98 bool hidden_observed_; |
98 | 99 |
99 DISALLOW_COPY_AND_ASSIGN(WebContentsHiddenObserver); | 100 DISALLOW_COPY_AND_ASSIGN(WebContentsHiddenObserver); |
100 }; | 101 }; |
101 | 102 |
102 // Handles |request| by serving a redirect response. | 103 // Handles |request| by serving a redirect response. |
103 scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler( | 104 scoped_ptr<net::test_server::HttpResponse> RedirectResponseHandler( |
104 const std::string& path, | 105 const std::string& path, |
105 const GURL& redirect_target, | 106 const GURL& redirect_target, |
106 const net::test_server::HttpRequest& request) { | 107 const net::test_server::HttpRequest& request) { |
107 if (!base::StartsWithASCII(path, request.relative_url, true)) | 108 if (!base::StartsWith(path, request.relative_url, |
| 109 base::CompareCase::SENSITIVE)) |
108 return scoped_ptr<net::test_server::HttpResponse>(); | 110 return scoped_ptr<net::test_server::HttpResponse>(); |
109 | 111 |
110 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 112 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
111 new net::test_server::BasicHttpResponse); | 113 new net::test_server::BasicHttpResponse); |
112 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 114 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
113 http_response->AddCustomHeader("Location", redirect_target.spec()); | 115 http_response->AddCustomHeader("Location", redirect_target.spec()); |
114 return http_response.Pass(); | 116 return http_response.Pass(); |
115 } | 117 } |
116 | 118 |
117 // Handles |request| by serving an empty response. | 119 // Handles |request| by serving an empty response. |
118 scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( | 120 scoped_ptr<net::test_server::HttpResponse> EmptyResponseHandler( |
119 const std::string& path, | 121 const std::string& path, |
120 const net::test_server::HttpRequest& request) { | 122 const net::test_server::HttpRequest& request) { |
121 if (base::StartsWithASCII(path, request.relative_url, true)) { | 123 if (base::StartsWith(path, request.relative_url, |
| 124 base::CompareCase::SENSITIVE)) { |
122 return scoped_ptr<net::test_server::HttpResponse>(new EmptyHttpResponse); | 125 return scoped_ptr<net::test_server::HttpResponse>(new EmptyHttpResponse); |
123 } | 126 } |
124 | 127 |
125 return scoped_ptr<net::test_server::HttpResponse>(); | 128 return scoped_ptr<net::test_server::HttpResponse>(); |
126 } | 129 } |
127 | 130 |
128 } // namespace | 131 } // namespace |
129 | 132 |
130 namespace extensions { | 133 namespace extensions { |
131 | 134 |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest"); | 729 RunTest("testWebRequestAPIGoogleProperty", "web_view/apitest"); |
727 } | 730 } |
728 | 731 |
729 // This test verifies that webview.contentWindow works inside an iframe | 732 // This test verifies that webview.contentWindow works inside an iframe |
730 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { | 733 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { |
731 LaunchApp("web_view/inside_iframe"); | 734 LaunchApp("web_view/inside_iframe"); |
732 } | 735 } |
733 | 736 |
734 | 737 |
735 } // namespace extensions | 738 } // namespace extensions |
OLD | NEW |