OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 "chrome_frame/test/test_mock_with_web_server.h" | 4 #include "chrome_frame/test/test_mock_with_web_server.h" |
5 | 5 |
6 #include <mshtmcid.h> | 6 #include <mshtmcid.h> |
7 | 7 |
8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
9 #include "chrome_frame/utils.h" | 9 #include "chrome_frame/utils.h" |
10 #include "chrome_frame/test/test_with_web_server.h" | 10 #include "chrome_frame/test/test_with_web_server.h" |
11 | 11 |
12 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING | 12 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING |
13 #include "testing/gmock_mutant.h" | 13 #include "testing/gmock_mutant.h" |
14 | 14 |
15 using testing::CreateFunctor; | 15 using testing::CreateFunctor; |
16 using testing::_; | 16 using testing::_; |
17 | 17 |
18 const int kChromeFrameLaunchDelay = 5; | 18 const int kChromeFrameLaunchDelay = 5; |
19 const int kChromeFrameLongNavigationTimeoutInSeconds = 10; | 19 const int kChromeFrameLongNavigationTimeoutInSeconds = 10; |
20 | 20 |
21 const wchar_t kChromeFrameFileUrl[] = L"gcf:file:///C:/"; | 21 const wchar_t kChromeFrameFileUrl[] = L"gcf:file:///C:/"; |
| 22 const wchar_t enter_key[] = { VK_RETURN, 0 }; |
| 23 const wchar_t tab_enter_keys[] = { VK_TAB, VK_RETURN, 0 }; |
22 | 24 |
23 TEST(ChromeFrameTest, FullTabModeIE_DisallowedUrls) { | 25 TEST(ChromeFrameTest, FullTabModeIE_DisallowedUrls) { |
24 chrome_frame_test::TimedMsgLoop loop; | 26 chrome_frame_test::TimedMsgLoop loop; |
25 // If a navigation fails then IE issues a navigation to an interstitial | 27 // If a navigation fails then IE issues a navigation to an interstitial |
26 // page. Catch this to track navigation errors as the NavigateError | 28 // page. Catch this to track navigation errors as the NavigateError |
27 // notification does not seem to fire reliably. | 29 // notification does not seem to fire reliably. |
28 CComObjectStackEx<MockWebBrowserEventSink> mock; | 30 CComObjectStackEx<MockWebBrowserEventSink> mock; |
29 | 31 |
30 EXPECT_CALL(mock, | 32 EXPECT_CALL(mock, |
31 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 33 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
(...skipping 17 matching lines...) Expand all Loading... |
49 return; | 51 return; |
50 | 52 |
51 ASSERT_TRUE(mock.web_browser2() != NULL); | 53 ASSERT_TRUE(mock.web_browser2() != NULL); |
52 | 54 |
53 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 55 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
54 | 56 |
55 mock.Uninitialize(); | 57 mock.Uninitialize(); |
56 chrome_frame_test::CloseAllIEWindows(); | 58 chrome_frame_test::CloseAllIEWindows(); |
57 } | 59 } |
58 | 60 |
59 const wchar_t kChromeFrameFullTabWindowOpenTestUrl[] = | 61 const wchar_t kKeyEventUrl[] = L"http://localhost:1337/files/keyevent.html"; |
| 62 |
| 63 // Marking this test FLAKY as it fails at times on the buildbot. |
| 64 // http://code.google.com/p/chromium/issues/detail?id=26549 |
| 65 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_KeyboardTest) { |
| 66 chrome_frame_test::TimedMsgLoop loop; |
| 67 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 68 |
| 69 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 70 testing::StrCaseEq(kKeyEventUrl)), |
| 71 _, _, _, _, _)) |
| 72 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 73 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 74 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
| 75 |
| 76 const wchar_t* input = L"Chrome"; |
| 77 EXPECT_CALL(mock, OnLoad(testing::StrEq(kKeyEventUrl))) |
| 78 .WillOnce(testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 79 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 80 NewRunnableMethod( |
| 81 &mock, |
| 82 &MockWebBrowserEventSink::SendKeys, input), 500))); |
| 83 |
| 84 EXPECT_CALL(mock, OnMessage(testing::StrEq(input), _, _)) |
| 85 .WillOnce(QUIT_LOOP(loop)); |
| 86 |
| 87 HRESULT hr = mock.LaunchIEAndNavigate(kKeyEventUrl); |
| 88 ASSERT_HRESULT_SUCCEEDED(hr); |
| 89 if (hr == S_FALSE) |
| 90 return; |
| 91 |
| 92 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 93 |
| 94 mock.Uninitialize(); |
| 95 chrome_frame_test::CloseAllIEWindows(); |
| 96 } |
| 97 |
| 98 const wchar_t kAboutVersionUrl[] = L"gcf:about:version"; |
| 99 const wchar_t kAboutVersion[] = L"about:version"; |
| 100 |
| 101 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_FocusTest) { |
| 102 chrome_frame_test::TimedMsgLoop loop; |
| 103 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 104 |
| 105 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 106 testing::StrCaseEq(kAboutVersionUrl)), |
| 107 _, _, _, _, _)) |
| 108 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 109 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 110 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
| 111 |
| 112 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAboutVersion))) |
| 113 .WillOnce(testing::DoAll( |
| 114 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 115 &MockWebBrowserEventSink::ExpectRendererWindowHasfocus)), |
| 116 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 117 &MockWebBrowserEventSink::Uninitialize)), |
| 118 testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 119 &chrome_frame_test::CloseAllIEWindows)), |
| 120 QUIT_LOOP_SOON(loop, 2))); |
| 121 |
| 122 HRESULT hr = mock.LaunchIEAndNavigate(kAboutVersionUrl); |
| 123 |
| 124 // Allow some time for chrome to be launched. |
| 125 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 126 |
| 127 mock.Uninitialize(); |
| 128 chrome_frame_test::CloseAllIEWindows(); |
| 129 } |
| 130 |
| 131 const wchar_t kFullTabWindowOpenTestUrl[] = |
60 L"http://localhost:1337/files/chrome_frame_window_open.html"; | 132 L"http://localhost:1337/files/chrome_frame_window_open.html"; |
61 | 133 |
62 const wchar_t kChromeFrameFullTabWindowOpenPopupUrl[] = | 134 const wchar_t kFullTabWindowOpenPopupUrl[] = |
63 L"http://localhost:1337/files/chrome_frame_window_open_popup.html"; | 135 L"http://localhost:1337/files/chrome_frame_window_open_popup.html"; |
64 | 136 |
65 // This test checks if window.open calls issued by a full tab mode ChromeFrame | 137 // This test checks if window.open calls issued by a full tab mode ChromeFrame |
66 // instance make it back to IE and then transitions back to Chrome as the | 138 // instance make it back to IE and then transitions back to Chrome as the |
67 // window.open target page is supposed to render within Chrome. | 139 // window.open target page is supposed to render within Chrome. |
68 // Marking this test as FLAKY initially as it relies on getting focus and user | 140 // Marking this test as FLAKY initially as it relies on getting focus and user |
69 // input which don't work correctly at times. | 141 // input which don't work correctly at times. |
70 // http://code.google.com/p/chromium/issues/detail?id=26549 | 142 // http://code.google.com/p/chromium/issues/detail?id=26549 |
71 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_WindowOpenInChrome) { | 143 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_WindowOpenInChrome) { |
72 chrome_frame_test::TimedMsgLoop loop; | 144 chrome_frame_test::TimedMsgLoop loop; |
73 CComObjectStackEx<MockWebBrowserEventSink> mock; | 145 CComObjectStackEx<MockWebBrowserEventSink> mock; |
74 | 146 |
75 // NOTE: | 147 // NOTE: |
76 // Intentionally not in sequence since we have just one navigation | 148 // Intentionally not in sequence since we have just one navigation |
77 // per mock, it's OK to be not in sequence as long as all the expections | 149 // per mock, it's OK to be not in sequence as long as all the expections |
78 // are satisfied. Moreover, since the second mock expects a new window, | 150 // are satisfied. Moreover, since the second mock expects a new window, |
79 // its events happen in random order. | 151 // its events happen in random order. |
80 EXPECT_CALL(mock, | 152 EXPECT_CALL(mock, |
81 OnBeforeNavigate2( | 153 OnBeforeNavigate2( |
82 _, testing::Field(&VARIANT::bstrVal, | 154 _, testing::Field(&VARIANT::bstrVal, |
83 testing::StrCaseEq(kChromeFrameFullTabWindowOpenTestUrl)), | 155 testing::StrCaseEq(kFullTabWindowOpenTestUrl)), |
84 _, _, _, _, _)) | 156 _, _, _, _, _)) |
85 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); | 157 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
86 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 158 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
87 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); | 159 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
88 | 160 |
| 161 const wchar_t* input = L"A"; |
89 EXPECT_CALL(mock, | 162 EXPECT_CALL(mock, |
90 OnLoad(testing::StrEq(kChromeFrameFullTabWindowOpenTestUrl))) | 163 OnLoad(testing::StrEq(kFullTabWindowOpenTestUrl))) |
91 .WillOnce(testing::DoAll( | 164 .WillOnce(testing::InvokeWithoutArgs(CreateFunctor(&loop, |
92 testing::InvokeWithoutArgs(CreateFunctor(&mock, | 165 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
93 &chrome_frame_test::WebBrowserEventSink::SetFocusToChrome)), | 166 NewRunnableMethod( |
94 testing::InvokeWithoutArgs(CreateFunctor(&loop, | 167 &mock, &MockWebBrowserEventSink::SendKeys, input), 500))); |
95 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, | |
96 NewRunnableMethod( | |
97 &mock, | |
98 &chrome_frame_test::WebBrowserEventSink::SendInputToChrome, | |
99 std::string("A")), 0)))); | |
100 | 168 |
101 // Watch for new window | 169 // Watch for new window |
102 CComObjectStackEx<MockWebBrowserEventSink> new_window_mock; | 170 CComObjectStackEx<MockWebBrowserEventSink> new_window_mock; |
103 // Can't really check URL here since it will be of the form gcf:attach... | 171 // Can't really check URL here since it will be of the form gcf:attach... |
104 EXPECT_CALL(mock, OnNewWindow3(_, _, _, _, _)); | 172 EXPECT_CALL(mock, OnNewWindow3(_, _, _, _, _)); |
105 EXPECT_CALL(mock, OnNewBrowserWindow(_, _)) | 173 EXPECT_CALL(mock, OnNewBrowserWindow(_, _)) |
106 .WillOnce(testing::WithArgs<0>( | 174 .WillOnce(testing::WithArgs<0>( |
107 testing::Invoke(CreateFunctor(&new_window_mock, | 175 testing::Invoke(CreateFunctor(&new_window_mock, |
108 &MockWebBrowserEventSink::Attach)))); | 176 &MockWebBrowserEventSink::Attach)))); |
109 | 177 |
110 // Expect navigations on the new mock | 178 // Expect navigations on the new mock |
111 EXPECT_CALL(new_window_mock, OnBeforeNavigate2(_, _, _, _, _, _, _)) | 179 EXPECT_CALL(new_window_mock, OnBeforeNavigate2(_, _, _, _, _, _, _)) |
112 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); | 180 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
113 EXPECT_CALL(new_window_mock, OnNavigateComplete2(_, _)) | 181 EXPECT_CALL(new_window_mock, OnNavigateComplete2(_, _)) |
114 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); | 182 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
115 EXPECT_CALL(new_window_mock, | 183 EXPECT_CALL(new_window_mock, |
116 OnLoad(testing::StrEq(kChromeFrameFullTabWindowOpenPopupUrl))) | 184 OnLoad(testing::StrEq(kFullTabWindowOpenPopupUrl))) |
117 .WillOnce(testing::DoAll( | 185 .WillOnce(testing::DoAll( |
118 testing::InvokeWithoutArgs(CreateFunctor(&mock, | 186 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
119 &MockWebBrowserEventSink::Uninitialize)), | 187 &MockWebBrowserEventSink::Uninitialize)), |
120 testing::InvokeWithoutArgs(CreateFunctor(&new_window_mock, | 188 testing::InvokeWithoutArgs(CreateFunctor(&new_window_mock, |
121 &MockWebBrowserEventSink::Uninitialize)), | 189 &MockWebBrowserEventSink::Uninitialize)), |
122 testing::IgnoreResult(testing::InvokeWithoutArgs( | 190 testing::IgnoreResult(testing::InvokeWithoutArgs( |
123 &chrome_frame_test::CloseAllIEWindows)), | 191 &chrome_frame_test::CloseAllIEWindows)), |
124 QUIT_LOOP_SOON(loop, 2))); | 192 QUIT_LOOP_SOON(loop, 2))); |
125 | 193 |
126 HRESULT hr = mock.LaunchIEAndNavigate(kChromeFrameFullTabWindowOpenTestUrl); | 194 HRESULT hr = mock.LaunchIEAndNavigate(kFullTabWindowOpenTestUrl); |
127 ASSERT_HRESULT_SUCCEEDED(hr); | 195 ASSERT_HRESULT_SUCCEEDED(hr); |
128 if (hr == S_FALSE) | 196 if (hr == S_FALSE) |
129 return; | 197 return; |
130 | 198 |
131 ASSERT_TRUE(mock.web_browser2() != NULL); | 199 ASSERT_TRUE(mock.web_browser2() != NULL); |
132 | 200 |
133 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 201 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
134 | 202 |
135 mock.Uninitialize(); | 203 mock.Uninitialize(); |
136 chrome_frame_test::CloseAllIEWindows(); | 204 chrome_frame_test::CloseAllIEWindows(); |
137 ASSERT_TRUE(CheckResultFile(L"ChromeFrameWindowOpenPopup", "OK")); | |
138 } | 205 } |
139 | 206 |
140 const wchar_t kSubFrameUrl1[] = | 207 const wchar_t kSubFrameUrl1[] = |
141 L"http://localhost:1337/files/sub_frame1.html"; | 208 L"http://localhost:1337/files/sub_frame1.html"; |
142 | 209 |
143 const wchar_t kChromeFrameAboutVersion[] = | |
144 L"gcf:about:version"; | |
145 | |
146 // This test launches chrome frame in full tab mode in IE by having IE navigate | 210 // This test launches chrome frame in full tab mode in IE by having IE navigate |
147 // to gcf:about:blank. It then looks for the chrome renderer window and posts | 211 // to a url. It then looks for the chrome renderer window and posts |
148 // the WM_RBUTTONDOWN/WM_RBUTTONUP messages to it, which bring up the context | 212 // the WM_RBUTTONDOWN/WM_RBUTTONUP messages to it, which bring up the context |
149 // menu. This is followed by keyboard messages sent via SendInput to select | 213 // menu. This is followed by keyboard messages sent via SendInput to select |
150 // the About chrome frame menu option, which would then bring up a new window | 214 // the About chrome frame menu option, which would then bring up a new window |
151 // with the chrome revision. The test finally checks for success by comparing | 215 // with the chrome revision. The test finally checks for success by comparing |
152 // the URL of the window being opened with cf:about:version, which indicates | 216 // the URL of the window being opened with cf:about:version, which indicates |
153 // that the operation succeeded. | 217 // that the operation succeeded. |
154 // Marking this test FLAKY as it fails at times on the buildbot. | 218 // Marking this test FLAKY as it fails at times on the buildbot. |
155 // http://code.google.com/p/chromium/issues/detail?id=26549 | 219 // http://code.google.com/p/chromium/issues/detail?id=26549 |
156 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_AboutChromeFrame) { | 220 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_AboutChromeFrame) { |
157 chrome_frame_test::TimedMsgLoop loop; | 221 chrome_frame_test::TimedMsgLoop loop; |
158 CComObjectStackEx<MockWebBrowserEventSink> mock; | 222 CComObjectStackEx<MockWebBrowserEventSink> mock; |
159 | 223 |
160 EXPECT_CALL(mock, | 224 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
161 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | |
162 testing::StrCaseEq(kSubFrameUrl1)), | 225 testing::StrCaseEq(kSubFrameUrl1)), |
163 _, _, _, _, _)) | 226 _, _, _, _, _)) |
164 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); | 227 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
165 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 228 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
166 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); | 229 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
167 | 230 |
168 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) | 231 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) |
169 .WillOnce(testing::InvokeWithoutArgs( | 232 .WillOnce(testing::DoAll( |
170 &chrome_frame_test::ShowChromeFrameContextMenu)); | 233 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 234 &MockWebBrowserEventSink::SendMouseClick, 10, 10, |
| 235 simulate_input::RIGHT)), |
| 236 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 237 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 238 NewRunnableFunction( |
| 239 simulate_input::SendExtendedKey, VK_UP, false, false, false), |
| 240 500)), |
| 241 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 242 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 243 NewRunnableFunction( |
| 244 simulate_input::SendString<wchar_t>, &enter_key[0]), |
| 245 600)))); |
171 | 246 |
172 EXPECT_CALL(mock, | 247 // Watch for new window |
173 OnNewWindow3(_, _, _, _, | 248 CComObjectStackEx<MockWebBrowserEventSink> new_window_mock; |
174 testing::StrCaseEq(kChromeFrameAboutVersion))) | 249 EXPECT_CALL(mock, OnNewWindow3(_, _, _, _, |
175 .WillOnce(QUIT_LOOP(loop)); | 250 testing::StrCaseEq(kAboutVersionUrl))); |
| 251 EXPECT_CALL(mock, OnNewBrowserWindow(_, _)) |
| 252 .WillOnce(testing::WithArgs<0>( |
| 253 testing::Invoke(CreateFunctor(&new_window_mock, |
| 254 &MockWebBrowserEventSink::Attach)))); |
| 255 |
| 256 // Expect navigations on the new mock |
| 257 EXPECT_CALL(new_window_mock, OnBeforeNavigate2(_, _, _, _, _, _, _)) |
| 258 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 259 EXPECT_CALL(new_window_mock, OnNavigateComplete2(_, _)) |
| 260 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
| 261 EXPECT_CALL(new_window_mock, OnLoad(testing::StrEq(kAboutVersion))) |
| 262 .WillOnce(testing::DoAll( |
| 263 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 264 &MockWebBrowserEventSink::Uninitialize)), |
| 265 testing::InvokeWithoutArgs(CreateFunctor(&new_window_mock, |
| 266 &MockWebBrowserEventSink::Uninitialize)), |
| 267 testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 268 &chrome_frame_test::CloseAllIEWindows)), |
| 269 QUIT_LOOP_SOON(loop, 2))); |
176 | 270 |
177 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | 271 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); |
178 ASSERT_HRESULT_SUCCEEDED(hr); | 272 ASSERT_HRESULT_SUCCEEDED(hr); |
179 if (hr == S_FALSE) | 273 if (hr == S_FALSE) |
180 return; | 274 return; |
181 | 275 |
182 ASSERT_TRUE(mock.web_browser2() != NULL); | 276 ASSERT_TRUE(mock.web_browser2() != NULL); |
183 | |
184 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 277 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
185 | 278 |
186 mock.Uninitialize(); | 279 mock.Uninitialize(); |
187 chrome_frame_test::CloseAllIEWindows(); | 280 chrome_frame_test::CloseAllIEWindows(); |
188 } | 281 } |
189 | 282 |
190 const wchar_t kSubFrameUrl2[] = | 283 const wchar_t kSubFrameUrl2[] = |
191 L"http://localhost:1337/files/sub_frame2.html"; | 284 L"http://localhost:1337/files/sub_frame2.html"; |
192 const wchar_t kSubFrameUrl3[] = | 285 const wchar_t kSubFrameUrl3[] = |
193 L"http://localhost:1337/files/sub_frame3.html"; | 286 L"http://localhost:1337/files/sub_frame3.html"; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 const wchar_t kAnchorUrl[] = L"http://localhost:1337/files/anchor.html"; | 432 const wchar_t kAnchorUrl[] = L"http://localhost:1337/files/anchor.html"; |
340 const wchar_t kAnchor1Url[] = L"http://localhost:1337/files/anchor.html#a1"; | 433 const wchar_t kAnchor1Url[] = L"http://localhost:1337/files/anchor.html#a1"; |
341 const wchar_t kAnchor2Url[] = L"http://localhost:1337/files/anchor.html#a2"; | 434 const wchar_t kAnchor2Url[] = L"http://localhost:1337/files/anchor.html#a2"; |
342 const wchar_t kAnchor3Url[] = L"http://localhost:1337/files/anchor.html#a3"; | 435 const wchar_t kAnchor3Url[] = L"http://localhost:1337/files/anchor.html#a3"; |
343 | 436 |
344 // Full tab mode back/forward test | 437 // Full tab mode back/forward test |
345 // Launch and navigate chrome frame to a set of URLs and test back forward | 438 // Launch and navigate chrome frame to a set of URLs and test back forward |
346 // Marking this test FLAKY as it fails at times on the buildbot. | 439 // Marking this test FLAKY as it fails at times on the buildbot. |
347 // http://code.google.com/p/chromium/issues/detail?id=26549 | 440 // http://code.google.com/p/chromium/issues/detail?id=26549 |
348 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_BackForwardAnchor) { | 441 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_BackForwardAnchor) { |
349 const char tab_enter_keystrokes[] = { VK_TAB, VK_RETURN, 0 }; | |
350 static const std::string tab_enter(tab_enter_keystrokes); | |
351 chrome_frame_test::TimedMsgLoop loop; | 442 chrome_frame_test::TimedMsgLoop loop; |
352 CComObjectStackEx<MockWebBrowserEventSink> mock; | 443 CComObjectStackEx<MockWebBrowserEventSink> mock; |
353 ::testing::InSequence sequence; // Everything in sequence | 444 ::testing::InSequence sequence; // Everything in sequence |
354 | 445 |
355 // When the onhttpequiv patch is enabled, we will get two | 446 // When the onhttpequiv patch is enabled, we will get two |
356 // BeforeNavigate2/OnNavigateComplete2 notifications due to | 447 // BeforeNavigate2/OnNavigateComplete2 notifications due to |
357 // switching from IE to CF. | 448 // switching from IE to CF. |
358 // Note that when going backwards, we don't expect that since the extra | 449 // Note that when going backwards, we don't expect that since the extra |
359 // navigational entries in the travel log should have been removed. | 450 // navigational entries in the travel log should have been removed. |
360 // Same for navigating to anchors within a page that's already loaded. | 451 // Same for navigating to anchors within a page that's already loaded. |
(...skipping 22 matching lines...) Expand all Loading... |
383 // - Then send keyboard input of TAB + ENTER to cause navigation. | 474 // - Then send keyboard input of TAB + ENTER to cause navigation. |
384 // It's better to send input as PostDelayedTask since the Activex | 475 // It's better to send input as PostDelayedTask since the Activex |
385 // message loop on the other side might be blocked when we get | 476 // message loop on the other side might be blocked when we get |
386 // called in Onload. | 477 // called in Onload. |
387 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchorUrl))) | 478 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchorUrl))) |
388 .WillOnce(testing::DoAll( | 479 .WillOnce(testing::DoAll( |
389 testing::InvokeWithoutArgs(CreateFunctor(&mock, | 480 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
390 &chrome_frame_test::WebBrowserEventSink::SetFocusToChrome)), | 481 &chrome_frame_test::WebBrowserEventSink::SetFocusToChrome)), |
391 testing::InvokeWithoutArgs(CreateFunctor(&loop, | 482 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
392 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, | 483 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
393 NewRunnableMethod( | 484 NewRunnableFunction( |
394 &mock, | 485 &simulate_input::SendString<wchar_t>, |
395 &chrome_frame_test::WebBrowserEventSink::SendInputToChrome, | 486 &tab_enter_keys[0]), 200)))); |
396 std::string(tab_enter)), 0)))); | |
397 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 487 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
398 testing::StrCaseEq(kAnchor1Url)), | 488 testing::StrCaseEq(kAnchor1Url)), |
399 _, _, _, _, _)) | 489 _, _, _, _, _)) |
400 .WillOnce(testing::Return(S_OK)); | 490 .WillOnce(testing::Return(S_OK)); |
401 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 491 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
402 .WillOnce(testing::Return()); | 492 .WillOnce(testing::Return()); |
403 | 493 |
404 // Navigate to anchor 2 after the previous navigation is complete | 494 // Navigate to anchor 2 after the previous navigation is complete |
405 // Back/Forward state at this point: | 495 // Back/Forward state at this point: |
406 // Back: 1 (kAnchorUrl) | 496 // Back: 1 (kAnchorUrl) |
407 // Forward: 0 | 497 // Forward: 0 |
408 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor1Url))) | 498 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor1Url))) |
409 .WillOnce(testing::InvokeWithoutArgs( | 499 .WillOnce(testing::InvokeWithoutArgs( |
410 CreateFunctor( | 500 CreateFunctor( |
411 &loop, &chrome_frame_test::TimedMsgLoop::PostDelayedTask, | 501 &loop, &chrome_frame_test::TimedMsgLoop::PostDelayedTask, |
412 FROM_HERE, | 502 FROM_HERE, |
413 NewRunnableMethod( | 503 NewRunnableFunction( |
414 &mock, | 504 &simulate_input::SendString<wchar_t>, |
415 &chrome_frame_test::WebBrowserEventSink::SendInputToChrome, | 505 &tab_enter_keys[0]), 200))); |
416 std::string(tab_enter)), 0))); | |
417 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 506 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
418 testing::StrCaseEq(kAnchor2Url)), | 507 testing::StrCaseEq(kAnchor2Url)), |
419 _, _, _, _, _)) | 508 _, _, _, _, _)) |
420 .WillOnce(testing::Return(S_OK)); | 509 .WillOnce(testing::Return(S_OK)); |
421 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 510 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
422 .WillOnce(testing::Return()); | 511 .WillOnce(testing::Return()); |
423 | 512 |
424 // Navigate to anchor 3 after the previous navigation is complete | 513 // Navigate to anchor 3 after the previous navigation is complete |
425 // Back/Forward state at this point: | 514 // Back/Forward state at this point: |
426 // Back: 2 (kAnchorUrl, kAnchor1Url) | 515 // Back: 2 (kAnchorUrl, kAnchor1Url) |
427 // Forward: 0 | 516 // Forward: 0 |
428 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor2Url))) | 517 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor2Url))) |
429 .WillOnce(testing::InvokeWithoutArgs( | 518 .WillOnce(testing::InvokeWithoutArgs( |
430 CreateFunctor( | 519 CreateFunctor( |
431 &loop, &chrome_frame_test::TimedMsgLoop::PostDelayedTask, | 520 &loop, &chrome_frame_test::TimedMsgLoop::PostDelayedTask, |
432 FROM_HERE, | 521 FROM_HERE, |
433 NewRunnableMethod( | 522 NewRunnableFunction( |
434 &mock, | 523 &simulate_input::SendString<wchar_t>, |
435 &chrome_frame_test::WebBrowserEventSink::SendInputToChrome, | 524 &tab_enter_keys[0]), 200))); |
436 std::string(tab_enter)), 0))); | |
437 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 525 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
438 testing::StrCaseEq(kAnchor3Url)), | 526 testing::StrCaseEq(kAnchor3Url)), |
439 _, _, _, _, _)) | 527 _, _, _, _, _)) |
440 .WillOnce(testing::Return(S_OK)); | 528 .WillOnce(testing::Return(S_OK)); |
441 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 529 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
442 .WillOnce(testing::Return()); | 530 .WillOnce(testing::Return()); |
443 | 531 |
444 // We will reach anchor 3 once the navigation is complete, | 532 // We will reach anchor 3 once the navigation is complete, |
445 // then go back to anchor 2 | 533 // then go back to anchor 2 |
446 // Back/Forward state at this point: | 534 // Back/Forward state at this point: |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 .WillOnce(testing::Return()); | 631 .WillOnce(testing::Return()); |
544 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 632 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
545 testing::StrCaseEq(kAnchorUrl)), | 633 testing::StrCaseEq(kAnchorUrl)), |
546 _, _, _, _, _)) | 634 _, _, _, _, _)) |
547 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); | 635 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
548 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 636 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
549 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); | 637 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
550 | 638 |
551 VARIANT empty = ScopedVariant::kEmptyVariant; | 639 VARIANT empty = ScopedVariant::kEmptyVariant; |
552 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchorUrl))) | 640 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchorUrl))) |
553 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( | 641 .WillOnce(testing::InvokeWithoutArgs( |
554 CreateFunctor(ReceivePointer(mock.web_browser2_), | 642 CreateFunctor(&mock, &MockWebBrowserEventSink::Exec, &CGID_MSHTML, |
555 &IWebBrowser2::ExecWB, | |
556 static_cast<OLECMDID>(IDM_VIEWSOURCE), | 643 static_cast<OLECMDID>(IDM_VIEWSOURCE), |
557 OLECMDEXECOPT_DONTPROMPTUSER, &empty, &empty)))); | 644 OLECMDEXECOPT_DONTPROMPTUSER, &empty, &empty))); |
558 | 645 |
559 // Expect notification for view-source window, handle new window event | 646 // Expect notification for view-source window, handle new window event |
560 // and attach a new mock to the received web browser | 647 // and attach a new mock to the received web browser |
561 std::wstring view_source_url; | 648 std::wstring view_source_url; |
562 view_source_url += UTF8ToWide(chrome::kViewSourceScheme); | 649 view_source_url += UTF8ToWide(chrome::kViewSourceScheme); |
563 view_source_url += L":"; | 650 view_source_url += L":"; |
564 view_source_url += kAnchorUrl; | 651 view_source_url += kAnchorUrl; |
565 std::wstring url_in_new_window = kChromeProtocolPrefix; | 652 std::wstring url_in_new_window = kChromeProtocolPrefix; |
566 url_in_new_window += view_source_url; | 653 url_in_new_window += view_source_url; |
567 | 654 |
(...skipping 25 matching lines...) Expand all Loading... |
593 ASSERT_HRESULT_SUCCEEDED(hr); | 680 ASSERT_HRESULT_SUCCEEDED(hr); |
594 if (hr == S_FALSE) | 681 if (hr == S_FALSE) |
595 return; | 682 return; |
596 | 683 |
597 ASSERT_TRUE(mock.web_browser2() != NULL); | 684 ASSERT_TRUE(mock.web_browser2() != NULL); |
598 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 685 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
599 mock.Uninitialize(); | 686 mock.Uninitialize(); |
600 chrome_frame_test::CloseAllIEWindows(); | 687 chrome_frame_test::CloseAllIEWindows(); |
601 } | 688 } |
602 | 689 |
603 const wchar_t kChromeFrameFullTabModeBeforeUnloadEventTest[] = | 690 const wchar_t kFullTabModeBeforeUnloadEventTest[] = |
604 L"http://localhost:1337/files/fulltab_before_unload_event_test.html"; | 691 L"http://localhost:1337/files/fulltab_before_unload_event_test.html"; |
605 | 692 |
606 const wchar_t kChromeFrameFullTabModeBeforeUnloadEventMain[] = | 693 const wchar_t kFullTabModeBeforeUnloadEventMain[] = |
607 L"http://localhost:1337/files/fulltab_before_unload_event_main.html"; | 694 L"http://localhost:1337/files/fulltab_before_unload_event_main.html"; |
608 | 695 |
609 TEST_F(ChromeFrameTestWithWebServer, | 696 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_UnloadEventTest) { |
610 FullTabModeIE_ChromeFrameUnloadEventTest) { | |
611 chrome_frame_test::TimedMsgLoop loop; | 697 chrome_frame_test::TimedMsgLoop loop; |
612 CComObjectStackEx<MockWebBrowserEventSink> mock; | 698 CComObjectStackEx<MockWebBrowserEventSink> mock; |
613 ::testing::InSequence sequence; // Everything in sequence | 699 ::testing::InSequence sequence; // Everything in sequence |
614 | 700 |
615 // We will get two BeforeNavigate2/OnNavigateComplete2 notifications due to | 701 // We will get two BeforeNavigate2/OnNavigateComplete2 notifications due to |
616 // switching from IE to CF. | 702 // switching from IE to CF. |
617 EXPECT_CALL( | 703 EXPECT_CALL( |
618 mock, | 704 mock, |
619 OnBeforeNavigate2( | 705 OnBeforeNavigate2( |
620 _, testing::Field(&VARIANT::bstrVal, | 706 _, testing::Field(&VARIANT::bstrVal, |
621 testing::StrCaseEq(kChromeFrameFullTabModeBeforeUnloadEventTest)), | 707 testing::StrCaseEq(kFullTabModeBeforeUnloadEventTest)), |
622 _, _, _, _, _)) | 708 _, _, _, _, _)) |
623 .WillOnce(testing::Return(S_OK)); | 709 .WillOnce(testing::Return(S_OK)); |
624 | 710 |
625 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 711 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
626 .WillOnce(testing::Return()); | 712 .WillOnce(testing::Return()); |
627 | 713 |
628 EXPECT_CALL( | 714 EXPECT_CALL( |
629 mock, | 715 mock, |
630 OnBeforeNavigate2( | 716 OnBeforeNavigate2( |
631 _, testing::Field(&VARIANT::bstrVal, | 717 _, testing::Field(&VARIANT::bstrVal, |
632 testing::StrCaseEq(kChromeFrameFullTabModeBeforeUnloadEventTest)), | 718 testing::StrCaseEq(kFullTabModeBeforeUnloadEventTest)), |
633 _, _, _, _, _)) | 719 _, _, _, _, _)) |
634 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); | 720 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
635 | 721 |
636 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 722 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
637 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); | 723 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
638 | 724 |
639 EXPECT_CALL(mock, OnLoad(_)).WillOnce(testing::Return()); | 725 EXPECT_CALL(mock, OnLoad(_)).WillOnce(testing::Return()); |
640 | 726 |
641 // We will get two BeforeNavigate2/OnNavigateComplete2 notifications due to | 727 // We will get two BeforeNavigate2/OnNavigateComplete2 notifications due to |
642 // switching from IE to CF. | 728 // switching from IE to CF. |
643 EXPECT_CALL( | 729 EXPECT_CALL( |
644 mock, | 730 mock, |
645 OnBeforeNavigate2( | 731 OnBeforeNavigate2( |
646 _, testing::Field(&VARIANT::bstrVal, | 732 _, testing::Field(&VARIANT::bstrVal, |
647 testing::StrCaseEq(kChromeFrameFullTabModeBeforeUnloadEventMain)), | 733 testing::StrCaseEq(kFullTabModeBeforeUnloadEventMain)), |
648 _, _, _, _, _)) | 734 _, _, _, _, _)) |
649 .WillOnce(testing::Return(S_OK)); | 735 .WillOnce(testing::Return(S_OK)); |
650 | 736 |
651 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 737 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
652 .WillOnce(testing::Return()); | 738 .WillOnce(testing::Return()); |
653 | 739 |
654 EXPECT_CALL( | 740 EXPECT_CALL( |
655 mock, | 741 mock, |
656 OnBeforeNavigate2( | 742 OnBeforeNavigate2( |
657 _, testing::Field(&VARIANT::bstrVal, | 743 _, testing::Field(&VARIANT::bstrVal, |
658 testing::StrCaseEq(kChromeFrameFullTabModeBeforeUnloadEventMain)), | 744 testing::StrCaseEq(kFullTabModeBeforeUnloadEventMain)), |
659 _, _, _, _, _)) | 745 _, _, _, _, _)) |
660 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); | 746 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
661 | 747 |
662 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 748 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
663 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); | 749 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
664 | 750 |
665 EXPECT_CALL(mock, OnLoad(_)).WillOnce(testing::Return()); | 751 EXPECT_CALL(mock, OnLoad(_)).WillOnce(testing::Return()); |
666 | 752 |
667 EXPECT_CALL(mock, OnMessage(_)) | 753 EXPECT_CALL(mock, OnMessage(_, _, _)) |
668 .WillOnce(testing::DoAll( | 754 .WillOnce(testing::DoAll( |
669 testing::InvokeWithoutArgs(CreateFunctor(&mock, | 755 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
670 &chrome_frame_test::WebBrowserEventSink::Uninitialize)), | 756 &chrome_frame_test::WebBrowserEventSink::Uninitialize)), |
671 testing::IgnoreResult(testing::InvokeWithoutArgs( | 757 testing::IgnoreResult(testing::InvokeWithoutArgs( |
672 &chrome_frame_test::CloseAllIEWindows)), | 758 &chrome_frame_test::CloseAllIEWindows)), |
673 QUIT_LOOP_SOON(loop, 2))); | 759 QUIT_LOOP_SOON(loop, 2))); |
674 | 760 |
675 HRESULT hr = | 761 HRESULT hr = mock.LaunchIEAndNavigate(kFullTabModeBeforeUnloadEventTest); |
676 mock.LaunchIEAndNavigate(kChromeFrameFullTabModeBeforeUnloadEventTest); | |
677 ASSERT_HRESULT_SUCCEEDED(hr); | 762 ASSERT_HRESULT_SUCCEEDED(hr); |
678 if (hr == S_FALSE) | 763 if (hr == S_FALSE) |
679 return; | 764 return; |
680 | 765 |
681 ASSERT_TRUE(mock.web_browser2() != NULL); | 766 ASSERT_TRUE(mock.web_browser2() != NULL); |
682 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 767 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
683 mock.Uninitialize(); | 768 mock.Uninitialize(); |
684 chrome_frame_test::CloseAllIEWindows(); | 769 chrome_frame_test::CloseAllIEWindows(); |
685 } | 770 } |
686 | 771 |
| 772 // Test Back/Forward from context menu. Loads page 1 in chrome and page 2 |
| 773 // in IE. Then it tests back and forward using context menu |
| 774 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ContextMenuBackForward) { |
| 775 chrome_frame_test::TimedMsgLoop loop; |
| 776 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 777 |
| 778 ::testing::InSequence sequence; // Everything in sequence |
| 779 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 780 testing::StrCaseEq(kSubFrameUrl1)), |
| 781 _, _, _, _, _)) |
| 782 .WillOnce(testing::Return(S_OK)); |
| 783 EXPECT_CALL(mock, OnNavigateComplete2(_, _)).WillOnce(testing::Return()); |
| 784 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 785 testing::StrCaseEq(kSubFrameUrl1)), |
| 786 _, _, _, _, _)) |
| 787 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 788 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 789 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
| 790 |
| 791 // Navigate to url 2 after the previous navigation is complete. |
| 792 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) |
| 793 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 794 CreateFunctor(&mock, |
| 795 &chrome_frame_test::WebBrowserEventSink::Navigate, |
| 796 std::wstring(kSubFrameUrl2))))); |
| 797 |
| 798 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 799 testing::StrCaseEq(kSubFrameUrl2)), |
| 800 _, _, _, _, _)) |
| 801 .WillOnce(testing::Return(S_OK)); |
| 802 EXPECT_CALL(mock, OnNavigateComplete2(_, _)).WillOnce(testing::Return()); |
| 803 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 804 testing::StrCaseEq(kSubFrameUrl2)), |
| 805 _, _, _, _, _)) |
| 806 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 807 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 808 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
| 809 |
| 810 // Go back using Rt-Click + DOWN + ENTER |
| 811 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl2))) |
| 812 .WillOnce(testing::DoAll( |
| 813 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 814 &MockWebBrowserEventSink::SendMouseClick, 10, 10, |
| 815 simulate_input::RIGHT)), |
| 816 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 817 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 818 NewRunnableFunction( |
| 819 simulate_input::SendExtendedKey, VK_DOWN, false, false, |
| 820 false), |
| 821 500)), |
| 822 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 823 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 824 NewRunnableFunction( |
| 825 simulate_input::SendString<wchar_t>, &enter_key[0]), |
| 826 600)))); |
| 827 |
| 828 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 829 testing::StrCaseEq(kSubFrameUrl1)), |
| 830 _, _, _, _, _)) |
| 831 .WillOnce(testing::Return(S_OK)); |
| 832 EXPECT_CALL(mock, OnNavigateComplete2(_, _)).WillOnce(testing::Return()); |
| 833 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 834 testing::StrCaseEq(kSubFrameUrl1)), |
| 835 _, _, _, _, _)) |
| 836 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 837 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 838 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
| 839 |
| 840 // Go forward using Rt-Click + DOWN + DOWN + ENTER |
| 841 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) |
| 842 .WillOnce(testing::DoAll( |
| 843 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 844 &MockWebBrowserEventSink::SendMouseClick, 10, 10, |
| 845 simulate_input::RIGHT)), |
| 846 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 847 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 848 NewRunnableFunction( |
| 849 simulate_input::SendExtendedKey, VK_DOWN, false, false, |
| 850 false), |
| 851 500)), |
| 852 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 853 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 854 NewRunnableFunction( |
| 855 simulate_input::SendExtendedKey, VK_DOWN, false, false, |
| 856 false), |
| 857 600)), |
| 858 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 859 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 860 NewRunnableFunction( |
| 861 simulate_input::SendString<wchar_t>, &enter_key[0]), |
| 862 700)))); |
| 863 |
| 864 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 865 testing::StrCaseEq(kSubFrameUrl2)), |
| 866 _, _, _, _, _)) |
| 867 .WillOnce(testing::Return(S_OK)); |
| 868 EXPECT_CALL(mock, OnNavigateComplete2(_, _)).WillOnce(testing::Return()); |
| 869 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 870 testing::StrCaseEq(kSubFrameUrl2)), |
| 871 _, _, _, _, _)) |
| 872 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 873 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 874 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
| 875 |
| 876 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl2))) |
| 877 .WillOnce(testing::DoAll( |
| 878 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 879 &MockWebBrowserEventSink::Uninitialize)), |
| 880 testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 881 &chrome_frame_test::CloseAllIEWindows)), |
| 882 QUIT_LOOP_SOON(loop, 2))); |
| 883 |
| 884 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); |
| 885 ASSERT_HRESULT_SUCCEEDED(hr); |
| 886 if (hr == S_FALSE) |
| 887 return; |
| 888 |
| 889 ASSERT_TRUE(mock.web_browser2() != NULL); |
| 890 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 891 mock.Uninitialize(); |
| 892 chrome_frame_test::CloseAllIEWindows(); |
| 893 } |
| 894 |
| 895 // Test Reload from context menu. |
| 896 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ContextMenuReload) { |
| 897 chrome_frame_test::TimedMsgLoop loop; |
| 898 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 899 |
| 900 ::testing::InSequence sequence; // Everything in sequence |
| 901 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 902 testing::StrCaseEq(kSubFrameUrl1)), |
| 903 _, _, _, _, _)) |
| 904 .WillOnce(testing::Return(S_OK)); |
| 905 EXPECT_CALL(mock, OnNavigateComplete2(_, _)).WillOnce(testing::Return()); |
| 906 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 907 testing::StrCaseEq(kSubFrameUrl1)), |
| 908 _, _, _, _, _)) |
| 909 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 910 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 911 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
| 912 |
| 913 // Reload using Rt-Click + DOWN + DOWN + DOWN + ENTER |
| 914 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) |
| 915 .WillOnce(testing::DoAll( |
| 916 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 917 &MockWebBrowserEventSink::SendMouseClick, 10, 10, |
| 918 simulate_input::RIGHT)), |
| 919 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 920 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 921 NewRunnableFunction( |
| 922 simulate_input::SendExtendedKey, VK_DOWN, false, false, |
| 923 false), |
| 924 500)), |
| 925 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 926 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 927 NewRunnableFunction( |
| 928 simulate_input::SendExtendedKey, VK_DOWN, false, false, |
| 929 false), |
| 930 600)), |
| 931 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 932 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 933 NewRunnableFunction( |
| 934 simulate_input::SendExtendedKey, VK_DOWN, false, false, |
| 935 false), |
| 936 700)), |
| 937 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 938 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 939 NewRunnableFunction( |
| 940 simulate_input::SendString<wchar_t>, &enter_key[0]), |
| 941 800)))); |
| 942 |
| 943 // Go forward using Rt-Click + DOWN + DOWN + ENTER |
| 944 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) |
| 945 .WillOnce(testing::DoAll( |
| 946 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 947 &MockWebBrowserEventSink::Uninitialize)), |
| 948 testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 949 &chrome_frame_test::CloseAllIEWindows)), |
| 950 QUIT_LOOP_SOON(loop, 2))); |
| 951 |
| 952 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); |
| 953 ASSERT_HRESULT_SUCCEEDED(hr); |
| 954 if (hr == S_FALSE) |
| 955 return; |
| 956 |
| 957 ASSERT_TRUE(mock.web_browser2() != NULL); |
| 958 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 959 mock.Uninitialize(); |
| 960 chrome_frame_test::CloseAllIEWindows(); |
| 961 } |
| 962 |
| 963 // Test view source using context menu |
| 964 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ContextMenuViewSource) { |
| 965 chrome_frame_test::TimedMsgLoop loop; |
| 966 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 967 CComObjectStackEx<MockWebBrowserEventSink> view_source_mock; |
| 968 ::testing::InSequence sequence; // Everything in sequence |
| 969 |
| 970 // After navigation invoke view soruce action using IWebBrowser2::ExecWB |
| 971 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 972 testing::StrCaseEq(kAnchorUrl)), |
| 973 _, _, _, _, _)) |
| 974 .WillOnce(testing::Return(S_OK)); |
| 975 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 976 .WillOnce(testing::Return()); |
| 977 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 978 testing::StrCaseEq(kAnchorUrl)), |
| 979 _, _, _, _, _)) |
| 980 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 981 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 982 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); |
| 983 |
| 984 // view soruce using Rt-Click + UP + UP + UP + UP + ENTER |
| 985 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchorUrl))) |
| 986 .WillOnce(testing::DoAll( |
| 987 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 988 &MockWebBrowserEventSink::SendMouseClick, 10, 10, |
| 989 simulate_input::RIGHT)), |
| 990 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 991 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 992 NewRunnableFunction( |
| 993 simulate_input::SendExtendedKey, VK_UP, false, false, |
| 994 false), |
| 995 500)), |
| 996 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 997 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 998 NewRunnableFunction( |
| 999 simulate_input::SendExtendedKey, VK_UP, false, false, |
| 1000 false), |
| 1001 600)), |
| 1002 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 1003 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 1004 NewRunnableFunction( |
| 1005 simulate_input::SendExtendedKey, VK_UP, false, false, |
| 1006 false), |
| 1007 700)), |
| 1008 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 1009 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 1010 NewRunnableFunction( |
| 1011 simulate_input::SendExtendedKey, VK_UP, false, false, |
| 1012 false), |
| 1013 800)), |
| 1014 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 1015 &chrome_frame_test::TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 1016 NewRunnableFunction( |
| 1017 simulate_input::SendString<wchar_t>, &enter_key[0]), |
| 1018 900)))); |
| 1019 |
| 1020 // Expect notification for view-source window, handle new window event |
| 1021 // and attach a new mock to the received web browser |
| 1022 std::wstring view_source_url; |
| 1023 view_source_url += UTF8ToWide(chrome::kViewSourceScheme); |
| 1024 view_source_url += L":"; |
| 1025 view_source_url += kAnchorUrl; |
| 1026 std::wstring url_in_new_window = kChromeProtocolPrefix; |
| 1027 url_in_new_window += view_source_url; |
| 1028 |
| 1029 EXPECT_CALL(mock, OnNewWindow3(_, _, _, _, |
| 1030 testing::StrCaseEq(url_in_new_window))); |
| 1031 EXPECT_CALL(mock, OnNewBrowserWindow(_, _)) |
| 1032 .WillOnce(testing::WithArgs<0>( |
| 1033 testing::Invoke(CreateFunctor(&view_source_mock, |
| 1034 &MockWebBrowserEventSink::Attach)))); |
| 1035 |
| 1036 // Expect navigations on the new mock |
| 1037 EXPECT_CALL(view_source_mock, OnBeforeNavigate2(_, |
| 1038 testing::Field(&VARIANT::bstrVal, |
| 1039 testing::StrCaseEq(url_in_new_window)), _, _, _, _, _)) |
| 1040 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); |
| 1041 EXPECT_CALL(view_source_mock, OnNavigateComplete2(_, _)) |
| 1042 .WillOnce(testing::Return()); |
| 1043 EXPECT_CALL(view_source_mock, OnLoad(testing::StrEq(view_source_url))) |
| 1044 .WillOnce(testing::DoAll( |
| 1045 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 1046 &MockWebBrowserEventSink::Uninitialize)), |
| 1047 testing::InvokeWithoutArgs(CreateFunctor(&view_source_mock, |
| 1048 &MockWebBrowserEventSink::Uninitialize)), |
| 1049 testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1050 &chrome_frame_test::CloseAllIEWindows)), |
| 1051 QUIT_LOOP_SOON(loop, 2))); |
| 1052 |
| 1053 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); |
| 1054 ASSERT_HRESULT_SUCCEEDED(hr); |
| 1055 if (hr == S_FALSE) |
| 1056 return; |
| 1057 |
| 1058 ASSERT_TRUE(mock.web_browser2() != NULL); |
| 1059 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 1060 mock.Uninitialize(); |
| 1061 chrome_frame_test::CloseAllIEWindows(); |
| 1062 } |
| 1063 |
| 1064 |
OLD | NEW |