15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome_frame/test/test_with_web_server.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/base_paths.h" 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/file_util.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/file_version_info.h" 102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/memory_mapped_file.h" 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/scoped_temp_dir.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/path_service.h" 13a3f7b4e666c476898878fa745f637129375cd889Ben Murdoch#include "base/process/kill.h" 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/stringprintf.h" 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/test/test_timeouts.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/win/windows_version.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_switches.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/installer/util/helper.h" 20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/installer/util/install_util.h" 21c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome/installer/util/product.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome_frame/html_utils.h" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome_frame/test/chrome_frame_test_utils.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome_frame/test/mock_ie_event_sink_actions.h" 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome_frame/test/mock_ie_event_sink_test.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome_frame/test/test_scrubber.h" 27c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "chrome_frame/utils.h" 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/base/mime_util.h" 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "net/http/http_util.h" 30c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "net/socket/stream_listen_socket.h" 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using chrome_frame_test::kChromeFrameLongNavigationTimeout; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using chrome_frame_test::kChromeFrameVeryLongNavigationTimeout; 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using testing::_; 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using testing::StrCaseEq; 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kDocRoot[] = L"chrome_frame\\test\\data"; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Helper method for creating the appropriate HTTP response headers. 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string CreateHttpHeaders(CFInvocation invocation, 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool add_no_cache_header, 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::string& content_type) { 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::ostringstream ss; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ss << "HTTP/1.1 200 OK\r\n" 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) << "Connection: close\r\n" 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) << "Content-Type: " << content_type << "\r\n"; 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (invocation.type() == CFInvocation::HTTP_HEADER) 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ss << "X-UA-Compatible: chrome=1\r\n"; 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (add_no_cache_header) { 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ss << "Cache-Control: no-cache\r\n"; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ss << "Expires: Tue, 15 Nov 1994 08:12:31 GMT\r\n"; 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return ss.str(); 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)std::string GetMockHttpHeaders(const base::FilePath& mock_http_headers_path) { 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string headers; 6158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) base::ReadFileToString(mock_http_headers_path, &headers); 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return headers; 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ChromeFrameTestEnvironment: public testing::Environment { 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~ChromeFrameTestEnvironment() {} 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetUp() OVERRIDE { 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ScopedChromeFrameRegistrar::RegisterDefaults(); 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)::testing::Environment* const chrome_frame_env = 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ::testing::AddGlobalTestEnvironment(new ChromeFrameTestEnvironment); 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)base::FilePath ChromeFrameTestWithWebServer::test_file_path_; 792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)base::FilePath ChromeFrameTestWithWebServer::results_dir_; 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)base::FilePath ChromeFrameTestWithWebServer::CFInstall_path_; 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)base::FilePath ChromeFrameTestWithWebServer::CFInstance_path_; 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)base::ScopedTempDir ChromeFrameTestWithWebServer::temp_dir_; 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)base::FilePath ChromeFrameTestWithWebServer::chrome_user_data_dir_; 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)chrome_frame_test::TimedMsgLoop* ChromeFrameTestWithWebServer::loop_; 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string ChromeFrameTestWithWebServer::local_address_; 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)testing::StrictMock<MockWebServerListener>* 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ChromeFrameTestWithWebServer::listener_mock_; 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)testing::StrictMock<MockWebServer>* ChromeFrameTestWithWebServer::server_mock_; 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() { 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeFrameTestWithWebServer::SetUpTestCase() { 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath chrome_frame_source_path; 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PathService::Get(base::DIR_SOURCE_ROOT, &chrome_frame_source_path); 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) chrome_frame_source_path = chrome_frame_source_path.Append( 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FILE_PATH_LITERAL("chrome_frame")); 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_file_path_ = chrome_frame_source_path 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .Append(FILE_PATH_LITERAL("test")) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .Append(FILE_PATH_LITERAL("data")); 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) results_dir_ = chrome_frame_test::GetTestDataFolder().AppendASCII("dump"); 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Copy the CFInstance.js and CFInstall.js files from src\chrome_frame to 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // src\chrome_frame\test\data. 1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath CFInstance_src_path; 1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath CFInstall_src_path; 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CFInstance_src_path = chrome_frame_source_path.AppendASCII("CFInstance.js"); 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CFInstance_path_ = test_file_path_.AppendASCII("CFInstance.js"); 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch ASSERT_TRUE(base::CopyFile(CFInstance_src_path, CFInstance_path_)); 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js"); 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js"); 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1197dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch ASSERT_TRUE(base::CopyFile(CFInstall_src_path, CFInstall_path_)); 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop_ = new chrome_frame_test::TimedMsgLoop(); 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop_->set_snapshot_on_timeout(true); 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) local_address_ = chrome_frame_test::GetLocalIPv4Address(); 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) listener_mock_ = new testing::StrictMock<MockWebServerListener>(); 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server_mock_ = new testing::StrictMock<MockWebServer>( 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1337, ASCIIToWide(local_address_), 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) chrome_frame_test::GetTestDataFolder()); 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server_mock_->set_listener(listener_mock_); 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeFrameTestWithWebServer::TearDownTestCase() { 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) delete server_mock_; 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server_mock_ = NULL; 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) delete listener_mock_; 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) listener_mock_ = NULL; 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) local_address_.clear(); 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) delete loop_; 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop_ = NULL; 1407dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch base::DeleteFile(CFInstall_path_, false); 1417dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch base::DeleteFile(CFInstance_path_, false); 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (temp_dir_.IsValid()) 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_TRUE(temp_dir_.Delete()); 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static 1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const base::FilePath& 1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)ChromeFrameTestWithWebServer::GetChromeUserDataDirectory() { 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!temp_dir_.IsValid()) { 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) chrome_user_data_dir_ = temp_dir_.path().AppendASCII("User Data"); 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return chrome_user_data_dir_; 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeFrameTestWithWebServer::SetUp() { 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Make sure that we are not accidentally enabling gcf protocol. 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SetConfigBool(kAllowUnsafeURLs, false); 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server_mock().ClearResults(); 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server_mock().ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server_mock().set_expected_result("OK"); 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeFrameTestWithWebServer::TearDown() { 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CloseBrowser(); 1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) loop().RunUntilIdle(); 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) testing::Mock::VerifyAndClear(listener_mock_); 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) testing::Mock::VerifyAndClear(server_mock_); 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser, 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const wchar_t* page) { 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::wstring url = page; 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We should resolve the URL only if it is a relative url. 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL parsed_url(WideToUTF8(page)); 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!parsed_url.has_scheme()) { 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) url = server_mock().Resolve(page); 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser_ = browser; 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (browser == IE) { 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser_handle_.Set(chrome_frame_test::LaunchIE(url)); 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else if (browser == CHROME) { 1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const base::FilePath& user_data_dir = GetChromeUserDataDirectory(); 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) chrome_frame_test::OverrideDataDirectoryForThisTest(user_data_dir.value()); 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser_handle_.Set(chrome_frame_test::LaunchChrome(url, user_data_dir)); 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 1905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NOTREACHED(); 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return browser_handle_.IsValid(); 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeFrameTestWithWebServer::CloseBrowser() { 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!browser_handle_.IsValid()) 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int attempts = 0; 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (browser_ == IE) { 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) attempts = chrome_frame_test::CloseAllIEWindows(); 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) attempts = chrome_frame_test::CloseVisibleWindowsOnAllThreads( 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser_handle_); 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (attempts > 0) { 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DWORD wait = ::WaitForSingleObject(browser_handle_, 20000); 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (wait == WAIT_OBJECT_0) { 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser_handle_.Close(); 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LOG(ERROR) << "WaitForSingleObject returned " << wait; 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 2165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LOG(ERROR) << "No attempts to close browser windows"; 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (browser_handle_.IsValid()) { 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DWORD exit_code = 0; 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!::GetExitCodeProcess(browser_handle_, &exit_code) || 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) exit_code == STILL_ACTIVE) { 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LOG(ERROR) << L"Forcefully killing browser process. Exit:" << exit_code; 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::KillProcess(browser_handle_, 0, true); 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser_handle_.Close(); 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ChromeFrameTestWithWebServer::BringBrowserToTop() { 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return simulate_input::EnsureProcessInForeground( 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetProcessId(browser_handle_)); 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ChromeFrameTestWithWebServer::WaitForTestToComplete( 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::TimeDelta duration) { 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop().RunFor(duration); 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return !loop().WasTimedOut(); 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return false; 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kPostedResultSubstring[] = L"/writefile/"; 2465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserKind browser, const wchar_t* page, const char* result) { 2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) if (browser == IE && chrome_frame_test::GetInstalledIEVersion() >= IE_9) { 2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) LOG(INFO) << "Temporarily disabling IE9 web server tests. " 2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) "See http://crbug.com/143699"; 2522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) return; 2532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 2542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int tries = 0; 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExpectAndHandlePostedResult(); 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Retry tests that timeout once; see http://crbug.com/96449. 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) do { 2595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // NOTE: Failed ASSERTs cause this function to exit immediately. 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Don't take a snapshot on the first try. 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop().set_snapshot_on_timeout(tries != 0); 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LaunchBrowser(browser, page)); 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (WaitForTestToComplete(TestTimeouts::action_max_timeout())) { 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The test exited without timing out. Confirm that the expected response 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // was posted and return. 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_EQ(result, server_mock().posted_result()); 2675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) break; 2685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_EQ(std::string(), server_mock().posted_result()) 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) << "Test timed out yet provided a result."; 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_EQ(0, tries++) << "Failing test due to two timeouts."; 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Close the browser and try a second time. 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CloseBrowser(); 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LOG(ERROR) << "Retrying test once since it timed out."; 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } while (true); 2765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop().set_snapshot_on_timeout(true); 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, 2805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const wchar_t* page) { 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTestExpectedResult(browser, page, "OK"); 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeFrameTestWithWebServer::ExpectAndHandlePostedResult() { 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_CALL(listener_mock(), OnExpectedResponse()) 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .WillRepeatedly(QUIT_LOOP_SOON(loop(), 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::TimeDelta::FromMilliseconds(100))); 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) kPostedResultSubstring); 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const wchar_t* page) { 2942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath plugin_path; 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PathService::Get(base::DIR_MODULE, &plugin_path); 2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) plugin_path = plugin_path.Append(kChromeFrameDllName); 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static FileVersionInfo* version_info = 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FileVersionInfo::CreateFileVersionInfo(plugin_path); 3005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::wstring version; 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (version_info) 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) version = version_info->product_version(); 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If we can't find the Chrome Frame DLL in the src tree, we turn to 3065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the directory where chrome is installed. 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!version_info) { 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Version ver_system; 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InstallUtil::GetChromeVersion(dist, true, &ver_system); 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Version ver_user; 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) InstallUtil::GetChromeVersion(dist, false, &ver_system); 3135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(ver_system.IsValid() || ver_user.IsValid()); 3145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool system_install = ver_system.IsValid(); 3162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist)); 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) cf_dll_path = cf_dll_path.Append(UTF8ToWide( 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ver_system.IsValid() ? ver_system.GetString() : ver_user.GetString())); 3195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (version_info) 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) version = version_info->product_version(); 3235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server_mock().set_expected_result(WideToUTF8(version)); 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_TRUE(version_info); 3285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_FALSE(version.empty()); 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTestExpectedResult(browser, page, WideToASCII(version).c_str()); 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// MockWebServer methods 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::wstring& url) { 3365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1)); 3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void MockWebServer::ExpectAndServeRequestWithCardinality( 3405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CFInvocation invocation, const std::wstring& url, 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) testing::Cardinality cardinality) { 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_CALL(*this, Get(_, chrome_frame_test::UrlPathEq(url), _)) 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .Times(cardinality) 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .WillRepeatedly(SendResponse(this, invocation)); 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void MockWebServer::ExpectAndServeRequestAllowCache(CFInvocation invocation, 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::wstring &url) { 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_CALL(*this, Get(_, chrome_frame_test::UrlPathEq(url), _)) 3505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .WillOnce(SendResponse(this, invocation)); 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void MockWebServer::ExpectAndServeRequestAnyNumberTimes( 3545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CFInvocation invocation, const std::wstring& path_prefix) { 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_CALL(*this, Get(_, testing::StartsWith(path_prefix), _)) 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .WillRepeatedly(SendResponse(this, invocation)); 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void MockWebServer::ExpectAndHandlePostedResult( 3605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CFInvocation invocation, const std::wstring& post_suffix) { 3615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_CALL(*this, Post(_, testing::HasSubstr(post_suffix), _)) 3625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .WillRepeatedly(HandlePostedResponseHelper(this, invocation)); 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void MockWebServer::HandlePostedResponse( 3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_server::ConfigurableConnection* connection, 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const test_server::Request& request) { 3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) posted_result_ = request.content(); 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (listener_ && posted_result_ == expected_result_) 3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) listener_->OnExpectedResponse(); 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) connection->Send("HTTP/1.1 200 OK\r\n", ""); 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void MockWebServer::SendResponseHelper( 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_server::ConfigurableConnection* connection, 3765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const std::wstring& request_uri, 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const test_server::Request& request, 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CFInvocation invocation, 3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool add_no_cache_header) { 3805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const wchar_t kEchoHeader[] = L"/echoheader?"; 3815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (request_uri.find(kEchoHeader) != std::wstring::npos) { 3825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::wstring header = request_uri.substr( 3835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) wcslen(kEchoHeader), 3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) request_uri.length() - wcslen(kEchoHeader)); 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string header_value = http_utils::GetHttpHeaderFromHeaderList( 3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WideToUTF8(header), request.headers()); 3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) connection->Send(header_value, ""); 3895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 3905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Convert |request_uri| to a path. 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::wstring path = request_uri; 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) size_t query_index = request_uri.find(L"?"); 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (query_index != std::string::npos) { 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) path = path.erase(query_index); 3965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 3972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath file_path = root_dir_; 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (path.size()) 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) file_path = file_path.Append(path.substr(1)); // remove first '/' 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string headers, body; 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string content_type; 4037dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch if (base::PathExists(file_path) && 4047dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch !base::DirectoryExists(file_path)) { 4052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath mock_http_headers(file_path.value() + L".mock-http-headers"); 4067dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch if (base::PathExists(mock_http_headers)) { 4075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) headers = GetMockHttpHeaders(mock_http_headers); 4085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_type = http_utils::GetHttpHeaderFromHeaderList("Content-type", 4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) headers); 4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_TRUE(net::GetMimeTypeFromFile(file_path, &content_type)); 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VLOG(1) << "Going to send file (" << WideToUTF8(file_path.value()) 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) << ") with content type (" << content_type << ")"; 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) headers = CreateHttpHeaders(invocation, add_no_cache_header, 4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_type); 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_FALSE(headers.empty()); 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 42058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) EXPECT_TRUE(base::ReadFileToString(file_path, &body)) 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) << "Could not read file (" << WideToUTF8(file_path.value()) << ")"; 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (invocation.type() == CFInvocation::META_TAG && 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) StartsWithASCII(content_type, "text/html", false)) { 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_TRUE(chrome_frame_test::AddCFMetaTag(&body)) << "Could not add " 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) << "meta tag to HTML file."; 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VLOG(1) << "Going to send 404 for non-existent file (" 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) << WideToUTF8(file_path.value()) << ")"; 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) headers = "HTTP/1.1 404 Not Found"; 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) body = ""; 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) connection->Send(headers, body); 4345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kPostMessageBasicPage[] = L"postmessage_basic_host.html"; 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_PostMessageBasic) { 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kPostMessageBasicPage); 4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabIE_MIMEFilterBasic) { 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const wchar_t kMIMEFilterBasicPage[] = 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"chrome_frame_mime_filter_test.html"; 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If this test fails for IE8 then it is possible that prebinding is enabled. 4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // A known workaround is to disable it until CF properly handles it. 4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // 4495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // HKCU\Software\Microsoft\Internet Explorer\Main 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Value name: EnablePreBinding (REG_DWORD) 4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Value: 0 4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kMIMEFilterBasicPage); 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Times out: http://crbug.com/163728 4562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_Resize) { 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, L"chrome_frame_resize.html"); 4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kNavigateURLAbsolutePage[] = 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"navigateurl_absolute_host.html"; 4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_NavigateURLAbsolute) { 4645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kNavigateURLAbsolutePage); 4655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kNavigateURLRelativePage[] = 4685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"navigateurl_relative_host.html"; 4695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky, crbug.com/160497. 4712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, 4722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DISABLED_WidgetModeIE_NavigateURLRelative) { 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kNavigateURLRelativePage); 4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kNavigateSimpleObjectFocus[] = L"simple_object_focus.html"; 4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_ObjectFocus) { 4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kNavigateSimpleObjectFocus); 4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html"; 4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky, crbug.com/160497. 4862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_iframeBasic) { 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kiframeBasicPage); 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html"; 4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_SrcProperty) { 4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kSrcPropertyTestPage); 4945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html"; 4975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) { 4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFInstanceBasicTestPage); 5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html"; 5035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) { 5055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFISingletonPage); 5065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html"; 5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDelay) { 5115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFIDelayPage); 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html"; 5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceFallback) { 5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFIFallbackPage); 5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html"; 5215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky, crbug.com/160497. 5232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceNoSrc) { 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFINoSrcPage); 5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html"; 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// disabled since it's unlikely that we care about this case 5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, 5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISABLED_WidgetModeIE_CFInstanceIfrOnLoad) { 5325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFIIfrOnLoadPage); 5335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html"; 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) { 5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFIZeroSizePage); 5395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html"; 5425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceIfrPost) { 5445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFIIfrPostPage); 5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) { 5485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(CHROME, kCFIIfrPostPage); 5495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html"; 5525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) { 5545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { 5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; 5565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 5575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFIPostPage); 5595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This test randomly fails on the ChromeFrame builder. 5625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) { 5635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(CHROME, kCFIPostPage); 5645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html"; 5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceRPC) { 5695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { 5705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; 5715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 5725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFIRPCPage); 5745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) { 5775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(CHROME, kCFIRPCPage); 5785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFIRPCInternalPage[] = 5815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"CFInstance_rpc_internal_host.html"; 5825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceRPCInternal) { 5845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { 5855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; 5865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 5875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 5885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFIRPCInternalPage); 5895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPCInternal) { 5925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(CHROME, kCFIRPCInternalPage); 5935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFIDefaultCtorPage[] = 5965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"CFInstance_default_ctor_host.html"; 5975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDefaultCtor) { 5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFIDefaultCtorPage); 6005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFInstallBasicTestPage[] = L"CFInstall_basic.html"; 6035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallBasic) { 6055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFInstallBasicTestPage); 6065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFInstallPlaceTestPage[] = L"CFInstall_place.html"; 6095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallPlace) { 6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFInstallPlaceTestPage); 6125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFInstallOverlayTestPage[] = L"CFInstall_overlay.html"; 6155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallOverlay) { 6175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFInstallOverlayTestPage); 6185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFInstallDismissTestPage[] = L"CFInstall_dismiss.html"; 6215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallDismiss) { 6235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFInstallDismissTestPage); 6245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kInitializeHiddenPage[] = L"initialize_hidden.html"; 6272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Times out: http://crbug.com/163728 6282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_InitializeHidden) { 6295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kInitializeHiddenPage); 6305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kFullTabHttpHeaderPage[] = L"chrome_frame_http_header.html"; 6335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_CFHttpHeaderBasic) { 6355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kFullTabHttpHeaderPage); 6365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kFullTabHttpHeaderPageIFrame[] = 6395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"chrome_frame_http_header_host.html"; 6405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_CFHttpHeaderIFrame) { 6425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kFullTabHttpHeaderPageIFrame); 6435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kFullTabHttpHeaderPageFrameset[] = 6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"chrome_frame_http_header_frameset.html"; 6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_CFHttpHeaderFrameSet) { 6495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kFullTabHttpHeaderPageFrameset); 6505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kVersionPage[] = L"version.html"; 6535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky, crbug.com/160497. 6552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_Version) { 6565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) VersionTest(IE, kVersionPage); 6575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kEventListenerPage[] = L"event_listener.html"; 6605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_EventListener) { 6625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kEventListenerPage); 6635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kPrivilegedApisPage[] = L"privileged_apis_host.html"; 6665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_PrivilegedApis) { 6685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kPrivilegedApisPage); 6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kMetaTagPage[] = L"meta_tag.html"; 6725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky, crbug.com/160497. 6732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_MetaTag) { 6745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kMetaTagPage); 6755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Times out: http://crbug.com/163728 6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kCFProtocolPage[] = L"cf_protocol.html"; 6792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_CFProtocol) { 6805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Temporarily enable gcf: protocol for this test. 6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SetConfigBool(kAllowUnsafeURLs, true); 6825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kCFProtocolPage); 6835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SetConfigBool(kAllowUnsafeURLs, false); 6845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kPersistentCookieTest[] = 6875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"persistent_cookie_test_page.html"; 6885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_PersistentCookieTest) { 6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kPersistentCookieTest); 6905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kNavigateOutPage[] = L"navigate_out.html"; 6935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_NavigateOut) { 6945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kNavigateOutPage); 6955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kReferrerMainTest[] = L"referrer_main.html"; 6985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ReferrerTest) { 7005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kReferrerMainTest); 7015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Times out: http://crbug.com/163728 7045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kSubFrameTestPage[] = L"full_tab_sub_frame_main.html"; 7052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_SubFrame) { 7065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kSubFrameTestPage); 7075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kSubIFrameTestPage[] = L"full_tab_sub_iframe_main.html"; 7105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubIFrame) { 7115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kSubIFrameTestPage); 7125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kXMLHttpRequestTestUrl[] = 7155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"xmlhttprequest_test.html"; 7165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky, crbug.com/160497. 7182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_XHRTest) { 7195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kXMLHttpRequestTestUrl); 7205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kInstallFlowTestUrl[] = 7235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"install_flow_test.html"; 7245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { 7265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (base::win::GetVersion() < base::win::VERSION_VISTA) { 7275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ScopedChromeFrameRegistrar::UnregisterAtPath( 7285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetChromeFrameBuildPath().value(), 7295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) chrome_frame_test::GetTestBedType()); 7305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl)); 7325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop().RunFor(kChromeFrameLongNavigationTimeout); 7345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ScopedChromeFrameRegistrar::RegisterAtPath( 7365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GetChromeFrameBuildPath().value(), 7375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) chrome_frame_test::GetTestBedType()); 7385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExpectAndHandlePostedResult(); 7405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop().RunFor(kChromeFrameLongNavigationTimeout); 7415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) chrome_frame_test::CloseAllIEWindows(); 7435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_EQ("OK", server_mock().posted_result()); 7445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 7455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kMultipleCFInstancesTestUrl[] = 7485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"multiple_cf_instances_main.html"; 7495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) { 7515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl); 7525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kXHRHeaderTestUrl[] = 7555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"xmlhttprequest_header_test.html"; 7565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Marking as flaky since it occasionally times out. crbug.com/127395. 7582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_XHRHeaderTest) { 7595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kXHRHeaderTestUrl); 7605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kDeleteCookieTest[] = 7635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"fulltab_delete_cookie_test.html"; 7645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_DeleteCookieTest) { 7665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kDeleteCookieTest); 7675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kAnchorUrlNavigate[] = 7705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"fulltab_anchor_url_navigate.html#chrome_frame"; 7715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_AnchorUrlNavigateTest) { 7735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kAnchorUrlNavigate); 7745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 7755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test whether POST-ing a form from an mshtml page to a CF page will cause 7775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the request to get reissued. It should not. 7785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// https://code.google.com/p/chromium/issues/detail?id=143699 7792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_TestPostReissue) { 7805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The order of pages in this array is assumed to be mshtml, cf, script. 7815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const wchar_t* kPages[] = { 7825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"full_tab_post_mshtml.html", 7835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"full_tab_post_target_cf.html", 7845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"chrome_frame_tester_helpers.js", 7855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 7865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleWebServerTest server(local_address_, 46664); 7885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 7895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) arraysize(kPages), GetCFTestFilePath()); 7905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 7925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop().RunFor(kChromeFrameLongNavigationTimeout); 7945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 7955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const test_server::Request* request = NULL; 7965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server.FindRequest("/quit?OK", &request); 7975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(request != NULL); 7985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ("OK", request->arguments()); 7995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (request->arguments().compare("OK") == 0) { 8015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Check how many requests we got for the cf page. Also expect it to be 8025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a POST. 8035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int requests = server.GetRequestCountForPage(kPages[1], "POST"); 8045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(1, requests); 8055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 8065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test whether following a link from an mshtml page to a CF page will cause 8095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// multiple network requests. It should not. 8105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky, crbug.com/160497. 8112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_TestMultipleGet) { 8125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The order of pages in this array is assumed to be mshtml, cf, script. 8135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const wchar_t* kPages[] = { 8145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"full_tab_get_mshtml.html", 8155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"full_tab_get_target_cf.html", 8165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"chrome_frame_tester_helpers.js", 8175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 8185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleWebServerTest server(local_address_, 46664); 8205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 8225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) arraysize(kPages), GetCFTestFilePath()); 8235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 8255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop().RunFor(kChromeFrameVeryLongNavigationTimeout); 8275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const test_server::Request* request = NULL; 8295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server.FindRequest("/quit?OK", &request); 8305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(request != NULL); 8315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ("OK", request->arguments()); 8325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (request->arguments().compare("OK") == 0) { 8345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Check how many requests we got for the cf page and check that it was 8355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a GET. 8365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int requests = server.GetRequestCountForPage(kPages[1], "GET"); 8375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(1, requests); 8385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 8395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kSetCookieTest[] = 8425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"fulltab_set_cookie_test.html"; 8435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SetCookieTest) { 8455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kSetCookieTest); 8465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kXHRConditionalHeaderTestUrl[] = 8495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"xmlhttprequest_conditional_header_test.html"; 8505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) { 8525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kXHRConditionalHeaderTestUrl); 8535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)const wchar_t kWindowCloseTestUrl[] = 8565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"window_close.html"; 8575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_WindowClose) { 8595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleBrowserTest(IE, kWindowCloseTestUrl); 8605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)std::string GetHeaderValue(const std::string& headers, 8635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const char* header_name) { 8645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), 8655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "\r\n"); 8665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) while (it.GetNext()) { 8675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (lstrcmpiA(it.name().c_str(), header_name) == 0) { 8685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return it.values(); 8695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 8705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 8715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return ""; 8725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 8735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Specialized implementation of test_server::FileResponse that supports 8755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// adding the request's User-Agent header to the returned document. 8765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// The class also supports $request_id$ which will be replaced with an 8775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// id that's incremented each time the response is sent over a socket. 8785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class UaTemplateFileResponse : public test_server::FileResponse { 8795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 8805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) typedef test_server::FileResponse SuperClass; 8815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) UaTemplateFileResponse(const char* request_path, 8832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const base::FilePath& file_path) 8845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : test_server::FileResponse(request_path, file_path), request_id_(0) { 8855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 8865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool Matches(const test_server::Request& r) const { 8885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool ret = SuperClass::Matches(r); 8895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (ret) 8905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ua_ = GetHeaderValue(r.headers(), "User-Agent"); 8915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return ret; 8925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 8935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual size_t ContentLength() const { 8955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const char kRequestIdTemplate[] = "$request_id$"; 8965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const char kUserAgentTemplate[] = "$UA$"; 8975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 8985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) size_t length = SuperClass::ContentLength(); 8995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(length); 9005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_.assign(reinterpret_cast<const char*>(file_->data()), 9015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) file_->length()); 9025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) size_t i = content_.find(kUserAgentTemplate); 9035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (i != std::string::npos) 9045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_.replace(i, arraysize(kUserAgentTemplate) - 1, ua_); 9055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) i = content_.find(kRequestIdTemplate); 9065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (i != std::string::npos) { 9075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content_.replace(i, arraysize(kRequestIdTemplate) - 1, 9085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::StringPrintf("%i", request_id_)); 9095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 9105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return content_.length(); 9115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 9125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void WriteContents(net::StreamListenSocket* socket) const { 9145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(content_.length()); 9155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) socket->Send(content_.c_str(), content_.length(), false); 9165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) request_id_++; 9175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 9185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 9205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) mutable std::string ua_; 9215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) mutable std::string content_; 9225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) mutable int request_id_; 9235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 9245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This test simulates a URL that on first request returns a document 9265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// that should be rendered in mshtml, then pops up a sign-in page that 9275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// after signing in, refreshes the original page that should then return 9285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// a page that needs to be rendered in GCF. 9295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 9305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This test currently fails because GCF does not add the chromeframe header 9315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to requests that mshtml initiates via IInternetSession::CreateBinding. 9325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_RefreshMshtmlTest) { 9335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const wchar_t* kPages[] = { 9345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"mshtml_refresh_test.html", 9355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"mshtml_refresh_test_popup.html", 9365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 9375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleWebServerTest server(local_address_, 46664); 9395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages, 9405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) arraysize(kPages), GetCFTestFilePath()); 9415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 9435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop().RunFor(kChromeFrameLongNavigationTimeout); 9455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_server::SimpleWebServer* ws = server.web_server(); 9475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const test_server::ConnectionList& connections = ws->connections(); 9485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_server::ConnectionList::const_iterator it = connections.begin(); 9495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int requests_for_first_page = 0; 9505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) for (; it != connections.end(); ++it) { 9515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_server::Connection* c = (*it); 9525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const test_server::Request& r = c->request(); 9535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!r.path().empty() && 9545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) { 9555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) requests_for_first_page++; 9565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string ua(GetHeaderValue(r.headers(), "User-Agent")); 9575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_NE(std::string::npos, ua.find("chromeframe")); 9585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 9595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 9605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_GT(requests_for_first_page, 1); 9615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 9625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// See bug 36694 for details. http://crbug.com/36694 9645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestDownloadFromForm) { 9655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) chrome_frame_test::MockWindowObserver win_observer_mock; 9665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) win_observer_mock.WatchWindow("File Download", ""); 9675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) win_observer_mock.WatchWindow("View Downloads*", ""); 9685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The content of our HTML test page. This will be returned whenever 9705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // we reply to a GET request. 9715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const char kHtml[] = 9725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "<html><head>\n" 9735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "<title>ChromeFrame Form Download Test</title>\n" 9745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // To see how this test runs with only IE (no CF in the picture), comment 9755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // out this meta tag. The outcome of the test should be identical. 9765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "<meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1\" />\n" 9775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "</head>\n" 9785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "<script language=\"javascript\">\n" 9795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "function SubmitForm() {\n" 9805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) " var form = document.forms['myform'];\n" 9815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) " form.action = document.location;\n" 9825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) " form.submit();\n" 9835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) " return true;\n" 9845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "}\n" 9855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "</script>\n" 9865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "<body onload=\"SubmitForm();\">\n" 9875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "<form method=\"post\" action=\"foo.html\" id=\"myform\">\n" 9885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) " <input type=\"hidden\" name=\"Field1\" value=\"myvalue\" />\n" 9895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) " <input type=\"button\" name=\"btn\" value=\"Test Download\" " 9905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "onclick=\"return SubmitForm();\" id=\"Button1\"/>\n" 9915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "</form></body></html>\n"; 9925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The content of our HTML test page. This will be returned whenever 9945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // we reply to a POST request. 9955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const char kText[] = 9965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "This is a text file (in case you were wondering)."; 9975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This http response class will return an HTML document that contains 9995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // a form whenever it receives a GET request. Whenever it gets a POST 10005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // request, it will respond with a text file that needs to be downloaded 10015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // (content-disposition is "attachment"). 10025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) class CustomResponse : public test_server::ResponseForPath { 10035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 10045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit CustomResponse(const char* path) 10055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) : test_server::ResponseForPath(path), is_post_(false), 10065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) post_requests_(0), get_requests_(0) { 10075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool GetContentType(std::string* content_type) const { 10105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(!is_post_); 10115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return false; 10125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual size_t ContentLength() const { 10155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK(!is_post_); 10165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return sizeof(kHtml) - 1; 10175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool GetCustomHeaders(std::string* headers) const { 10205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (!is_post_) 10215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return false; 10222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *headers = base::StringPrintf( 10235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "HTTP/1.1 200 OK\r\n" 10245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "Content-Disposition: attachment;filename=\"test.txt\"\r\n" 10255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "Content-Type: application/text\r\n" 10265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "Connection: close\r\n" 10275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "Content-Length: %i\r\n\r\n", sizeof(kText) - 1); 10285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return true; 10295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool Matches(const test_server::Request& r) const { 10325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool match = __super::Matches(r); 10335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (match) { 10345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) is_post_ = LowerCaseEqualsASCII(r.method().c_str(), "post"); 10355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return match; 10375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void WriteContents(net::StreamListenSocket* socket) const { 10405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (is_post_) { 10415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) socket->Send(kText, sizeof(kText) - 1, false); 10425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 10435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) socket->Send(kHtml, sizeof(kHtml) - 1, false); 10445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void IncrementAccessCounter() { 10485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) __super::IncrementAccessCounter(); 10495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (is_post_) { 10505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) post_requests_++; 10515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 10525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) get_requests_++; 10535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) size_t get_request_count() const { 10575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return get_requests_; 10585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) size_t post_request_count() const { 10615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return get_requests_; 10625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 10635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 10655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) mutable bool is_post_; 10665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) size_t post_requests_; 10675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) size_t get_requests_; 10685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 10695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) 10715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .Times(testing::AtMost(1)) 10725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .WillOnce(chrome_frame_test::DoCloseWindow()); 10735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_CALL(win_observer_mock, OnWindowClose(_)) 10755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .Times(testing::AtMost(1)) 10765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .WillOnce(QUIT_LOOP(loop())); 10775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimpleWebServerTest server(local_address_, 46664); 10795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CustomResponse* response = new CustomResponse("/form.html"); 10805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) server.web_server()->AddResponse(response); 10815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::wstring url(server.FormatHttpPath(L"form.html")); 10835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); 10855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) loop().RunFor(kChromeFrameLongNavigationTimeout); 10865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(1, response->get_request_count()); 10885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(1, response->post_request_count()); 10895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 10902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// This test loads a large page and ensures that the full page contents are 10922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// actually loaded via a self-validating HTML page. This is done due to a bug 10932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// whereby the middle of the response stream would sometimes be truncated when 10942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// loading a CF document. See http://crbug.com/178421 for details. 10952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_LargePageLoad) { 10962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) const wchar_t kLargePageLoadPage[] = 10972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) L"chrome_frame_large_page.html"; 10982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 10992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) SimpleBrowserTest(IE, kLargePageLoadPage); 11002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} 1101