| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome_frame/test/test_with_web_server.h" | 5 #include "chrome_frame/test/test_with_web_server.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // Helper method for creating the appropriate HTTP response headers. | 37 // Helper method for creating the appropriate HTTP response headers. |
| 38 std::string CreateHttpHeaders(CFInvocation invocation, | 38 std::string CreateHttpHeaders(CFInvocation invocation, |
| 39 bool add_no_cache_header, | 39 bool add_no_cache_header, |
| 40 const std::string& content_type) { | 40 const std::string& content_type) { |
| 41 std::ostringstream ss; | 41 std::ostringstream ss; |
| 42 ss << "HTTP/1.1 200 OK\r\n" | 42 ss << "HTTP/1.1 200 OK\r\n" |
| 43 << "Connection: close\r\n" | 43 << "Connection: close\r\n" |
| 44 << "Content-Type: " << content_type << "\r\n"; | 44 << "Content-Type: " << content_type << "\r\n"; |
| 45 if (invocation.type() == CFInvocation::HTTP_HEADER) | 45 if (invocation.type() == CFInvocation::HTTP_HEADER) |
| 46 ss << "X-UA-Compatible: chrome=1\r\n"; | 46 ss << "X-UA-Compatible: chrome=1\r\n"; |
| 47 if (add_no_cache_header) | 47 if (add_no_cache_header) { |
| 48 ss << "Cache-Control: no-cache\r\n"; | 48 ss << "Cache-Control: no-cache\r\n"; |
| 49 ss << "Expires: Tue, 15 Nov 1994 08:12:31 GMT\r\n"; |
| 50 } |
| 49 return ss.str(); | 51 return ss.str(); |
| 50 } | 52 } |
| 51 | 53 |
| 52 std::string GetMockHttpHeaders(const FilePath& mock_http_headers_path) { | 54 std::string GetMockHttpHeaders(const FilePath& mock_http_headers_path) { |
| 53 std::string headers; | 55 std::string headers; |
| 54 file_util::ReadFileToString(mock_http_headers_path, &headers); | 56 file_util::ReadFileToString(mock_http_headers_path, &headers); |
| 55 return headers; | 57 return headers; |
| 56 } | 58 } |
| 57 | 59 |
| 58 class ChromeFrameTestEnvironment: public testing::Environment { | 60 class ChromeFrameTestEnvironment: public testing::Environment { |
| 59 public: | 61 public: |
| 60 virtual ~ChromeFrameTestEnvironment() {} | 62 virtual ~ChromeFrameTestEnvironment() {} |
| 61 virtual void SetUp() OVERRIDE { | 63 virtual void SetUp() OVERRIDE { |
| 62 ScopedChromeFrameRegistrar::RegisterDefaults(); | 64 ScopedChromeFrameRegistrar::RegisterDefaults(); |
| 63 } | 65 } |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 ::testing::Environment* const chrome_frame_env = | 68 ::testing::Environment* const chrome_frame_env = |
| 67 ::testing::AddGlobalTestEnvironment(new ChromeFrameTestEnvironment); | 69 ::testing::AddGlobalTestEnvironment(new ChromeFrameTestEnvironment); |
| 68 | 70 |
| 69 } // namespace | 71 } // namespace |
| 70 | 72 |
| 71 FilePath ChromeFrameTestWithWebServer::test_file_path_; | 73 FilePath ChromeFrameTestWithWebServer::test_file_path_; |
| 72 FilePath ChromeFrameTestWithWebServer::results_dir_; | 74 FilePath ChromeFrameTestWithWebServer::results_dir_; |
| 73 FilePath ChromeFrameTestWithWebServer::CFInstall_path_; | 75 FilePath ChromeFrameTestWithWebServer::CFInstall_path_; |
| 74 FilePath ChromeFrameTestWithWebServer::CFInstance_path_; | 76 FilePath ChromeFrameTestWithWebServer::CFInstance_path_; |
| 75 ScopedTempDir ChromeFrameTestWithWebServer::temp_dir_; | 77 ScopedTempDir ChromeFrameTestWithWebServer::temp_dir_; |
| 76 FilePath ChromeFrameTestWithWebServer::chrome_user_data_dir_; | 78 FilePath ChromeFrameTestWithWebServer::chrome_user_data_dir_; |
| 79 chrome_frame_test::TimedMsgLoop* ChromeFrameTestWithWebServer::loop_; |
| 80 testing::StrictMock<MockWebServer>* ChromeFrameTestWithWebServer::server_mock_; |
| 77 | 81 |
| 78 ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() | 82 ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() { |
| 79 : loop_(), | |
| 80 server_mock_(1337, L"127.0.0.1", | |
| 81 chrome_frame_test::GetTestDataFolder()) { | |
| 82 } | 83 } |
| 83 | 84 |
| 84 // static | 85 // static |
| 85 void ChromeFrameTestWithWebServer::SetUpTestCase() { | 86 void ChromeFrameTestWithWebServer::SetUpTestCase() { |
| 86 FilePath chrome_frame_source_path; | 87 FilePath chrome_frame_source_path; |
| 87 PathService::Get(base::DIR_SOURCE_ROOT, &chrome_frame_source_path); | 88 PathService::Get(base::DIR_SOURCE_ROOT, &chrome_frame_source_path); |
| 88 chrome_frame_source_path = chrome_frame_source_path.Append( | 89 chrome_frame_source_path = chrome_frame_source_path.Append( |
| 89 FILE_PATH_LITERAL("chrome_frame")); | 90 FILE_PATH_LITERAL("chrome_frame")); |
| 90 | 91 |
| 91 test_file_path_ = chrome_frame_source_path | 92 test_file_path_ = chrome_frame_source_path |
| 92 .Append(FILE_PATH_LITERAL("test")) | 93 .Append(FILE_PATH_LITERAL("test")) |
| 93 .Append(FILE_PATH_LITERAL("data")); | 94 .Append(FILE_PATH_LITERAL("data")); |
| 94 | 95 |
| 95 results_dir_ = chrome_frame_test::GetTestDataFolder().AppendASCII("dump"); | 96 results_dir_ = chrome_frame_test::GetTestDataFolder().AppendASCII("dump"); |
| 96 | 97 |
| 97 // Copy the CFInstance.js and CFInstall.js files from src\chrome_frame to | 98 // Copy the CFInstance.js and CFInstall.js files from src\chrome_frame to |
| 98 // src\chrome_frame\test\data. | 99 // src\chrome_frame\test\data. |
| 99 FilePath CFInstance_src_path; | 100 FilePath CFInstance_src_path; |
| 100 FilePath CFInstall_src_path; | 101 FilePath CFInstall_src_path; |
| 101 | 102 |
| 102 CFInstance_src_path = chrome_frame_source_path.AppendASCII("CFInstance.js"); | 103 CFInstance_src_path = chrome_frame_source_path.AppendASCII("CFInstance.js"); |
| 103 CFInstance_path_ = test_file_path_.AppendASCII("CFInstance.js"); | 104 CFInstance_path_ = test_file_path_.AppendASCII("CFInstance.js"); |
| 104 | 105 |
| 105 ASSERT_TRUE(file_util::CopyFile(CFInstance_src_path, CFInstance_path_)); | 106 ASSERT_TRUE(file_util::CopyFile(CFInstance_src_path, CFInstance_path_)); |
| 106 | 107 |
| 107 CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js"); | 108 CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js"); |
| 108 CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js"); | 109 CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js"); |
| 109 | 110 |
| 110 ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_)); | 111 ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_)); |
| 112 |
| 113 loop_ = new chrome_frame_test::TimedMsgLoop(); |
| 114 loop_->set_snapshot_on_timeout(true); |
| 115 server_mock_ = new testing::StrictMock<MockWebServer>( |
| 116 1337, L"127.0.0.1", chrome_frame_test::GetTestDataFolder()); |
| 111 } | 117 } |
| 112 | 118 |
| 113 // static | 119 // static |
| 114 void ChromeFrameTestWithWebServer::TearDownTestCase() { | 120 void ChromeFrameTestWithWebServer::TearDownTestCase() { |
| 121 delete server_mock_; |
| 122 server_mock_ = NULL; |
| 123 delete loop_; |
| 124 loop_ = NULL; |
| 115 file_util::Delete(CFInstall_path_, false); | 125 file_util::Delete(CFInstall_path_, false); |
| 116 file_util::Delete(CFInstance_path_, false); | 126 file_util::Delete(CFInstance_path_, false); |
| 117 EXPECT_TRUE(temp_dir_.Delete()); | 127 if (temp_dir_.IsValid()) |
| 128 EXPECT_TRUE(temp_dir_.Delete()); |
| 118 } | 129 } |
| 119 | 130 |
| 120 // static | 131 // static |
| 121 const FilePath& ChromeFrameTestWithWebServer::GetChromeUserDataDirectory() { | 132 const FilePath& ChromeFrameTestWithWebServer::GetChromeUserDataDirectory() { |
| 122 if (!temp_dir_.IsValid()) { | 133 if (!temp_dir_.IsValid()) { |
| 123 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 134 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 124 chrome_user_data_dir_ = temp_dir_.path().AppendASCII("User Data"); | 135 chrome_user_data_dir_ = temp_dir_.path().AppendASCII("User Data"); |
| 125 } | 136 } |
| 126 return chrome_user_data_dir_; | 137 return chrome_user_data_dir_; |
| 127 } | 138 } |
| 128 | 139 |
| 129 void ChromeFrameTestWithWebServer::SetUp() { | 140 void ChromeFrameTestWithWebServer::SetUp() { |
| 130 // Make sure that we are not accidentally enabling gcf protocol. | 141 // Make sure that we are not accidentally enabling gcf protocol. |
| 131 SetConfigBool(kAllowUnsafeURLs, false); | 142 SetConfigBool(kAllowUnsafeURLs, false); |
| 132 | 143 |
| 133 server_mock_.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); | 144 server_mock().ClearResults(); |
| 134 server_mock_.set_expected_result("OK"); | 145 server_mock().ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); |
| 146 server_mock().set_expected_result("OK"); |
| 135 } | 147 } |
| 136 | 148 |
| 137 void ChromeFrameTestWithWebServer::TearDown() { | 149 void ChromeFrameTestWithWebServer::TearDown() { |
| 138 CloseBrowser(); | 150 CloseBrowser(); |
| 151 loop().RunAllPending(); |
| 152 testing::Mock::VerifyAndClear(server_mock_); |
| 139 } | 153 } |
| 140 | 154 |
| 141 bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser, | 155 bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser, |
| 142 const wchar_t* page) { | 156 const wchar_t* page) { |
| 143 std::wstring url = page; | 157 std::wstring url = page; |
| 144 | 158 |
| 145 // We should resolve the URL only if it is a relative url. | 159 // We should resolve the URL only if it is a relative url. |
| 146 GURL parsed_url(WideToUTF8(page)); | 160 GURL parsed_url(WideToUTF8(page)); |
| 147 if (!parsed_url.has_scheme()) { | 161 if (!parsed_url.has_scheme()) { |
| 148 url = server_mock_.Resolve(page); | 162 url = server_mock().Resolve(page); |
| 149 } | 163 } |
| 150 | 164 |
| 151 browser_ = browser; | 165 browser_ = browser; |
| 152 if (browser == IE) { | 166 if (browser == IE) { |
| 153 browser_handle_.Set(chrome_frame_test::LaunchIE(url)); | 167 browser_handle_.Set(chrome_frame_test::LaunchIE(url)); |
| 154 } else if (browser == CHROME) { | 168 } else if (browser == CHROME) { |
| 155 const FilePath& user_data_dir = GetChromeUserDataDirectory(); | 169 const FilePath& user_data_dir = GetChromeUserDataDirectory(); |
| 156 chrome_frame_test::OverrideDataDirectoryForThisTest(user_data_dir.value()); | 170 chrome_frame_test::OverrideDataDirectoryForThisTest(user_data_dir.value()); |
| 157 browser_handle_.Set(chrome_frame_test::LaunchChrome(url, user_data_dir)); | 171 browser_handle_.Set(chrome_frame_test::LaunchChrome(url, user_data_dir)); |
| 158 } else { | 172 } else { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 browser_handle_.Close(); | 209 browser_handle_.Close(); |
| 196 } | 210 } |
| 197 } | 211 } |
| 198 | 212 |
| 199 bool ChromeFrameTestWithWebServer::BringBrowserToTop() { | 213 bool ChromeFrameTestWithWebServer::BringBrowserToTop() { |
| 200 return simulate_input::EnsureProcessInForeground( | 214 return simulate_input::EnsureProcessInForeground( |
| 201 GetProcessId(browser_handle_)); | 215 GetProcessId(browser_handle_)); |
| 202 } | 216 } |
| 203 | 217 |
| 204 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(int milliseconds) { | 218 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(int milliseconds) { |
| 205 loop_.RunFor(milliseconds/1000); | 219 loop().RunFor(milliseconds/1000); |
| 206 return true; | 220 return true; |
| 207 } | 221 } |
| 208 | 222 |
| 209 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { | 223 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { |
| 210 return false; | 224 return false; |
| 211 } | 225 } |
| 212 | 226 |
| 213 const wchar_t kPostedResultSubstring[] = L"/writefile/"; | 227 const wchar_t kPostedResultSubstring[] = L"/writefile/"; |
| 214 | 228 |
| 215 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( | 229 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( |
| 216 BrowserKind browser, const wchar_t* page, const char* result) { | 230 BrowserKind browser, const wchar_t* page, const char* result) { |
| 217 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), | 231 server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), |
| 218 kPostedResultSubstring); | 232 kPostedResultSubstring); |
| 219 ASSERT_TRUE(LaunchBrowser(browser, page)); | 233 ASSERT_TRUE(LaunchBrowser(browser, page)); |
| 220 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); | 234 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); |
| 221 ASSERT_EQ(result, server_mock_.posted_result()); | 235 ASSERT_EQ(result, server_mock().posted_result()); |
| 222 } | 236 } |
| 223 | 237 |
| 224 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, | 238 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, |
| 225 const wchar_t* page) { | 239 const wchar_t* page) { |
| 226 SimpleBrowserTestExpectedResult(browser, page, "OK"); | 240 SimpleBrowserTestExpectedResult(browser, page, "OK"); |
| 227 } | 241 } |
| 228 | 242 |
| 229 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, | 243 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, |
| 230 const wchar_t* page) { | 244 const wchar_t* page) { |
| 231 FilePath plugin_path; | 245 FilePath plugin_path; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 250 bool system_install = ver_system.get() ? true : false; | 264 bool system_install = ver_system.get() ? true : false; |
| 251 FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist)); | 265 FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist)); |
| 252 cf_dll_path = cf_dll_path.Append(UTF8ToWide( | 266 cf_dll_path = cf_dll_path.Append(UTF8ToWide( |
| 253 ver_system.get() ? ver_system->GetString() : ver_user->GetString())); | 267 ver_system.get() ? ver_system->GetString() : ver_user->GetString())); |
| 254 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); | 268 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); |
| 255 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); | 269 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); |
| 256 if (version_info) | 270 if (version_info) |
| 257 version = version_info->product_version(); | 271 version = version_info->product_version(); |
| 258 } | 272 } |
| 259 | 273 |
| 260 server_mock_.set_expected_result(WideToUTF8(version)); | 274 server_mock().set_expected_result(WideToUTF8(version)); |
| 261 | 275 |
| 262 EXPECT_TRUE(version_info); | 276 EXPECT_TRUE(version_info); |
| 263 EXPECT_FALSE(version.empty()); | 277 EXPECT_FALSE(version.empty()); |
| 264 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), | 278 server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), |
| 265 kPostedResultSubstring); | 279 kPostedResultSubstring); |
| 266 EXPECT_TRUE(LaunchBrowser(browser, page)); | 280 EXPECT_TRUE(LaunchBrowser(browser, page)); |
| 267 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); | 281 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); |
| 268 ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result())); | 282 ASSERT_EQ(version, UTF8ToWide(server_mock().posted_result())); |
| 269 } | 283 } |
| 270 | 284 |
| 271 // MockWebServer methods | 285 // MockWebServer methods |
| 272 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, | 286 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, |
| 273 const std::wstring& url) { | 287 const std::wstring& url) { |
| 274 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1)); | 288 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1)); |
| 275 } | 289 } |
| 276 | 290 |
| 277 void MockWebServer::ExpectAndServeRequestWithCardinality( | 291 void MockWebServer::ExpectAndServeRequestWithCardinality( |
| 278 CFInvocation invocation, const std::wstring& url, | 292 CFInvocation invocation, const std::wstring& url, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 432 } |
| 419 | 433 |
| 420 const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html"; | 434 const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html"; |
| 421 | 435 |
| 422 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) { | 436 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) { |
| 423 SimpleBrowserTest(IE, kiframeBasicPage); | 437 SimpleBrowserTest(IE, kiframeBasicPage); |
| 424 } | 438 } |
| 425 | 439 |
| 426 const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html"; | 440 const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html"; |
| 427 | 441 |
| 428 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_SrcProperty) { | 442 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_SrcProperty) { |
| 429 SimpleBrowserTest(IE, kSrcPropertyTestPage); | 443 SimpleBrowserTest(IE, kSrcPropertyTestPage); |
| 430 } | 444 } |
| 431 | 445 |
| 432 const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html"; | 446 const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html"; |
| 433 | 447 |
| 434 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) { | 448 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) { |
| 435 SimpleBrowserTest(IE, kCFInstanceBasicTestPage); | 449 SimpleBrowserTest(IE, kCFInstanceBasicTestPage); |
| 436 } | 450 } |
| 437 | 451 |
| 438 const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html"; | 452 const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html"; |
| 439 | 453 |
| 440 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) { | 454 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) { |
| 441 SimpleBrowserTest(IE, kCFISingletonPage); | 455 SimpleBrowserTest(IE, kCFISingletonPage); |
| 442 } | 456 } |
| 443 | 457 |
| 444 const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html"; | 458 const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html"; |
| 445 | 459 |
| 446 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceDelay) { | 460 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDelay) { |
| 447 SimpleBrowserTest(IE, kCFIDelayPage); | 461 SimpleBrowserTest(IE, kCFIDelayPage); |
| 448 } | 462 } |
| 449 | 463 |
| 450 const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html"; | 464 const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html"; |
| 451 | 465 |
| 452 // http://crbug.com/37088 | 466 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceFallback) { |
| 453 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceFallback) { | |
| 454 SimpleBrowserTest(IE, kCFIFallbackPage); | 467 SimpleBrowserTest(IE, kCFIFallbackPage); |
| 455 } | 468 } |
| 456 | 469 |
| 457 const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html"; | 470 const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html"; |
| 458 | 471 |
| 459 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceNoSrc) { | 472 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceNoSrc) { |
| 460 SimpleBrowserTest(IE, kCFINoSrcPage); | 473 SimpleBrowserTest(IE, kCFINoSrcPage); |
| 461 } | 474 } |
| 462 | 475 |
| 463 const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html"; | 476 const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html"; |
| 464 | 477 |
| 465 // disabled since it's unlikely that we care about this case | 478 // disabled since it's unlikely that we care about this case |
| 466 TEST_F(ChromeFrameTestWithWebServer, | 479 TEST_F(ChromeFrameTestWithWebServer, |
| 467 DISABLED_WidgetModeIE_CFInstanceIfrOnLoad) { | 480 DISABLED_WidgetModeIE_CFInstanceIfrOnLoad) { |
| 468 SimpleBrowserTest(IE, kCFIIfrOnLoadPage); | 481 SimpleBrowserTest(IE, kCFIIfrOnLoadPage); |
| 469 } | 482 } |
| 470 | 483 |
| 471 const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html"; | 484 const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html"; |
| 472 | 485 |
| 473 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) { | 486 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) { |
| 474 SimpleBrowserTest(IE, kCFIZeroSizePage); | 487 SimpleBrowserTest(IE, kCFIZeroSizePage); |
| 475 } | 488 } |
| 476 | 489 |
| 477 const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html"; | 490 const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html"; |
| 478 | 491 |
| 479 // http://crbug.com/32321 | 492 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceIfrPost) { |
| 480 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceIfrPost) { | |
| 481 SimpleBrowserTest(IE, kCFIIfrPostPage); | 493 SimpleBrowserTest(IE, kCFIIfrPostPage); |
| 482 } | 494 } |
| 483 | 495 |
| 484 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) { | 496 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) { |
| 485 SimpleBrowserTest(CHROME, kCFIIfrPostPage); | 497 SimpleBrowserTest(CHROME, kCFIIfrPostPage); |
| 486 } | 498 } |
| 487 | 499 |
| 488 const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html"; | 500 const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html"; |
| 489 | 501 |
| 490 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) { | 502 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) { |
| 491 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { | 503 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { |
| 492 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; | 504 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; |
| 493 return; | 505 return; |
| 494 } | 506 } |
| 495 SimpleBrowserTest(IE, kCFIPostPage); | 507 SimpleBrowserTest(IE, kCFIPostPage); |
| 496 } | 508 } |
| 497 | 509 |
| 498 // This test randomly fails on the ChromeFrame builder. | 510 // This test randomly fails on the ChromeFrame builder. |
| 499 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) { | 511 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) { |
| 500 SimpleBrowserTest(CHROME, kCFIPostPage); | 512 SimpleBrowserTest(CHROME, kCFIPostPage); |
| 501 } | 513 } |
| 502 | 514 |
| 503 const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html"; | 515 const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html"; |
| 504 | 516 |
| 505 // This test consistently times out in debug builds; see http://crbug.com/112599 | 517 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceRPC) { |
| 506 #ifndef NDEBUG | |
| 507 #define MAYBE_WidgetModeIE_CFInstanceRPC DISABLED_WidgetModeIE_CFInstanceRPC | |
| 508 #else | |
| 509 #define MAYBE_WidgetModeIE_CFInstanceRPC WidgetModeIE_CFInstanceRPC | |
| 510 #endif | |
| 511 | |
| 512 TEST_F(ChromeFrameTestWithWebServer, MAYBE_WidgetModeIE_CFInstanceRPC) { | |
| 513 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { | 518 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { |
| 514 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; | 519 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; |
| 515 return; | 520 return; |
| 516 } | 521 } |
| 517 SimpleBrowserTest(IE, kCFIRPCPage); | 522 SimpleBrowserTest(IE, kCFIRPCPage); |
| 518 } | 523 } |
| 519 | 524 |
| 520 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) { | 525 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) { |
| 521 SimpleBrowserTest(CHROME, kCFIRPCPage); | 526 SimpleBrowserTest(CHROME, kCFIRPCPage); |
| 522 } | 527 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 L"install_flow_test.html"; | 667 L"install_flow_test.html"; |
| 663 | 668 |
| 664 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { | 669 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { |
| 665 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 670 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
| 666 ScopedChromeFrameRegistrar::UnregisterAtPath( | 671 ScopedChromeFrameRegistrar::UnregisterAtPath( |
| 667 GetChromeFrameBuildPath().value(), | 672 GetChromeFrameBuildPath().value(), |
| 668 chrome_frame_test::GetTestBedType()); | 673 chrome_frame_test::GetTestBedType()); |
| 669 | 674 |
| 670 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl)); | 675 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl)); |
| 671 | 676 |
| 672 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 677 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 673 | 678 |
| 674 ScopedChromeFrameRegistrar::RegisterAtPath( | 679 ScopedChromeFrameRegistrar::RegisterAtPath( |
| 675 GetChromeFrameBuildPath().value(), | 680 GetChromeFrameBuildPath().value(), |
| 676 chrome_frame_test::GetTestBedType()); | 681 chrome_frame_test::GetTestBedType()); |
| 677 | 682 |
| 678 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), | 683 server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), |
| 679 kPostedResultSubstring); | 684 kPostedResultSubstring); |
| 680 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 685 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 681 | 686 |
| 682 chrome_frame_test::CloseAllIEWindows(); | 687 chrome_frame_test::CloseAllIEWindows(); |
| 683 ASSERT_EQ("OK", server_mock_.posted_result()); | 688 ASSERT_EQ("OK", server_mock().posted_result()); |
| 684 } | 689 } |
| 685 } | 690 } |
| 686 | 691 |
| 687 const wchar_t kMultipleCFInstancesTestUrl[] = | 692 const wchar_t kMultipleCFInstancesTestUrl[] = |
| 688 L"multiple_cf_instances_main.html"; | 693 L"multiple_cf_instances_main.html"; |
| 689 | 694 |
| 690 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) { | 695 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) { |
| 691 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl); | 696 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl); |
| 692 } | 697 } |
| 693 | 698 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 721 L"full_tab_post_target_cf.html", | 726 L"full_tab_post_target_cf.html", |
| 722 L"chrome_frame_tester_helpers.js", | 727 L"chrome_frame_tester_helpers.js", |
| 723 }; | 728 }; |
| 724 | 729 |
| 725 SimpleWebServerTest server(46664); | 730 SimpleWebServerTest server(46664); |
| 726 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, | 731 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, |
| 727 arraysize(kPages), GetCFTestFilePath()); | 732 arraysize(kPages), GetCFTestFilePath()); |
| 728 | 733 |
| 729 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); | 734 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); |
| 730 | 735 |
| 731 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 736 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 732 | 737 |
| 733 const test_server::Request* request = NULL; | 738 const test_server::Request* request = NULL; |
| 734 server.FindRequest("/quit?OK", &request); | 739 server.FindRequest("/quit?OK", &request); |
| 735 ASSERT_TRUE(request != NULL); | 740 ASSERT_TRUE(request != NULL); |
| 736 EXPECT_EQ("OK", request->arguments()); | 741 EXPECT_EQ("OK", request->arguments()); |
| 737 | 742 |
| 738 if (request->arguments().compare("OK") == 0) { | 743 if (request->arguments().compare("OK") == 0) { |
| 739 // Check how many requests we got for the cf page. Also expect it to be | 744 // Check how many requests we got for the cf page. Also expect it to be |
| 740 // a POST. | 745 // a POST. |
| 741 int requests = server.GetRequestCountForPage(kPages[1], "POST"); | 746 int requests = server.GetRequestCountForPage(kPages[1], "POST"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 753 L"chrome_frame_tester_helpers.js", | 758 L"chrome_frame_tester_helpers.js", |
| 754 }; | 759 }; |
| 755 | 760 |
| 756 SimpleWebServerTest server(46664); | 761 SimpleWebServerTest server(46664); |
| 757 | 762 |
| 758 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, | 763 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, |
| 759 arraysize(kPages), GetCFTestFilePath()); | 764 arraysize(kPages), GetCFTestFilePath()); |
| 760 | 765 |
| 761 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); | 766 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); |
| 762 | 767 |
| 763 loop_.RunFor(kChromeFrameVeryLongNavigationTimeoutInSeconds); | 768 loop().RunFor(kChromeFrameVeryLongNavigationTimeoutInSeconds); |
| 764 | 769 |
| 765 const test_server::Request* request = NULL; | 770 const test_server::Request* request = NULL; |
| 766 server.FindRequest("/quit?OK", &request); | 771 server.FindRequest("/quit?OK", &request); |
| 767 ASSERT_TRUE(request != NULL); | 772 ASSERT_TRUE(request != NULL); |
| 768 EXPECT_EQ("OK", request->arguments()); | 773 EXPECT_EQ("OK", request->arguments()); |
| 769 | 774 |
| 770 if (request->arguments().compare("OK") == 0) { | 775 if (request->arguments().compare("OK") == 0) { |
| 771 // Check how many requests we got for the cf page and check that it was | 776 // Check how many requests we got for the cf page and check that it was |
| 772 // a GET. | 777 // a GET. |
| 773 int requests = server.GetRequestCountForPage(kPages[1], "GET"); | 778 int requests = server.GetRequestCountForPage(kPages[1], "GET"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 785 const wchar_t kXHRConditionalHeaderTestUrl[] = | 790 const wchar_t kXHRConditionalHeaderTestUrl[] = |
| 786 L"xmlhttprequest_conditional_header_test.html"; | 791 L"xmlhttprequest_conditional_header_test.html"; |
| 787 | 792 |
| 788 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) { | 793 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) { |
| 789 SimpleBrowserTest(IE, kXHRConditionalHeaderTestUrl); | 794 SimpleBrowserTest(IE, kXHRConditionalHeaderTestUrl); |
| 790 } | 795 } |
| 791 | 796 |
| 792 const wchar_t kWindowCloseTestUrl[] = | 797 const wchar_t kWindowCloseTestUrl[] = |
| 793 L"window_close.html"; | 798 L"window_close.html"; |
| 794 | 799 |
| 795 // http://code.google.com/p/chromium/issues/detail?id=111074 | 800 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_WindowClose) { |
| 796 TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_WindowClose) { | |
| 797 SimpleBrowserTest(IE, kWindowCloseTestUrl); | 801 SimpleBrowserTest(IE, kWindowCloseTestUrl); |
| 798 } | 802 } |
| 799 | 803 |
| 800 std::string GetHeaderValue(const std::string& headers, | 804 std::string GetHeaderValue(const std::string& headers, |
| 801 const char* header_name) { | 805 const char* header_name) { |
| 802 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), | 806 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), |
| 803 "\r\n"); | 807 "\r\n"); |
| 804 while (it.GetNext()) { | 808 while (it.GetNext()) { |
| 805 if (lstrcmpiA(it.name().c_str(), header_name) == 0) { | 809 if (lstrcmpiA(it.name().c_str(), header_name) == 0) { |
| 806 return it.values(); | 810 return it.values(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 L"mshtml_refresh_test.html", | 875 L"mshtml_refresh_test.html", |
| 872 L"mshtml_refresh_test_popup.html", | 876 L"mshtml_refresh_test_popup.html", |
| 873 }; | 877 }; |
| 874 | 878 |
| 875 SimpleWebServerTest server(46664); | 879 SimpleWebServerTest server(46664); |
| 876 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages, | 880 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages, |
| 877 arraysize(kPages), GetCFTestFilePath()); | 881 arraysize(kPages), GetCFTestFilePath()); |
| 878 | 882 |
| 879 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); | 883 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); |
| 880 | 884 |
| 881 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 885 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 882 | 886 |
| 883 test_server::SimpleWebServer* ws = server.web_server(); | 887 test_server::SimpleWebServer* ws = server.web_server(); |
| 884 const test_server::ConnectionList& connections = ws->connections(); | 888 const test_server::ConnectionList& connections = ws->connections(); |
| 885 test_server::ConnectionList::const_iterator it = connections.begin(); | 889 test_server::ConnectionList::const_iterator it = connections.begin(); |
| 886 int requests_for_first_page = 0; | 890 int requests_for_first_page = 0; |
| 887 for (; it != connections.end(); ++it) { | 891 for (; it != connections.end(); ++it) { |
| 888 test_server::Connection* c = (*it); | 892 test_server::Connection* c = (*it); |
| 889 const test_server::Request& r = c->request(); | 893 const test_server::Request& r = c->request(); |
| 890 if (!r.path().empty() && | 894 if (!r.path().empty() && |
| 891 ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) { | 895 ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 size_t post_requests_; | 1007 size_t post_requests_; |
| 1004 size_t get_requests_; | 1008 size_t get_requests_; |
| 1005 }; | 1009 }; |
| 1006 | 1010 |
| 1007 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) | 1011 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) |
| 1008 .Times(testing::AtMost(1)) | 1012 .Times(testing::AtMost(1)) |
| 1009 .WillOnce(chrome_frame_test::DoCloseWindow()); | 1013 .WillOnce(chrome_frame_test::DoCloseWindow()); |
| 1010 | 1014 |
| 1011 EXPECT_CALL(win_observer_mock, OnWindowClose(_)) | 1015 EXPECT_CALL(win_observer_mock, OnWindowClose(_)) |
| 1012 .Times(testing::AtMost(1)) | 1016 .Times(testing::AtMost(1)) |
| 1013 .WillOnce(QUIT_LOOP(loop_)); | 1017 .WillOnce(QUIT_LOOP(loop())); |
| 1014 | 1018 |
| 1015 SimpleWebServerTest server(46664); | 1019 SimpleWebServerTest server(46664); |
| 1016 CustomResponse* response = new CustomResponse("/form.html"); | 1020 CustomResponse* response = new CustomResponse("/form.html"); |
| 1017 server.web_server()->AddResponse(response); | 1021 server.web_server()->AddResponse(response); |
| 1018 | 1022 |
| 1019 std::wstring url(server.FormatHttpPath(L"form.html")); | 1023 std::wstring url(server.FormatHttpPath(L"form.html")); |
| 1020 | 1024 |
| 1021 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); | 1025 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); |
| 1022 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 1026 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 1023 | 1027 |
| 1024 EXPECT_EQ(1, response->get_request_count()); | 1028 EXPECT_EQ(1, response->get_request_count()); |
| 1025 EXPECT_EQ(1, response->post_request_count()); | 1029 EXPECT_EQ(1, response->post_request_count()); |
| 1026 } | 1030 } |
| OLD | NEW |