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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 const char kEmptyResponsePath[] = "/close-socket"; | 49 const char kEmptyResponsePath[] = "/close-socket"; |
50 const char kRedirectResponsePath[] = "/server-redirect"; | 50 const char kRedirectResponsePath[] = "/server-redirect"; |
51 const char kRedirectResponseFullPath[] = "/guest_redirect.html"; | 51 const char kRedirectResponseFullPath[] = "/guest_redirect.html"; |
52 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent"; | 52 const char kUserAgentRedirectResponsePath[] = "/detect-user-agent"; |
53 const char kTestDataDirectory[] = "testDataDirectory"; | 53 const char kTestDataDirectory[] = "testDataDirectory"; |
54 const char kTestServerPort[] = "testServer.port"; | 54 const char kTestServerPort[] = "testServer.port"; |
55 const char kTestWebSocketPort[] = "testWebSocketPort"; | 55 const char kTestWebSocketPort[] = "testWebSocketPort"; |
56 const char kIsolateExtensions[] = "isolateExtensions"; | |
57 | 56 |
58 // Handles |request| by serving a redirect response if the |User-Agent| is | 57 // Handles |request| by serving a redirect response if the |User-Agent| is |
59 // foobar. | 58 // foobar. |
60 static std::unique_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( | 59 static std::unique_ptr<net::test_server::HttpResponse> UserAgentResponseHandler( |
61 const std::string& path, | 60 const std::string& path, |
62 const GURL& redirect_target, | 61 const GURL& redirect_target, |
63 const net::test_server::HttpRequest& request) { | 62 const net::test_server::HttpRequest& request) { |
64 if (!base::StartsWith(path, request.relative_url, | 63 if (!base::StartsWith(path, request.relative_url, |
65 base::CompareCase::SENSITIVE)) | 64 base::CompareCase::SENSITIVE)) |
66 return std::unique_ptr<net::test_server::HttpResponse>(); | 65 return std::unique_ptr<net::test_server::HttpResponse>(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 AppShellTest::SetUpCommandLine(command_line); | 181 AppShellTest::SetUpCommandLine(command_line); |
183 command_line->AppendSwitchASCII(::switches::kJavaScriptFlags, "--expose-gc"); | 182 command_line->AppendSwitchASCII(::switches::kJavaScriptFlags, "--expose-gc"); |
184 } | 183 } |
185 | 184 |
186 void WebViewAPITest::SetUpOnMainThread() { | 185 void WebViewAPITest::SetUpOnMainThread() { |
187 AppShellTest::SetUpOnMainThread(); | 186 AppShellTest::SetUpOnMainThread(); |
188 | 187 |
189 TestGetConfigFunction::set_test_config_state(&test_config_); | 188 TestGetConfigFunction::set_test_config_state(&test_config_); |
190 base::FilePath test_data_dir; | 189 base::FilePath test_data_dir; |
191 test_config_.SetInteger(kTestWebSocketPort, 0); | 190 test_config_.SetInteger(kTestWebSocketPort, 0); |
192 bool isolate_extensions = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
193 ::switches::kSitePerProcess) || | |
194 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
195 extensions::switches::kIsolateExtensions); | |
196 test_config_.SetBoolean(kIsolateExtensions, isolate_extensions); | |
197 } | 191 } |
198 | 192 |
199 void WebViewAPITest::StartTestServer(const std::string& app_location) { | 193 void WebViewAPITest::StartTestServer(const std::string& app_location) { |
200 // For serving guest pages. | 194 // For serving guest pages. |
201 if (!embedded_test_server()->InitializeAndListen()) { | 195 if (!embedded_test_server()->InitializeAndListen()) { |
202 LOG(ERROR) << "Failed to start test server."; | 196 LOG(ERROR) << "Failed to start test server."; |
203 return; | 197 return; |
204 } | 198 } |
205 | 199 |
206 test_config_.SetInteger(kTestServerPort, embedded_test_server()->port()); | 200 test_config_.SetInteger(kTestServerPort, embedded_test_server()->port()); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 // This test verifies that webview.contentWindow works inside an iframe | 760 // This test verifies that webview.contentWindow works inside an iframe |
767 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { | 761 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { |
768 LaunchApp("web_view/inside_iframe"); | 762 LaunchApp("web_view/inside_iframe"); |
769 } | 763 } |
770 | 764 |
771 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCaptureVisibleRegion) { | 765 IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCaptureVisibleRegion) { |
772 RunTest("testCaptureVisibleRegion", "web_view/apitest"); | 766 RunTest("testCaptureVisibleRegion", "web_view/apitest"); |
773 } | 767 } |
774 | 768 |
775 } // namespace extensions | 769 } // namespace extensions |
OLD | NEW |