| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #include <windows.h> | 4 #include <windows.h> |
| 5 #include <stdarg.h> | 5 #include <stdarg.h> |
| 6 | 6 |
| 7 // IShellWindows includes. Unfortunately we can't keep these in | 7 // IShellWindows includes. Unfortunately we can't keep these in |
| 8 // alphabetic order since exdisp will bark if some interfaces aren't fully | 8 // alphabetic order since exdisp will bark if some interfaces aren't fully |
| 9 // defined. | 9 // defined. |
| 10 #include <mshtml.h> | 10 #include <mshtml.h> |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING | 31 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING |
| 32 #include "testing/gmock_mutant.h" | 32 #include "testing/gmock_mutant.h" |
| 33 | 33 |
| 34 using testing::CreateFunctor; | 34 using testing::CreateFunctor; |
| 35 | 35 |
| 36 const wchar_t kDocRoot[] = L"chrome_frame\\test\\data"; | 36 const wchar_t kDocRoot[] = L"chrome_frame\\test\\data"; |
| 37 const int kLongWaitTimeout = 60 * 1000; | 37 const int kLongWaitTimeout = 60 * 1000; |
| 38 const int kShortWaitTimeout = 25 * 1000; | 38 const int kShortWaitTimeout = 25 * 1000; |
| 39 | 39 |
| 40 _ATL_FUNC_INFO WebBrowserEventSink::kNavigateErrorInfo = { | |
| 41 CC_STDCALL, VT_EMPTY, 5, { | |
| 42 VT_DISPATCH, | |
| 43 VT_VARIANT | VT_BYREF, | |
| 44 VT_VARIANT | VT_BYREF, | |
| 45 VT_VARIANT | VT_BYREF, | |
| 46 VT_BOOL | VT_BYREF, | |
| 47 } | |
| 48 }; | |
| 49 | |
| 50 _ATL_FUNC_INFO WebBrowserEventSink::kNavigateComplete2Info = { | |
| 51 CC_STDCALL, VT_EMPTY, 2, { | |
| 52 VT_DISPATCH, | |
| 53 VT_VARIANT | VT_BYREF | |
| 54 } | |
| 55 }; | |
| 56 | |
| 57 _ATL_FUNC_INFO WebBrowserEventSink::kBeforeNavigate2Info = { | |
| 58 CC_STDCALL, VT_EMPTY, 7, { | |
| 59 VT_DISPATCH, | |
| 60 VT_VARIANT | VT_BYREF, | |
| 61 VT_VARIANT | VT_BYREF, | |
| 62 VT_VARIANT | VT_BYREF, | |
| 63 VT_VARIANT | VT_BYREF, | |
| 64 VT_VARIANT | VT_BYREF, | |
| 65 VT_BOOL | VT_BYREF | |
| 66 } | |
| 67 }; | |
| 68 | |
| 69 _ATL_FUNC_INFO WebBrowserEventSink::kNewWindow3Info = { | |
| 70 CC_STDCALL, VT_EMPTY, 5, { | |
| 71 VT_DISPATCH | VT_BYREF, | |
| 72 VT_BOOL | VT_BYREF, | |
| 73 VT_UINT, | |
| 74 VT_BSTR, | |
| 75 VT_BSTR | |
| 76 } | |
| 77 }; | |
| 78 | |
| 79 _ATL_FUNC_INFO WebBrowserEventSink::kVoidMethodInfo = { | |
| 80 CC_STDCALL, VT_EMPTY, 0, {NULL}}; | |
| 81 | |
| 82 void ChromeFrameTestWithWebServer::CloseAllBrowsers() { | 40 void ChromeFrameTestWithWebServer::CloseAllBrowsers() { |
| 83 // Web browsers tend to relaunch themselves in other processes, meaning the | 41 // Web browsers tend to relaunch themselves in other processes, meaning the |
| 84 // KillProcess stuff above might not have actually cleaned up all our browser | 42 // KillProcess stuff above might not have actually cleaned up all our browser |
| 85 // instances, so make really sure browsers are dead. | 43 // instances, so make really sure browsers are dead. |
| 86 base::KillProcesses(chrome_frame_test::kIEImageName, 0, NULL); | 44 base::KillProcesses(chrome_frame_test::kIEImageName, 0, NULL); |
| 87 base::KillProcesses(chrome_frame_test::kIEBrokerImageName, 0, NULL); | 45 base::KillProcesses(chrome_frame_test::kIEBrokerImageName, 0, NULL); |
| 88 base::KillProcesses(chrome_frame_test::kFirefoxImageName, 0, NULL); | 46 base::KillProcesses(chrome_frame_test::kFirefoxImageName, 0, NULL); |
| 89 base::KillProcesses(chrome_frame_test::kSafariImageName, 0, NULL); | 47 base::KillProcesses(chrome_frame_test::kSafariImageName, 0, NULL); |
| 90 | 48 |
| 91 // Endeavour to only kill off Chrome Frame derived Chrome processes. | 49 // Endeavour to only kill off Chrome Frame derived Chrome processes. |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 L"files/CFInstance_default_ctor_host.html"; | 533 L"files/CFInstance_default_ctor_host.html"; |
| 576 | 534 |
| 577 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDefaultCtor) { | 535 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDefaultCtor) { |
| 578 SimpleBrowserTest(IE, kCFIDefaultCtorPage, L"CFInstanceDefaultCtor"); | 536 SimpleBrowserTest(IE, kCFIDefaultCtorPage, L"CFInstanceDefaultCtor"); |
| 579 } | 537 } |
| 580 | 538 |
| 581 TEST_F(ChromeFrameTestWithWebServer, WidgetModeFF_CFInstanceDefaultCtor) { | 539 TEST_F(ChromeFrameTestWithWebServer, WidgetModeFF_CFInstanceDefaultCtor) { |
| 582 SimpleBrowserTest(FIREFOX, kCFIDefaultCtorPage, L"CFInstanceDefaultCtor"); | 540 SimpleBrowserTest(FIREFOX, kCFIDefaultCtorPage, L"CFInstanceDefaultCtor"); |
| 583 } | 541 } |
| 584 | 542 |
| 585 | |
| 586 const wchar_t kCFInstallBasicTestPage[] = L"files/CFInstall_basic.html"; | 543 const wchar_t kCFInstallBasicTestPage[] = L"files/CFInstall_basic.html"; |
| 587 | 544 |
| 588 TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallBasic) { | 545 TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallBasic) { |
| 589 SimpleBrowserTest(IE, kCFInstallBasicTestPage, L"CFInstallBasic"); | 546 SimpleBrowserTest(IE, kCFInstallBasicTestPage, L"CFInstallBasic"); |
| 590 } | 547 } |
| 591 | 548 |
| 592 const wchar_t kCFInstallPlaceTestPage[] = L"files/CFInstall_place.html"; | 549 const wchar_t kCFInstallPlaceTestPage[] = L"files/CFInstall_place.html"; |
| 593 | 550 |
| 594 TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallPlace) { | 551 TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallPlace) { |
| 595 SimpleBrowserTest(IE, kCFInstallPlaceTestPage, L"CFInstallPlace"); | 552 SimpleBrowserTest(IE, kCFInstallPlaceTestPage, L"CFInstallPlace"); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 template <> struct RunnableMethodTraits<MockProxyFactory> { | 800 template <> struct RunnableMethodTraits<MockProxyFactory> { |
| 844 void RetainCallee(MockProxyFactory* obj) {} | 801 void RetainCallee(MockProxyFactory* obj) {} |
| 845 void ReleaseCallee(MockProxyFactory* obj) {} | 802 void ReleaseCallee(MockProxyFactory* obj) {} |
| 846 }; | 803 }; |
| 847 | 804 |
| 848 template <> struct RunnableMethodTraits<ChromeFrameAutomationClient> { | 805 template <> struct RunnableMethodTraits<ChromeFrameAutomationClient> { |
| 849 void RetainCallee(ChromeFrameAutomationClient* obj) {} | 806 void RetainCallee(ChromeFrameAutomationClient* obj) {} |
| 850 void ReleaseCallee(ChromeFrameAutomationClient* obj) {} | 807 void ReleaseCallee(ChromeFrameAutomationClient* obj) {} |
| 851 }; | 808 }; |
| 852 | 809 |
| 853 // MessageLoopForUI wrapper that runs only for a limited time. | 810 template <> struct RunnableMethodTraits<chrome_frame_test::TimedMsgLoop> { |
| 854 // We need a UI message loop in the main thread. | 811 void RetainCallee(chrome_frame_test::TimedMsgLoop* obj) {} |
| 855 struct TimedMsgLoop { | 812 void ReleaseCallee(chrome_frame_test::TimedMsgLoop* obj) {} |
| 856 public: | |
| 857 void RunFor(int seconds) { | |
| 858 QuitAfter(seconds); | |
| 859 loop_.MessageLoop::Run(); | |
| 860 } | |
| 861 | |
| 862 void PostDelayedTask( | |
| 863 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { | |
| 864 loop_.PostDelayedTask(from_here, task, delay_ms); | |
| 865 } | |
| 866 | |
| 867 void Quit() { | |
| 868 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); | |
| 869 } | |
| 870 | |
| 871 void QuitAfter(int seconds) { | |
| 872 loop_.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, 1000 * seconds); | |
| 873 } | |
| 874 | |
| 875 MessageLoopForUI loop_; | |
| 876 }; | |
| 877 | |
| 878 template <> struct RunnableMethodTraits<TimedMsgLoop> { | |
| 879 void RetainCallee(TimedMsgLoop* obj) {} | |
| 880 void ReleaseCallee(TimedMsgLoop* obj) {} | |
| 881 }; | 813 }; |
| 882 | 814 |
| 883 // Saves typing. It's somewhat hard to create a wrapper around | 815 // Saves typing. It's somewhat hard to create a wrapper around |
| 884 // testing::InvokeWithoutArgs since it returns a | 816 // testing::InvokeWithoutArgs since it returns a |
| 885 // non-public (testing::internal) type. | 817 // non-public (testing::internal) type. |
| 886 #define QUIT_LOOP(loop) testing::InvokeWithoutArgs(\ | 818 #define QUIT_LOOP(loop) testing::InvokeWithoutArgs(\ |
| 887 CreateFunctor(&loop, &TimedMsgLoop::Quit)) | 819 CreateFunctor(&loop, &chrome_frame_test::TimedMsgLoop::Quit)) |
| 888 | 820 |
| 889 #define QUIT_LOOP_SOON(loop, seconds) testing::InvokeWithoutArgs(\ | 821 #define QUIT_LOOP_SOON(loop, seconds) testing::InvokeWithoutArgs(\ |
| 890 CreateFunctor(&loop, &TimedMsgLoop::QuitAfter, seconds)) | 822 CreateFunctor(&loop, &chrome_frame_test::TimedMsgLoop::QuitAfter, \ |
| 823 seconds)) |
| 891 | 824 |
| 892 // We mock ChromeFrameDelegate only. The rest is with real AutomationProxy | 825 // We mock ChromeFrameDelegate only. The rest is with real AutomationProxy |
| 893 TEST(CFACWithChrome, CreateTooFast) { | 826 TEST(CFACWithChrome, CreateTooFast) { |
| 894 MockCFDelegate cfd; | 827 MockCFDelegate cfd; |
| 895 TimedMsgLoop loop; | 828 chrome_frame_test::TimedMsgLoop loop; |
| 896 int timeout = 0; // Chrome cannot send Hello message so fast. | 829 int timeout = 0; // Chrome cannot send Hello message so fast. |
| 897 const std::wstring profile = L"Adam.N.Epilinter"; | 830 const std::wstring profile = L"Adam.N.Epilinter"; |
| 898 | 831 |
| 899 scoped_refptr<ChromeFrameAutomationClient> client; | 832 scoped_refptr<ChromeFrameAutomationClient> client; |
| 900 client = new ChromeFrameAutomationClient(); | 833 client = new ChromeFrameAutomationClient(); |
| 901 | 834 |
| 902 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(AUTOMATION_TIMEOUT, | 835 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(AUTOMATION_TIMEOUT, |
| 903 testing::_)) | 836 testing::_)) |
| 904 .Times(1) | 837 .Times(1) |
| 905 .WillOnce(QUIT_LOOP(loop)); | 838 .WillOnce(QUIT_LOOP(loop)); |
| 906 | 839 |
| 907 EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false)); | 840 EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false)); |
| 908 loop.RunFor(10); | 841 loop.RunFor(10); |
| 909 client->Uninitialize(); | 842 client->Uninitialize(); |
| 910 } | 843 } |
| 911 | 844 |
| 912 // This test may fail if Chrome take more that 10 seconds (timeout var) to | 845 // This test may fail if Chrome take more that 10 seconds (timeout var) to |
| 913 // launch. In this case GMock shall print something like "unexpected call to | 846 // launch. In this case GMock shall print something like "unexpected call to |
| 914 // OnAutomationServerLaunchFailed". I'm yet to find out how to specify | 847 // OnAutomationServerLaunchFailed". I'm yet to find out how to specify |
| 915 // that this is an unexpected call, and still to execute and action. | 848 // that this is an unexpected call, and still to execute and action. |
| 916 TEST(CFACWithChrome, CreateNotSoFast) { | 849 TEST(CFACWithChrome, CreateNotSoFast) { |
| 917 MockCFDelegate cfd; | 850 MockCFDelegate cfd; |
| 918 TimedMsgLoop loop; | 851 chrome_frame_test::TimedMsgLoop loop; |
| 919 const std::wstring profile = L"Adam.N.Epilinter"; | 852 const std::wstring profile = L"Adam.N.Epilinter"; |
| 920 int timeout = 10000; | 853 int timeout = 10000; |
| 921 | 854 |
| 922 scoped_refptr<ChromeFrameAutomationClient> client; | 855 scoped_refptr<ChromeFrameAutomationClient> client; |
| 923 client = new ChromeFrameAutomationClient; | 856 client = new ChromeFrameAutomationClient; |
| 924 | 857 |
| 925 EXPECT_CALL(cfd, OnAutomationServerReady()) | 858 EXPECT_CALL(cfd, OnAutomationServerReady()) |
| 926 .Times(1) | 859 .Times(1) |
| 927 .WillOnce(QUIT_LOOP(loop)); | 860 .WillOnce(QUIT_LOOP(loop)); |
| 928 | 861 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 943 | 876 |
| 944 MATCHER_P(EqNavigationInfoUrl, url, "IPC::NavigationInfo matcher") { | 877 MATCHER_P(EqNavigationInfoUrl, url, "IPC::NavigationInfo matcher") { |
| 945 if (url.is_valid() && url != arg.url) | 878 if (url.is_valid() && url != arg.url) |
| 946 return false; | 879 return false; |
| 947 // TODO(stevet): other members | 880 // TODO(stevet): other members |
| 948 return true; | 881 return true; |
| 949 } | 882 } |
| 950 | 883 |
| 951 TEST(CFACWithChrome, NavigateOk) { | 884 TEST(CFACWithChrome, NavigateOk) { |
| 952 MockCFDelegate cfd; | 885 MockCFDelegate cfd; |
| 953 TimedMsgLoop loop; | 886 chrome_frame_test::TimedMsgLoop loop; |
| 954 const std::wstring profile = L"Adam.N.Epilinter"; | 887 const std::wstring profile = L"Adam.N.Epilinter"; |
| 955 const std::string url = "about:version"; | 888 const std::string url = "about:version"; |
| 956 int timeout = 10000; | 889 int timeout = 10000; |
| 957 | 890 |
| 958 scoped_refptr<ChromeFrameAutomationClient> client; | 891 scoped_refptr<ChromeFrameAutomationClient> client; |
| 959 client = new ChromeFrameAutomationClient; | 892 client = new ChromeFrameAutomationClient; |
| 960 | 893 |
| 961 EXPECT_CALL(cfd, OnAutomationServerReady()) | 894 EXPECT_CALL(cfd, OnAutomationServerReady()) |
| 962 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( | 895 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( |
| 963 client.get(), &ChromeFrameAutomationClient::InitiateNavigation, | 896 client.get(), &ChromeFrameAutomationClient::InitiateNavigation, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 983 | 916 |
| 984 EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false)); | 917 EXPECT_TRUE(client->Initialize(&cfd, timeout, false, profile, L"", false)); |
| 985 loop.RunFor(10); | 918 loop.RunFor(10); |
| 986 client->Uninitialize(); | 919 client->Uninitialize(); |
| 987 client = NULL; | 920 client = NULL; |
| 988 } | 921 } |
| 989 | 922 |
| 990 // Bug: http://b/issue?id=2033644 | 923 // Bug: http://b/issue?id=2033644 |
| 991 TEST(CFACWithChrome, DISABLED_NavigateFailed) { | 924 TEST(CFACWithChrome, DISABLED_NavigateFailed) { |
| 992 MockCFDelegate cfd; | 925 MockCFDelegate cfd; |
| 993 TimedMsgLoop loop; | 926 chrome_frame_test::TimedMsgLoop loop; |
| 994 const std::wstring profile = L"Adam.N.Epilinter"; | 927 const std::wstring profile = L"Adam.N.Epilinter"; |
| 995 const std::string url = "http://127.0.0.3:65412/"; | 928 const std::string url = "http://127.0.0.3:65412/"; |
| 996 int timeout = 10000; | 929 int timeout = 10000; |
| 997 | 930 |
| 998 scoped_refptr<ChromeFrameAutomationClient> client; | 931 scoped_refptr<ChromeFrameAutomationClient> client; |
| 999 client = new ChromeFrameAutomationClient; | 932 client = new ChromeFrameAutomationClient; |
| 1000 | 933 |
| 1001 EXPECT_CALL(cfd, OnAutomationServerReady()) | 934 EXPECT_CALL(cfd, OnAutomationServerReady()) |
| 1002 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( | 935 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( |
| 1003 client.get(), &ChromeFrameAutomationClient::InitiateNavigation, | 936 client.get(), &ChromeFrameAutomationClient::InitiateNavigation, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1034 // we create 'real' TabProxy but with fake AutomationSender (the one responsible | 967 // we create 'real' TabProxy but with fake AutomationSender (the one responsible |
| 1035 // for sending messages over channel). | 968 // for sending messages over channel). |
| 1036 // Additionally we have mock implementation ChromeFrameDelagate interface - | 969 // Additionally we have mock implementation ChromeFrameDelagate interface - |
| 1037 // MockCFDelegate. | 970 // MockCFDelegate. |
| 1038 | 971 |
| 1039 // Test fixture, saves typing all of it's members. | 972 // Test fixture, saves typing all of it's members. |
| 1040 class CFACMockTest : public testing::Test { | 973 class CFACMockTest : public testing::Test { |
| 1041 public: | 974 public: |
| 1042 MockProxyFactory factory_; | 975 MockProxyFactory factory_; |
| 1043 MockCFDelegate cfd_; | 976 MockCFDelegate cfd_; |
| 1044 TimedMsgLoop loop_; | 977 chrome_frame_test::TimedMsgLoop loop_; |
| 1045 MockAutomationProxy proxy_; | 978 MockAutomationProxy proxy_; |
| 1046 scoped_ptr<AutomationHandleTracker> tracker_; | 979 scoped_ptr<AutomationHandleTracker> tracker_; |
| 1047 MockAutomationMessageSender dummy_sender_; | 980 MockAutomationMessageSender dummy_sender_; |
| 1048 scoped_refptr<TabProxy> tab_; | 981 scoped_refptr<TabProxy> tab_; |
| 1049 // the victim of all tests | 982 // the victim of all tests |
| 1050 scoped_refptr<ChromeFrameAutomationClient> client_; | 983 scoped_refptr<ChromeFrameAutomationClient> client_; |
| 1051 | 984 |
| 1052 std::wstring profile_; | 985 std::wstring profile_; |
| 1053 int timeout_; | 986 int timeout_; |
| 1054 void* id_; // Automation server id we are going to return | 987 void* id_; // Automation server id we are going to return |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 const wchar_t kSubFrameTestPage[] = L"files/full_tab_sub_frame_main.html"; | 1131 const wchar_t kSubFrameTestPage[] = L"files/full_tab_sub_frame_main.html"; |
| 1199 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubFrame) { | 1132 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubFrame) { |
| 1200 SimpleBrowserTest(IE, kSubFrameTestPage, L"sub_frame"); | 1133 SimpleBrowserTest(IE, kSubFrameTestPage, L"sub_frame"); |
| 1201 } | 1134 } |
| 1202 | 1135 |
| 1203 const wchar_t kSubIFrameTestPage[] = L"files/full_tab_sub_iframe_main.html"; | 1136 const wchar_t kSubIFrameTestPage[] = L"files/full_tab_sub_iframe_main.html"; |
| 1204 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubIFrame) { | 1137 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SubIFrame) { |
| 1205 SimpleBrowserTest(IE, kSubIFrameTestPage, L"sub_frame"); | 1138 SimpleBrowserTest(IE, kSubIFrameTestPage, L"sub_frame"); |
| 1206 } | 1139 } |
| 1207 | 1140 |
| 1208 HRESULT LaunchIEAsComServer(IWebBrowser2** web_browser) { | |
| 1209 if (!web_browser) | |
| 1210 return E_INVALIDARG; | |
| 1211 | |
| 1212 HRESULT hr = S_OK; | |
| 1213 DWORD cocreate_flags = CLSCTX_LOCAL_SERVER; | |
| 1214 chrome_frame_test::LowIntegrityToken token; | |
| 1215 if (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) { | |
| 1216 // Create medium integrity browser that will launch IE broker. | |
| 1217 ScopedComPtr<IWebBrowser2> medium_integrity_browser; | |
| 1218 hr = medium_integrity_browser.CreateInstance(CLSID_InternetExplorer, NULL, | |
| 1219 CLSCTX_LOCAL_SERVER); | |
| 1220 if (FAILED(hr)) | |
| 1221 return hr; | |
| 1222 medium_integrity_browser->Quit(); | |
| 1223 // Broker remains alive. | |
| 1224 if (!token.Impersonate()) { | |
| 1225 hr = HRESULT_FROM_WIN32(GetLastError()); | |
| 1226 return hr; | |
| 1227 } | |
| 1228 | |
| 1229 cocreate_flags |= CLSCTX_ENABLE_CLOAKING; | |
| 1230 } | |
| 1231 | |
| 1232 hr = ::CoCreateInstance(CLSID_InternetExplorer, NULL, | |
| 1233 cocreate_flags, IID_IWebBrowser2, | |
| 1234 reinterpret_cast<void**>(web_browser)); | |
| 1235 // ~LowIntegrityToken() will switch integrity back to medium. | |
| 1236 return hr; | |
| 1237 } | |
| 1238 | |
| 1239 // WebBrowserEventSink member defines | |
| 1240 void WebBrowserEventSink::Uninitialize() { | |
| 1241 chrome_frame_ = NULL; | |
| 1242 if (web_browser2_.get()) { | |
| 1243 DispEventUnadvise(web_browser2_); | |
| 1244 web_browser2_->Quit(); | |
| 1245 web_browser2_.Release(); | |
| 1246 } | |
| 1247 } | |
| 1248 | |
| 1249 STDMETHODIMP WebBrowserEventSink::OnBeforeNavigate2Internal( | |
| 1250 IDispatch* dispatch, VARIANT* url, VARIANT* flags, | |
| 1251 VARIANT* target_frame_name, VARIANT* post_data, VARIANT* headers, | |
| 1252 VARIANT_BOOL* cancel) { | |
| 1253 DLOG(INFO) << __FUNCTION__; | |
| 1254 // Reset any existing reference to chrome frame since this is a new | |
| 1255 // navigation. | |
| 1256 chrome_frame_ = NULL; | |
| 1257 return OnBeforeNavigate2(dispatch, url, flags, target_frame_name, | |
| 1258 post_data, headers, cancel); | |
| 1259 } | |
| 1260 | |
| 1261 STDMETHODIMP_(void) WebBrowserEventSink::OnNavigateComplete2Internal( | |
| 1262 IDispatch* dispatch, VARIANT* url) { | |
| 1263 DLOG(INFO) << __FUNCTION__; | |
| 1264 ConnectToChromeFrame(); | |
| 1265 OnNavigateComplete2(dispatch, url); | |
| 1266 } | |
| 1267 | |
| 1268 HRESULT WebBrowserEventSink::OnLoadInternal(const VARIANT* param) { | |
| 1269 DLOG(INFO) << __FUNCTION__ << " " << param->bstrVal; | |
| 1270 OnLoad(param->bstrVal); | |
| 1271 return S_OK; | |
| 1272 } | |
| 1273 | |
| 1274 HRESULT WebBrowserEventSink::OnLoadErrorInternal(const VARIANT* param) { | |
| 1275 DLOG(INFO) << __FUNCTION__ << " " << param->bstrVal; | |
| 1276 OnLoadError(param->bstrVal); | |
| 1277 return S_OK; | |
| 1278 } | |
| 1279 | |
| 1280 HRESULT WebBrowserEventSink::OnMessageInternal(const VARIANT* param) { | |
| 1281 DLOG(INFO) << __FUNCTION__ << " " << param->bstrVal; | |
| 1282 OnMessage(param->bstrVal); | |
| 1283 return S_OK; | |
| 1284 } | |
| 1285 | |
| 1286 HRESULT WebBrowserEventSink::LaunchIEAndNavigate( | |
| 1287 const std::wstring& navigate_url) { | |
| 1288 HRESULT hr = LaunchIEAsComServer(web_browser2_.Receive()); | |
| 1289 EXPECT_EQ(S_OK, hr); | |
| 1290 if (hr == S_OK) { | |
| 1291 web_browser2_->put_Visible(VARIANT_TRUE); | |
| 1292 hr = DispEventAdvise(web_browser2_, &DIID_DWebBrowserEvents2); | |
| 1293 EXPECT_TRUE(hr == S_OK); | |
| 1294 hr = Navigate(navigate_url); | |
| 1295 } | |
| 1296 return hr; | |
| 1297 } | |
| 1298 | |
| 1299 HRESULT WebBrowserEventSink::Navigate(const std::wstring& navigate_url) { | |
| 1300 VARIANT empty = ScopedVariant::kEmptyVariant; | |
| 1301 ScopedVariant url; | |
| 1302 url.Set(navigate_url.c_str()); | |
| 1303 | |
| 1304 HRESULT hr = S_OK; | |
| 1305 hr = web_browser2_->Navigate2(url.AsInput(), &empty, &empty, &empty, &empty); | |
| 1306 EXPECT_TRUE(hr == S_OK); | |
| 1307 return hr; | |
| 1308 } | |
| 1309 | |
| 1310 void WebBrowserEventSink::SetFocusToChrome() { | |
| 1311 chrome_frame_test::SetKeyboardFocusToWindow(GetChromeRendererWindow(), 1, 1); | |
| 1312 } | |
| 1313 | |
| 1314 void WebBrowserEventSink::SendInputToChrome( | |
| 1315 const std::string& input_string) { | |
| 1316 chrome_frame_test::SendInputToWindow(GetChromeRendererWindow(), input_string); | |
| 1317 } | |
| 1318 | |
| 1319 void WebBrowserEventSink::ConnectToChromeFrame() { | |
| 1320 DCHECK(web_browser2_); | |
| 1321 ScopedComPtr<IShellBrowser> shell_browser; | |
| 1322 DoQueryService(SID_STopLevelBrowser, web_browser2_, | |
| 1323 shell_browser.Receive()); | |
| 1324 | |
| 1325 if (shell_browser) { | |
| 1326 ScopedComPtr<IShellView> shell_view; | |
| 1327 shell_browser->QueryActiveShellView(shell_view.Receive()); | |
| 1328 if (shell_view) { | |
| 1329 shell_view->GetItemObject(SVGIO_BACKGROUND, __uuidof(IChromeFrame), | |
| 1330 reinterpret_cast<void**>(chrome_frame_.Receive())); | |
| 1331 } | |
| 1332 | |
| 1333 if (chrome_frame_) { | |
| 1334 ScopedVariant onmessage(onmessage_.ToDispatch()); | |
| 1335 ScopedVariant onloaderror(onloaderror_.ToDispatch()); | |
| 1336 ScopedVariant onload(onload_.ToDispatch()); | |
| 1337 EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onmessage(onmessage)); | |
| 1338 EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onloaderror(onloaderror)); | |
| 1339 EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onload(onload)); | |
| 1340 } | |
| 1341 } | |
| 1342 } | |
| 1343 | |
| 1344 HWND WebBrowserEventSink::GetChromeRendererWindow() { | |
| 1345 DCHECK(chrome_frame_); | |
| 1346 HWND renderer_window = NULL; | |
| 1347 ScopedComPtr<IOleWindow> ole_window; | |
| 1348 ole_window.QueryFrom(chrome_frame_); | |
| 1349 EXPECT_TRUE(ole_window.get()); | |
| 1350 | |
| 1351 if (ole_window) { | |
| 1352 HWND activex_window = NULL; | |
| 1353 ole_window->GetWindow(&activex_window); | |
| 1354 EXPECT_TRUE(IsWindow(activex_window)); | |
| 1355 | |
| 1356 // chrome tab window is the first (and the only) child of activex | |
| 1357 HWND chrome_tab_window = GetWindow(activex_window, GW_CHILD); | |
| 1358 EXPECT_TRUE(IsWindow(chrome_tab_window)); | |
| 1359 renderer_window = GetWindow(chrome_tab_window, GW_CHILD); | |
| 1360 } | |
| 1361 | |
| 1362 DCHECK(IsWindow(renderer_window)); | |
| 1363 return renderer_window; | |
| 1364 } | |
| 1365 | |
| 1366 const int kChromeFrameLaunchDelay = 5; | 1141 const int kChromeFrameLaunchDelay = 5; |
| 1367 const int kChromeFrameLongNavigationTimeoutInSeconds = 10; | 1142 const int kChromeFrameLongNavigationTimeoutInSeconds = 10; |
| 1368 | 1143 |
| 1369 // This class provides functionality to add expectations to IE full tab mode | 1144 // This class provides functionality to add expectations to IE full tab mode |
| 1370 // tests. | 1145 // tests. |
| 1371 class MockWebBrowserEventSink : public WebBrowserEventSink { | 1146 class MockWebBrowserEventSink : public chrome_frame_test::WebBrowserEventSink { |
| 1372 public: | 1147 public: |
| 1373 // Needed to support PostTask. | 1148 // Needed to support PostTask. |
| 1374 static bool ImplementsThreadSafeReferenceCounting() { | 1149 static bool ImplementsThreadSafeReferenceCounting() { |
| 1375 return true; | 1150 return true; |
| 1376 } | 1151 } |
| 1377 | 1152 |
| 1378 MOCK_METHOD7_WITH_CALLTYPE(__stdcall, OnBeforeNavigate2, | 1153 MOCK_METHOD7_WITH_CALLTYPE(__stdcall, OnBeforeNavigate2, |
| 1379 HRESULT (IDispatch* dispatch, // NOLINT | 1154 HRESULT (IDispatch* dispatch, // NOLINT |
| 1380 VARIANT* url, | 1155 VARIANT* url, |
| 1381 VARIANT* flags, | 1156 VARIANT* flags, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1405 MOCK_METHOD1(OnLoad, void (const wchar_t* url)); // NOLINT | 1180 MOCK_METHOD1(OnLoad, void (const wchar_t* url)); // NOLINT |
| 1406 MOCK_METHOD1(OnLoadError, void (const wchar_t* url)); // NOLINT | 1181 MOCK_METHOD1(OnLoadError, void (const wchar_t* url)); // NOLINT |
| 1407 MOCK_METHOD1(OnMessage, void (const wchar_t* message)); // NOLINT | 1182 MOCK_METHOD1(OnMessage, void (const wchar_t* message)); // NOLINT |
| 1408 }; | 1183 }; |
| 1409 | 1184 |
| 1410 using testing::_; | 1185 using testing::_; |
| 1411 | 1186 |
| 1412 const wchar_t kChromeFrameFileUrl[] = L"cf:file:///C:/"; | 1187 const wchar_t kChromeFrameFileUrl[] = L"cf:file:///C:/"; |
| 1413 | 1188 |
| 1414 TEST(ChromeFrameTest, FullTabModeIE_DisallowedUrls) { | 1189 TEST(ChromeFrameTest, FullTabModeIE_DisallowedUrls) { |
| 1415 TimedMsgLoop loop; | 1190 chrome_frame_test::TimedMsgLoop loop; |
| 1416 // If a navigation fails then IE issues a navigation to an interstitial | 1191 // If a navigation fails then IE issues a navigation to an interstitial |
| 1417 // page. Catch this to track navigation errors as the NavigateError | 1192 // page. Catch this to track navigation errors as the NavigateError |
| 1418 // notification does not seem to fire reliably. | 1193 // notification does not seem to fire reliably. |
| 1419 CComObjectStackEx<MockWebBrowserEventSink> mock; | 1194 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 1420 | 1195 |
| 1421 EXPECT_CALL(mock, | 1196 EXPECT_CALL(mock, |
| 1422 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1197 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1423 testing::StrCaseEq(kChromeFrameFileUrl)), | 1198 testing::StrCaseEq(kChromeFrameFileUrl)), |
| 1424 _, _, _, _, _)) | 1199 _, _, _, _, _)) |
| 1425 .Times(1) | 1200 .Times(1) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1450 const wchar_t kChromeFrameFullTabWindowOpenTestUrl[] = | 1225 const wchar_t kChromeFrameFullTabWindowOpenTestUrl[] = |
| 1451 L"http://localhost:1337/files/chrome_frame_window_open.html"; | 1226 L"http://localhost:1337/files/chrome_frame_window_open.html"; |
| 1452 | 1227 |
| 1453 const wchar_t kChromeFrameFullTabWindowOpenPopupUrl[] = | 1228 const wchar_t kChromeFrameFullTabWindowOpenPopupUrl[] = |
| 1454 L"http://localhost:1337/files/chrome_frame_window_open_popup.html"; | 1229 L"http://localhost:1337/files/chrome_frame_window_open_popup.html"; |
| 1455 | 1230 |
| 1456 // This test checks if window.open calls issued by a full tab mode ChromeFrame | 1231 // This test checks if window.open calls issued by a full tab mode ChromeFrame |
| 1457 // instance make it back to IE and then transitions back to Chrome as the | 1232 // instance make it back to IE and then transitions back to Chrome as the |
| 1458 // window.open target page is supposed to render within Chrome. | 1233 // window.open target page is supposed to render within Chrome. |
| 1459 TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_WindowOpen) { | 1234 TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_WindowOpen) { |
| 1460 TimedMsgLoop loop; | 1235 chrome_frame_test::TimedMsgLoop loop; |
| 1461 CComObjectStackEx<MockWebBrowserEventSink> mock; | 1236 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 1462 | 1237 |
| 1463 ::testing::InSequence sequence; | 1238 ::testing::InSequence sequence; |
| 1464 EXPECT_CALL(mock, | 1239 EXPECT_CALL(mock, |
| 1465 OnBeforeNavigate2( | 1240 OnBeforeNavigate2( |
| 1466 _, testing::Field(&VARIANT::bstrVal, | 1241 _, testing::Field(&VARIANT::bstrVal, |
| 1467 testing::StrCaseEq(kChromeFrameFullTabWindowOpenTestUrl)), | 1242 testing::StrCaseEq(kChromeFrameFullTabWindowOpenTestUrl)), |
| 1468 _, _, _, _, _)) | 1243 _, _, _, _, _)) |
| 1469 .WillOnce(testing::Return(S_OK)); | 1244 .WillOnce(testing::Return(S_OK)); |
| 1470 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1245 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 // to cf:about:blank. It then looks for the chrome renderer window and posts | 1285 // to cf:about:blank. It then looks for the chrome renderer window and posts |
| 1511 // the WM_RBUTTONDOWN/WM_RBUTTONUP messages to it, which bring up the context | 1286 // the WM_RBUTTONDOWN/WM_RBUTTONUP messages to it, which bring up the context |
| 1512 // menu. This is followed by keyboard messages sent via SendInput to select | 1287 // menu. This is followed by keyboard messages sent via SendInput to select |
| 1513 // the About chrome frame menu option, which would then bring up a new window | 1288 // the About chrome frame menu option, which would then bring up a new window |
| 1514 // with the chrome revision. The test finally checks for success by comparing | 1289 // with the chrome revision. The test finally checks for success by comparing |
| 1515 // the URL of the window being opened with cf:about:version, which indicates | 1290 // the URL of the window being opened with cf:about:version, which indicates |
| 1516 // that the operation succeeded. | 1291 // that the operation succeeded. |
| 1517 // Marking this test FLAKY as it fails at times on the buildbot. | 1292 // Marking this test FLAKY as it fails at times on the buildbot. |
| 1518 // http://code.google.com/p/chromium/issues/detail?id=26549 | 1293 // http://code.google.com/p/chromium/issues/detail?id=26549 |
| 1519 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_AboutChromeFrame) { | 1294 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_AboutChromeFrame) { |
| 1520 TimedMsgLoop loop; | 1295 chrome_frame_test::TimedMsgLoop loop; |
| 1521 CComObjectStackEx<MockWebBrowserEventSink> mock; | 1296 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 1522 | 1297 |
| 1523 EXPECT_CALL(mock, | 1298 EXPECT_CALL(mock, |
| 1524 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1299 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1525 testing::StrCaseEq(kSubFrameUrl1)), | 1300 testing::StrCaseEq(kSubFrameUrl1)), |
| 1526 _, _, _, _, _)) | 1301 _, _, _, _, _)) |
| 1527 .Times(1) | 1302 .Times(1) |
| 1528 .WillOnce(testing::Return(S_OK)); | 1303 .WillOnce(testing::Return(S_OK)); |
| 1529 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1304 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1530 .WillOnce(testing::Return()); | 1305 .WillOnce(testing::Return()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1547 | 1322 |
| 1548 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 1323 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 1549 | 1324 |
| 1550 mock.Uninitialize(); | 1325 mock.Uninitialize(); |
| 1551 chrome_frame_test::CloseAllIEWindows(); | 1326 chrome_frame_test::CloseAllIEWindows(); |
| 1552 } | 1327 } |
| 1553 | 1328 |
| 1554 const wchar_t kChromeFrameFullTabModeKeyEventUrl[] = L"files/keyevent.html"; | 1329 const wchar_t kChromeFrameFullTabModeKeyEventUrl[] = L"files/keyevent.html"; |
| 1555 | 1330 |
| 1556 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameKeyboardTest) { | 1331 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameKeyboardTest) { |
| 1557 TimedMsgLoop loop; | 1332 chrome_frame_test::TimedMsgLoop loop; |
| 1558 | 1333 |
| 1559 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeKeyEventUrl)); | 1334 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeKeyEventUrl)); |
| 1560 | 1335 |
| 1561 // Allow some time for chrome to be launched. | 1336 // Allow some time for chrome to be launched. |
| 1562 loop.RunFor(kChromeFrameLaunchDelay); | 1337 loop.RunFor(kChromeFrameLaunchDelay); |
| 1563 | 1338 |
| 1564 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); | 1339 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); |
| 1565 EXPECT_TRUE(IsWindow(renderer_window)); | 1340 EXPECT_TRUE(IsWindow(renderer_window)); |
| 1566 | 1341 |
| 1567 chrome_frame_test::SetKeyboardFocusToWindow(renderer_window, 1, 1); | 1342 chrome_frame_test::SetKeyboardFocusToWindow(renderer_window, 1, 1); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1583 // not always ideal. For e.g. At the time of mock creation, web_browser2_ | 1358 // not always ideal. For e.g. At the time of mock creation, web_browser2_ |
| 1584 // pointer is not set up yet so by passing a reference to it instead of | 1359 // pointer is not set up yet so by passing a reference to it instead of |
| 1585 // a value we allow it to be created later. | 1360 // a value we allow it to be created later. |
| 1586 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT | 1361 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT |
| 1587 return reinterpret_cast<T**>(&p); | 1362 return reinterpret_cast<T**>(&p); |
| 1588 } | 1363 } |
| 1589 | 1364 |
| 1590 // Full tab mode back/forward test | 1365 // Full tab mode back/forward test |
| 1591 // Launch and navigate chrome frame to a set of URLs and test back forward | 1366 // Launch and navigate chrome frame to a set of URLs and test back forward |
| 1592 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { | 1367 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { |
| 1593 TimedMsgLoop loop; | 1368 chrome_frame_test::TimedMsgLoop loop; |
| 1594 CComObjectStackEx<MockWebBrowserEventSink> mock; | 1369 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 1595 ::testing::InSequence sequence; // Everything in sequence | 1370 ::testing::InSequence sequence; // Everything in sequence |
| 1596 | 1371 |
| 1597 // Navigate to url 2 after the previous navigation is complete | 1372 // Navigate to url 2 after the previous navigation is complete |
| 1598 EXPECT_CALL(mock, | 1373 EXPECT_CALL(mock, |
| 1599 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1374 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1600 testing::StrCaseEq(kSubFrameUrl1)), | 1375 testing::StrCaseEq(kSubFrameUrl1)), |
| 1601 _, _, _, _, _)) | 1376 _, _, _, _, _)) |
| 1602 .WillOnce(testing::Return(S_OK)); | 1377 .WillOnce(testing::Return(S_OK)); |
| 1603 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1378 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1604 .WillOnce(testing::Return()); | 1379 .WillOnce(testing::Return()); |
| 1605 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) | 1380 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) |
| 1606 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( | 1381 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1607 CreateFunctor(&mock, &WebBrowserEventSink::Navigate, | 1382 CreateFunctor( |
| 1608 std::wstring(kSubFrameUrl2))))); | 1383 &mock, &chrome_frame_test::WebBrowserEventSink::Navigate, |
| 1384 std::wstring(kSubFrameUrl2))))); |
| 1609 | 1385 |
| 1610 // Navigate to url 3 after the previous navigation is complete | 1386 // Navigate to url 3 after the previous navigation is complete |
| 1611 EXPECT_CALL(mock, | 1387 EXPECT_CALL(mock, |
| 1612 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1388 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1613 testing::StrCaseEq(kSubFrameUrl2)), | 1389 testing::StrCaseEq(kSubFrameUrl2)), |
| 1614 _, _, _, _, _)) | 1390 _, _, _, _, _)) |
| 1615 .WillOnce(testing::Return(S_OK)); | 1391 .WillOnce(testing::Return(S_OK)); |
| 1616 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1392 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1617 .WillOnce(testing::Return()); | 1393 .WillOnce(testing::Return()); |
| 1618 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl2))) | 1394 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl2))) |
| 1619 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( | 1395 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1620 CreateFunctor(&mock, &WebBrowserEventSink::Navigate, | 1396 CreateFunctor( |
| 1621 std::wstring(kSubFrameUrl3))))); | 1397 &mock, &chrome_frame_test::WebBrowserEventSink::Navigate, |
| 1398 std::wstring(kSubFrameUrl3))))); |
| 1622 | 1399 |
| 1623 // We have reached url 3 and have two back entries for url 1 & 2 | 1400 // We have reached url 3 and have two back entries for url 1 & 2 |
| 1624 // Go back to url 2 now | 1401 // Go back to url 2 now |
| 1625 EXPECT_CALL(mock, | 1402 EXPECT_CALL(mock, |
| 1626 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1403 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1627 testing::StrCaseEq(kSubFrameUrl3)), | 1404 testing::StrCaseEq(kSubFrameUrl3)), |
| 1628 _, _, _, _, _)) | 1405 _, _, _, _, _)) |
| 1629 .WillOnce(testing::Return(S_OK)); | 1406 .WillOnce(testing::Return(S_OK)); |
| 1630 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1407 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1631 .WillOnce(testing::Return()); | 1408 .WillOnce(testing::Return()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1652 // Go back to url 1 now | 1429 // Go back to url 1 now |
| 1653 EXPECT_CALL(mock, | 1430 EXPECT_CALL(mock, |
| 1654 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1431 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1655 testing::StrCaseEq(kSubFrameUrl1)), | 1432 testing::StrCaseEq(kSubFrameUrl1)), |
| 1656 _, _, _, _, _)); | 1433 _, _, _, _, _)); |
| 1657 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1434 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1658 .WillOnce(testing::Return()); | 1435 .WillOnce(testing::Return()); |
| 1659 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) | 1436 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) |
| 1660 .WillOnce(testing::DoAll( | 1437 .WillOnce(testing::DoAll( |
| 1661 testing::InvokeWithoutArgs(CreateFunctor(&mock, | 1438 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 1662 &WebBrowserEventSink::Uninitialize)), | 1439 &chrome_frame_test::WebBrowserEventSink::Uninitialize)), |
| 1663 testing::IgnoreResult(testing::InvokeWithoutArgs( | 1440 testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1664 &chrome_frame_test::CloseAllIEWindows)), | 1441 &chrome_frame_test::CloseAllIEWindows)), |
| 1665 QUIT_LOOP_SOON(loop, 2))); | 1442 QUIT_LOOP_SOON(loop, 2))); |
| 1666 | 1443 |
| 1667 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | 1444 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); |
| 1668 ASSERT_HRESULT_SUCCEEDED(hr); | 1445 ASSERT_HRESULT_SUCCEEDED(hr); |
| 1669 if (hr == S_FALSE) | 1446 if (hr == S_FALSE) |
| 1670 return; | 1447 return; |
| 1671 | 1448 |
| 1672 ASSERT_TRUE(mock.web_browser2() != NULL); | 1449 ASSERT_TRUE(mock.web_browser2() != NULL); |
| 1673 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 1450 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 1451 mock.Uninitialize(); |
| 1452 chrome_frame_test::CloseAllIEWindows(); |
| 1674 } | 1453 } |
| 1675 | 1454 |
| 1676 | 1455 |
| 1677 const wchar_t kChromeFrameAboutBlankUrl[] = L"cf:about:blank"; | 1456 const wchar_t kChromeFrameAboutBlankUrl[] = L"cf:about:blank"; |
| 1678 | 1457 |
| 1679 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameFocusTest) { | 1458 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameFocusTest) { |
| 1680 TimedMsgLoop loop; | 1459 chrome_frame_test::TimedMsgLoop loop; |
| 1681 | 1460 |
| 1682 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameAboutBlankUrl)); | 1461 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameAboutBlankUrl)); |
| 1683 | 1462 |
| 1684 // Allow some time for chrome to be launched. | 1463 // Allow some time for chrome to be launched. |
| 1685 loop.RunFor(kChromeFrameLaunchDelay); | 1464 loop.RunFor(kChromeFrameLaunchDelay); |
| 1686 | 1465 |
| 1687 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); | 1466 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); |
| 1688 EXPECT_TRUE(IsWindow(renderer_window)); | 1467 EXPECT_TRUE(IsWindow(renderer_window)); |
| 1689 | 1468 |
| 1690 DWORD renderer_thread_id = 0; | 1469 DWORD renderer_thread_id = 0; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1703 const wchar_t kAnchorUrl[] = L"http://localhost:1337/files/anchor.html"; | 1482 const wchar_t kAnchorUrl[] = L"http://localhost:1337/files/anchor.html"; |
| 1704 const wchar_t kAnchor1Url[] = L"http://localhost:1337/files/anchor.html#a1"; | 1483 const wchar_t kAnchor1Url[] = L"http://localhost:1337/files/anchor.html#a1"; |
| 1705 const wchar_t kAnchor2Url[] = L"http://localhost:1337/files/anchor.html#a2"; | 1484 const wchar_t kAnchor2Url[] = L"http://localhost:1337/files/anchor.html#a2"; |
| 1706 const wchar_t kAnchor3Url[] = L"http://localhost:1337/files/anchor.html#a3"; | 1485 const wchar_t kAnchor3Url[] = L"http://localhost:1337/files/anchor.html#a3"; |
| 1707 | 1486 |
| 1708 // Full tab mode back/forward test | 1487 // Full tab mode back/forward test |
| 1709 // Launch and navigate chrome frame to a set of URLs and test back forward | 1488 // Launch and navigate chrome frame to a set of URLs and test back forward |
| 1710 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForwardAnchor) { | 1489 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForwardAnchor) { |
| 1711 const char tab_enter_keystrokes[] = { VK_TAB, VK_RETURN, 0 }; | 1490 const char tab_enter_keystrokes[] = { VK_TAB, VK_RETURN, 0 }; |
| 1712 static const std::string tab_enter(tab_enter_keystrokes); | 1491 static const std::string tab_enter(tab_enter_keystrokes); |
| 1713 TimedMsgLoop loop; | 1492 chrome_frame_test::TimedMsgLoop loop; |
| 1714 CComObjectStackEx<MockWebBrowserEventSink> mock; | 1493 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 1715 ::testing::InSequence sequence; // Everything in sequence | 1494 ::testing::InSequence sequence; // Everything in sequence |
| 1716 | 1495 |
| 1717 // Back/Forward state at this point: | 1496 // Back/Forward state at this point: |
| 1718 // Back: 0 | 1497 // Back: 0 |
| 1719 // Forward: 0 | 1498 // Forward: 0 |
| 1720 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1499 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1721 testing::StrCaseEq(kAnchorUrl)), | 1500 testing::StrCaseEq(kAnchorUrl)), |
| 1722 _, _, _, _, _)) | 1501 _, _, _, _, _)) |
| 1723 .WillOnce(testing::Return(S_OK)); | 1502 .WillOnce(testing::Return(S_OK)); |
| 1724 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1503 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1725 .WillOnce(testing::Return()); | 1504 .WillOnce(testing::Return()); |
| 1726 | 1505 |
| 1727 // Navigate to anchor 1: | 1506 // Navigate to anchor 1: |
| 1728 // - First set focus to chrome renderer window | 1507 // - First set focus to chrome renderer window |
| 1729 // Call WebBrowserEventSink::SetFocusToChrome only once | 1508 // Call WebBrowserEventSink::SetFocusToChrome only once |
| 1730 // in the beginning. Calling it again will change focus from the | 1509 // in the beginning. Calling it again will change focus from the |
| 1731 // current location to an element near the simulated mouse.click. | 1510 // current location to an element near the simulated mouse.click. |
| 1732 // - Then send keyboard input of TAB + ENTER to cause navigation. | 1511 // - Then send keyboard input of TAB + ENTER to cause navigation. |
| 1733 // It's better to send input as PostDelayedTask since the Activex | 1512 // It's better to send input as PostDelayedTask since the Activex |
| 1734 // message loop on the other side might be blocked when we get | 1513 // message loop on the other side might be blocked when we get |
| 1735 // called in Onload. | 1514 // called in Onload. |
| 1736 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchorUrl))) | 1515 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchorUrl))) |
| 1737 .WillOnce(testing::DoAll( | 1516 .WillOnce(testing::DoAll( |
| 1738 testing::InvokeWithoutArgs(CreateFunctor(&mock, | 1517 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 1739 &WebBrowserEventSink::SetFocusToChrome)), | 1518 &chrome_frame_test::WebBrowserEventSink::SetFocusToChrome)), |
| 1740 testing::InvokeWithoutArgs(CreateFunctor(&loop, | 1519 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 1741 &TimedMsgLoop::PostDelayedTask, FROM_HERE, NewRunnableMethod( | 1520 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 1742 &mock, &WebBrowserEventSink::SendInputToChrome, | 1521 NewRunnableMethod( |
| 1522 &mock, |
| 1523 &chrome_frame_test::WebBrowserEventSink::SendInputToChrome, |
| 1743 std::string(tab_enter)), 0)))); | 1524 std::string(tab_enter)), 0)))); |
| 1744 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1525 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1745 testing::StrCaseEq(kAnchor1Url)), | 1526 testing::StrCaseEq(kAnchor1Url)), |
| 1746 _, _, _, _, _)) | 1527 _, _, _, _, _)) |
| 1747 .WillOnce(testing::Return(S_OK)); | 1528 .WillOnce(testing::Return(S_OK)); |
| 1748 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1529 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1749 .WillOnce(testing::Return()); | 1530 .WillOnce(testing::Return()); |
| 1750 | 1531 |
| 1751 // Navigate to anchor 2 after the previous navigation is complete | 1532 // Navigate to anchor 2 after the previous navigation is complete |
| 1752 // Back/Forward state at this point: | 1533 // Back/Forward state at this point: |
| 1753 // Back: 1 (kAnchorUrl) | 1534 // Back: 1 (kAnchorUrl) |
| 1754 // Forward: 0 | 1535 // Forward: 0 |
| 1755 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor1Url))) | 1536 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor1Url))) |
| 1756 .WillOnce(testing::InvokeWithoutArgs( | 1537 .WillOnce(testing::InvokeWithoutArgs( |
| 1757 CreateFunctor(&loop, &TimedMsgLoop::PostDelayedTask, FROM_HERE, | 1538 CreateFunctor( |
| 1758 NewRunnableMethod(&mock, &WebBrowserEventSink::SendInputToChrome, | 1539 &loop, &chrome_frame_test::TimedMsgLoop::PostDelayedTask, |
| 1540 FROM_HERE, |
| 1541 NewRunnableMethod( |
| 1542 &mock, |
| 1543 &chrome_frame_test::WebBrowserEventSink::SendInputToChrome, |
| 1759 std::string(tab_enter)), 0))); | 1544 std::string(tab_enter)), 0))); |
| 1760 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1545 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1761 testing::StrCaseEq(kAnchor2Url)), | 1546 testing::StrCaseEq(kAnchor2Url)), |
| 1762 _, _, _, _, _)) | 1547 _, _, _, _, _)) |
| 1763 .WillOnce(testing::Return(S_OK)); | 1548 .WillOnce(testing::Return(S_OK)); |
| 1764 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1549 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1765 .WillOnce(testing::Return()); | 1550 .WillOnce(testing::Return()); |
| 1766 | 1551 |
| 1767 // Navigate to anchor 3 after the previous navigation is complete | 1552 // Navigate to anchor 3 after the previous navigation is complete |
| 1768 // Back/Forward state at this point: | 1553 // Back/Forward state at this point: |
| 1769 // Back: 2 (kAnchorUrl, kAnchor1Url) | 1554 // Back: 2 (kAnchorUrl, kAnchor1Url) |
| 1770 // Forward: 0 | 1555 // Forward: 0 |
| 1771 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor2Url))) | 1556 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor2Url))) |
| 1772 .WillOnce(testing::InvokeWithoutArgs( | 1557 .WillOnce(testing::InvokeWithoutArgs( |
| 1773 CreateFunctor(&loop, &TimedMsgLoop::PostDelayedTask, FROM_HERE, | 1558 CreateFunctor( |
| 1774 NewRunnableMethod(&mock, &WebBrowserEventSink::SendInputToChrome, | 1559 &loop, &chrome_frame_test::TimedMsgLoop::PostDelayedTask, |
| 1560 FROM_HERE, |
| 1561 NewRunnableMethod( |
| 1562 &mock, |
| 1563 &chrome_frame_test::WebBrowserEventSink::SendInputToChrome, |
| 1775 std::string(tab_enter)), 0))); | 1564 std::string(tab_enter)), 0))); |
| 1776 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1565 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1777 testing::StrCaseEq(kAnchor3Url)), | 1566 testing::StrCaseEq(kAnchor3Url)), |
| 1778 _, _, _, _, _)) | 1567 _, _, _, _, _)) |
| 1779 .WillOnce(testing::Return(S_OK)); | 1568 .WillOnce(testing::Return(S_OK)); |
| 1780 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1569 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1781 .WillOnce(testing::Return()); | 1570 .WillOnce(testing::Return()); |
| 1782 | 1571 |
| 1783 // We will reach anchor 3 once the navigation is complete, | 1572 // We will reach anchor 3 once the navigation is complete, |
| 1784 // then go back to anchor 2 | 1573 // then go back to anchor 2 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1840 testing::StrCaseEq(kAnchor3Url)), | 1629 testing::StrCaseEq(kAnchor3Url)), |
| 1841 _, _, _, _, _)) | 1630 _, _, _, _, _)) |
| 1842 .WillOnce(testing::Return(S_OK)); | 1631 .WillOnce(testing::Return(S_OK)); |
| 1843 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1632 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1844 .WillOnce(testing::Return()); | 1633 .WillOnce(testing::Return()); |
| 1845 | 1634 |
| 1846 // We have gone a few steps back and forward, this should be enough for now. | 1635 // We have gone a few steps back and forward, this should be enough for now. |
| 1847 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor3Url))) | 1636 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor3Url))) |
| 1848 .WillOnce(testing::DoAll( | 1637 .WillOnce(testing::DoAll( |
| 1849 testing::InvokeWithoutArgs(CreateFunctor(&mock, | 1638 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 1850 &WebBrowserEventSink::Uninitialize)), | 1639 &chrome_frame_test::WebBrowserEventSink::Uninitialize)), |
| 1851 testing::IgnoreResult(testing::InvokeWithoutArgs( | 1640 testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1852 &chrome_frame_test::CloseAllIEWindows)), | 1641 &chrome_frame_test::CloseAllIEWindows)), |
| 1853 QUIT_LOOP_SOON(loop, 2))); | 1642 QUIT_LOOP_SOON(loop, 2))); |
| 1854 | 1643 |
| 1855 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); | 1644 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); |
| 1856 ASSERT_HRESULT_SUCCEEDED(hr); | 1645 ASSERT_HRESULT_SUCCEEDED(hr); |
| 1857 if (hr == S_FALSE) | 1646 if (hr == S_FALSE) |
| 1858 return; | 1647 return; |
| 1859 | 1648 |
| 1860 ASSERT_TRUE(mock.web_browser2() != NULL); | 1649 ASSERT_TRUE(mock.web_browser2() != NULL); |
| 1861 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 1650 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 1651 mock.Uninitialize(); |
| 1652 chrome_frame_test::CloseAllIEWindows(); |
| 1862 } | 1653 } |
| OLD | NEW |