| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 #include "chrome_frame/test/test_mock_with_web_server.h" | |
| 5 | |
| 6 #include <mshtmcid.h> | |
| 7 | |
| 8 #include "base/scoped_bstr_win.h" | |
| 9 #include "chrome/common/url_constants.h" | |
| 10 #include "chrome_frame/utils.h" | |
| 11 #include "chrome_frame/test/simulate_input.h" | |
| 12 #include "chrome_frame/test/test_with_web_server.h" | |
| 13 | |
| 14 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING | |
| 15 #include "testing/gmock_mutant.h" | |
| 16 | |
| 17 using testing::_; | |
| 18 using testing::CreateFunctor; | |
| 19 using chrome_frame_test::CloseIeAtEndOfScope; | |
| 20 using chrome_frame_test::ComStackObjectWithUninitialize; | |
| 21 using chrome_frame_test::kChromeFrameLongNavigationTimeoutInSeconds; | |
| 22 using chrome_frame_test::MockWebBrowserEventSink; | |
| 23 | |
| 24 const wchar_t kChromeFrameFileUrl[] = L"gcf:file:///C:/"; | |
| 25 const wchar_t enter_key[] = { VK_RETURN, 0 }; | |
| 26 const wchar_t escape_key[] = { VK_ESCAPE, 0 }; | |
| 27 const wchar_t tab_enter_keys[] = { VK_TAB, VK_RETURN, 0 }; | |
| 28 | |
| 29 namespace chrome_frame_test { | |
| 30 | |
| 31 ExpectationSet MockWebBrowserEventSink::ExpectNavigationCardinality( | |
| 32 const std::wstring& url, testing::Cardinality cardinality) { | |
| 33 // Expect a single navigation sequence. If URL is specified, | |
| 34 // match the URL. | |
| 35 // The navigation sequence is a set of OnBeforeNavigate2, OnFileDownload | |
| 36 // and OnNavigationComplete2 events. For certain navigations, internal | |
| 37 // vs external (and maybe between different IE versions) these events | |
| 38 // events occur with different frequencies. Hence, the variable | |
| 39 // cardinality. | |
| 40 ExpectationSet navigation; | |
| 41 if (url.empty()) { | |
| 42 navigation += EXPECT_CALL(*this, OnBeforeNavigate2(_, _, _, _, _, _, _)) | |
| 43 .Times(cardinality); | |
| 44 } else { | |
| 45 navigation += EXPECT_CALL(*this, OnBeforeNavigate2(_, | |
| 46 testing::Field(&VARIANT::bstrVal, | |
| 47 testing::StrCaseEq(url)), _, _, _, _, _)) | |
| 48 .Times(cardinality); | |
| 49 } | |
| 50 navigation += EXPECT_CALL(*this, OnFileDownload(VARIANT_TRUE, _)) | |
| 51 .Times(cardinality); | |
| 52 | |
| 53 if (url.empty()) { | |
| 54 navigation += EXPECT_CALL(*this, OnNavigateComplete2(_, _)) | |
| 55 .Times(cardinality); | |
| 56 } else { | |
| 57 navigation += EXPECT_CALL(*this, OnNavigateComplete2(_, | |
| 58 testing::Field(&VARIANT::bstrVal, | |
| 59 testing::StrCaseEq(url)))) | |
| 60 .Times(cardinality); | |
| 61 } | |
| 62 | |
| 63 return navigation; | |
| 64 } | |
| 65 | |
| 66 ExpectationSet MockWebBrowserEventSink::ExpectNavigation( | |
| 67 const std::wstring& url) { | |
| 68 // When the onhttpequiv patch is enabled, we will get two | |
| 69 // BeforeNavigate2/OnNavigateComplete2 notifications due to | |
| 70 // switching from IE to CF. | |
| 71 // Note that when going backwards, we don't expect that since the extra | |
| 72 // navigational entries in the travel log should have been removed. | |
| 73 ExpectationSet navigation; | |
| 74 navigation += EXPECT_CALL(*this, OnBeforeNavigate2(_, | |
| 75 testing::Field(&VARIANT::bstrVal, | |
| 76 testing::StrCaseEq(url)), _, _, _, _, _)); | |
| 77 navigation += EXPECT_CALL(*this, OnFileDownload(VARIANT_TRUE, _)) | |
| 78 .Times(testing::AnyNumber()); | |
| 79 navigation += EXPECT_CALL(*this, OnNavigateComplete2(_, | |
| 80 testing::Field(&VARIANT::bstrVal, | |
| 81 testing::StrCaseEq(url)))) | |
| 82 .Times(testing::AnyNumber()); | |
| 83 | |
| 84 return navigation; | |
| 85 } | |
| 86 | |
| 87 ExpectationSet MockWebBrowserEventSink::ExpectNavigationSequenceForAnchors( | |
| 88 const std::wstring& url) { | |
| 89 // When the onhttpequiv patch is enabled, we will get two | |
| 90 // BeforeNavigate2/OnNavigateComplete2 notifications due to | |
| 91 // switching from IE to CF. | |
| 92 // Note that when going backwards, we don't expect that since the extra | |
| 93 // navigational entries in the travel log should have been removed. | |
| 94 // On IE6 we don't receive the BeforeNavigate notifications for anchors. | |
| 95 ExpectationSet navigation; | |
| 96 navigation += EXPECT_CALL(*this, OnBeforeNavigate2(_, | |
| 97 testing::Field(&VARIANT::bstrVal, | |
| 98 testing::StrCaseEq(url)), _, _, _, _, _)) | |
| 99 .Times(testing::AnyNumber()); | |
| 100 navigation += EXPECT_CALL(*this, OnFileDownload(VARIANT_TRUE, _)) | |
| 101 .Times(testing::AnyNumber()); | |
| 102 navigation += EXPECT_CALL(*this, OnNavigateComplete2(_, | |
| 103 testing::Field(&VARIANT::bstrVal, | |
| 104 testing::StrCaseEq(url)))) | |
| 105 .Times(testing::AnyNumber()); | |
| 106 | |
| 107 return navigation; | |
| 108 } | |
| 109 | |
| 110 ExpectationSet MockWebBrowserEventSink::ExpectNavigationAndSwitch( | |
| 111 const std::wstring& url) { | |
| 112 return ExpectNavigationCardinality(url, testing::AnyNumber()); | |
| 113 } | |
| 114 | |
| 115 ExpectationSet MockWebBrowserEventSink::ExpectNavigationAndSwitchSequence( | |
| 116 const std::wstring& url) { | |
| 117 // When navigation expectations occur in sequence the following order | |
| 118 // is necessary. This is mainly based on observed quirks rather than | |
| 119 // any theory. | |
| 120 // TODO(joshia): Improve expectations here | |
| 121 ExpectationSet navigation = ExpectNavigationCardinality(url, | |
| 122 testing::Exactly(1)); | |
| 123 navigation += EXPECT_CALL(*this, OnBeforeNavigate2(_, | |
| 124 testing::Field(&VARIANT::bstrVal, | |
| 125 testing::StrCaseEq(url)), _, _, _, _, _)) | |
| 126 .Times(testing::AnyNumber()); | |
| 127 navigation += EXPECT_CALL(*this, OnFileDownload(VARIANT_TRUE, _)) | |
| 128 .Times(testing::AnyNumber()); | |
| 129 navigation += EXPECT_CALL(*this, OnNavigateComplete2(_, | |
| 130 testing::Field(&VARIANT::bstrVal, | |
| 131 testing::StrCaseEq(url)))) | |
| 132 .Times(testing::AnyNumber()); | |
| 133 | |
| 134 return navigation; | |
| 135 } | |
| 136 | |
| 137 ExpectationSet MockWebBrowserEventSink::ExpectNewWindow( | |
| 138 MockWebBrowserEventSink* new_window_mock) { | |
| 139 DCHECK(new_window_mock); | |
| 140 ExpectationSet new_window; | |
| 141 new_window += EXPECT_CALL(*this, OnNewWindow3(_, _, _, _, _)); | |
| 142 new_window += EXPECT_CALL(*this, OnNewBrowserWindow(_, _)) | |
| 143 .WillOnce(testing::WithArgs<0>(testing::Invoke(CreateFunctor( | |
| 144 new_window_mock, &MockWebBrowserEventSink::Attach)))); | |
| 145 | |
| 146 new_window_mock->ExpectNavigationAndSwitch(std::wstring()); | |
| 147 return new_window; | |
| 148 } | |
| 149 | |
| 150 ExpectationSet MockWebBrowserEventSink::ExpectNavigationInIE( | |
| 151 const std::wstring& url) { | |
| 152 testing::InSequence sequence; | |
| 153 ExpectationSet navigation; | |
| 154 navigation += EXPECT_CALL(*this, OnBeforeNavigate2(_, | |
| 155 testing::Field(&VARIANT::bstrVal, | |
| 156 testing::StrCaseEq(url)), _, _, _, _, _)); | |
| 157 navigation += EXPECT_CALL(*this, OnFileDownload(VARIANT_TRUE, _)) | |
| 158 .Times(testing::AnyNumber()); | |
| 159 navigation += EXPECT_CALL(*this, OnNavigateComplete2(_, | |
| 160 testing::Field(&VARIANT::bstrVal, | |
| 161 testing::StrCaseEq(url)))); | |
| 162 return navigation; | |
| 163 } | |
| 164 | |
| 165 ExpectationSet MockWebBrowserEventSink::ExpectNewWindowWithIE( | |
| 166 const std::wstring& url, MockWebBrowserEventSink* new_window_mock) { | |
| 167 DCHECK(new_window_mock); | |
| 168 ExpectationSet new_window; | |
| 169 new_window += EXPECT_CALL(*this, OnNewWindow3(_, _, _, _, _)); | |
| 170 new_window += EXPECT_CALL(*this, OnNewBrowserWindow(_, _)) | |
| 171 .WillOnce(testing::WithArgs<0>(testing::Invoke(CreateFunctor( | |
| 172 new_window_mock, &MockWebBrowserEventSink::Attach)))); | |
| 173 | |
| 174 new_window_mock->ExpectNavigationInIE(url); | |
| 175 return new_window; | |
| 176 } | |
| 177 | |
| 178 } // namespace chrome_frame_test | |
| 179 | |
| 180 ACTION_P(SetFocusToChrome, mock) { | |
| 181 mock->SetFocusToChrome(); | |
| 182 } | |
| 183 | |
| 184 ACTION_P2(Navigate, mock, url) { | |
| 185 mock->Navigate(url); | |
| 186 } | |
| 187 | |
| 188 ACTION_P2(WatchWindow, mock, window_class) { | |
| 189 mock->WatchChromeWindow(window_class); | |
| 190 } | |
| 191 | |
| 192 ACTION_P(StopWindowWatching, mock) { | |
| 193 mock->StopWatching(); | |
| 194 } | |
| 195 | |
| 196 ACTION_P6(DelaySendMouseClick, mock, loop, delay, x, y, button) { | |
| 197 loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock, | |
| 198 &MockWebBrowserEventSink::SendMouseClick, x, y, button), delay); | |
| 199 } | |
| 200 | |
| 201 ACTION_P3(DelaySendString, loop, delay, str) { | |
| 202 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | |
| 203 simulate_input::SendStringW, str), delay); | |
| 204 } | |
| 205 | |
| 206 ACTION_P5(SendExtendedKeysEnter, loop, delay, c, repeat, mod) { | |
| 207 chrome_frame_test::DelaySendExtendedKeysEnter(loop, delay, c, repeat, mod); | |
| 208 } | |
| 209 | |
| 210 ACTION(DoCloseWindow) { | |
| 211 ::PostMessage(arg0, WM_SYSCOMMAND, SC_CLOSE, 0); | |
| 212 } | |
| 213 | |
| 214 // This function selects the address bar via the Alt+d shortcut. This is done | |
| 215 // via a delayed task which executes after the delay which is passed in. | |
| 216 // The subsequent operations like typing in the actual url and then hitting | |
| 217 // enter to force the browser to navigate to it each execute as delayed tasks | |
| 218 // timed at the delay passed in. The recommended value for delay is 2000 ms | |
| 219 // to account for the time taken for the accelerator keys to be reflected back | |
| 220 // from Chrome. | |
| 221 ACTION_P3(TypeUrlInAddressBar, loop, url, delay) { | |
| 222 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | |
| 223 simulate_input::SendCharA, 'd', simulate_input::ALT), | |
| 224 delay); | |
| 225 | |
| 226 const unsigned int kInterval = 500; | |
| 227 int next_delay = delay + kInterval; | |
| 228 | |
| 229 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | |
| 230 simulate_input::SendStringW, url), next_delay); | |
| 231 | |
| 232 next_delay = next_delay + kInterval; | |
| 233 | |
| 234 loop->PostDelayedTask(FROM_HERE, NewRunnableFunction( | |
| 235 simulate_input::SendCharA, VK_RETURN, simulate_input::NONE), | |
| 236 next_delay); | |
| 237 } | |
| 238 | |
| 239 ACTION_P(VerifyAddressBarUrlWithGcf, mock) { | |
| 240 std::wstring expected_url = L"gcf:"; | |
| 241 expected_url += arg0; | |
| 242 mock->ExpectAddressBarUrl(expected_url); | |
| 243 } | |
| 244 | |
| 245 TEST(ChromeFrameTest, FullTabModeIE_DisallowedUrls) { | |
| 246 CloseIeAtEndOfScope last_resort_close_ie; | |
| 247 // If a navigation fails then IE issues a navigation to an interstitial | |
| 248 // page. Catch this to track navigation errors as the NavigateError | |
| 249 // notification does not seem to fire reliably. | |
| 250 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 251 chrome_frame_test::TimedMsgLoop loop; | |
| 252 | |
| 253 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | |
| 254 testing::StrCaseEq(kChromeFrameFileUrl)), | |
| 255 _, _, _, _, _)); | |
| 256 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | |
| 257 testing::StartsWith(L"res:")), | |
| 258 _, _, _, _, _)); | |
| 259 EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) | |
| 260 .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); | |
| 261 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | |
| 262 .WillOnce(CloseBrowserMock(&mock)); | |
| 263 EXPECT_CALL(mock, OnQuit()) | |
| 264 .Times(testing::AtMost(1)).WillOnce(QUIT_LOOP(loop)); | |
| 265 | |
| 266 HRESULT hr = mock.LaunchIEAndNavigate(kChromeFrameFileUrl); | |
| 267 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 268 if (hr == S_FALSE) | |
| 269 return; | |
| 270 | |
| 271 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 272 | |
| 273 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 274 } | |
| 275 | |
| 276 const wchar_t kKeyEventUrl[] = L"http://localhost:1337/files/keyevent.html"; | |
| 277 | |
| 278 // Marking this test FLAKY as it fails at times on the buildbot. | |
| 279 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
| 280 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_KeyboardTest) { | |
| 281 CloseIeAtEndOfScope last_resort_close_ie; | |
| 282 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 283 chrome_frame_test::TimedMsgLoop loop; | |
| 284 | |
| 285 mock.ExpectNavigationAndSwitch(kKeyEventUrl); | |
| 286 | |
| 287 const wchar_t* input = L"Chrome"; | |
| 288 EXPECT_CALL(mock, OnLoad(testing::StrEq(kKeyEventUrl))) | |
| 289 .WillOnce(testing::DoAll( | |
| 290 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::LEFT), | |
| 291 DelaySendString(&loop, 500, input))); | |
| 292 | |
| 293 EXPECT_CALL(mock, OnMessage(testing::StrEq(input), _, _)) | |
| 294 .WillOnce(CloseBrowserMock(&mock)); | |
| 295 EXPECT_CALL(mock, OnQuit()) | |
| 296 .Times(testing::AtMost(1)) | |
| 297 .WillOnce(QUIT_LOOP(loop)); | |
| 298 | |
| 299 HRESULT hr = mock.LaunchIEAndNavigate(kKeyEventUrl); | |
| 300 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 301 if (hr == S_FALSE) | |
| 302 return; | |
| 303 | |
| 304 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 305 } | |
| 306 | |
| 307 const wchar_t kAboutVersionUrl[] = L"gcf:about:version"; | |
| 308 const wchar_t kAboutVersion[] = L"about:version"; | |
| 309 | |
| 310 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_FocusTest) { | |
| 311 CloseIeAtEndOfScope last_resort_close_ie; | |
| 312 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 313 chrome_frame_test::TimedMsgLoop loop; | |
| 314 | |
| 315 mock.ExpectNavigationAndSwitch(kAboutVersionUrl); | |
| 316 | |
| 317 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAboutVersion))) | |
| 318 .WillOnce(testing::DoAll( | |
| 319 testing::InvokeWithoutArgs(CreateFunctor(&mock, | |
| 320 &MockWebBrowserEventSink::ExpectRendererWindowHasFocus)), | |
| 321 VerifyAddressBarUrlWithGcf(&mock), | |
| 322 CloseBrowserMock(&mock))); | |
| 323 | |
| 324 EXPECT_CALL(mock, OnQuit()) | |
| 325 .Times(testing::AtMost(1)) | |
| 326 .WillOnce(QUIT_LOOP(loop)); | |
| 327 | |
| 328 HRESULT hr = mock.LaunchIEAndNavigate(kAboutVersionUrl); | |
| 329 | |
| 330 // Allow some time for chrome to be launched. | |
| 331 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 332 } | |
| 333 | |
| 334 const wchar_t kWindowOpenUrl[] = | |
| 335 L"http://localhost:1337/files/chrome_frame_window_open.html"; | |
| 336 | |
| 337 const wchar_t kWindowOpenPopupUrl[] = | |
| 338 L"http://localhost:1337/files/chrome_frame_window_open_popup.html"; | |
| 339 | |
| 340 // This test checks if window.open calls issued by a full tab mode ChromeFrame | |
| 341 // instance make it back to IE and then transitions back to Chrome as the | |
| 342 // window.open target page is supposed to render within Chrome. | |
| 343 // Marking this test as FLAKY initially as it relies on getting focus and user | |
| 344 // input which don't work correctly at times. | |
| 345 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
| 346 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_WindowOpenInChrome) { | |
| 347 CloseIeAtEndOfScope last_resort_close_ie; | |
| 348 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 349 ComStackObjectWithUninitialize<MockWebBrowserEventSink> new_window_mock; | |
| 350 chrome_frame_test::TimedMsgLoop loop; | |
| 351 | |
| 352 mock.ExpectNavigationAndSwitch(kWindowOpenUrl); | |
| 353 | |
| 354 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kWindowOpenUrl))) | |
| 355 .WillOnce(testing::DoAll( | |
| 356 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::LEFT), | |
| 357 DelaySendChar(&loop, 500, 'O', simulate_input::NONE))); | |
| 358 // Watch for new window | |
| 359 mock.ExpectNewWindow(&new_window_mock); | |
| 360 | |
| 361 EXPECT_CALL(new_window_mock, OnLoad(testing::StrCaseEq(kWindowOpenPopupUrl))) | |
| 362 .WillOnce(testing::DoAll( | |
| 363 VerifyAddressBarUrl(&new_window_mock), | |
| 364 ValidateWindowSize(&new_window_mock, 10, 10, 250, 250), | |
| 365 CloseBrowserMock(&new_window_mock))); | |
| 366 | |
| 367 EXPECT_CALL(new_window_mock, OnQuit()) | |
| 368 .Times(testing::AtMost(1)) | |
| 369 .WillOnce(CloseBrowserMock(&mock)); | |
| 370 | |
| 371 EXPECT_CALL(mock, OnQuit()) | |
| 372 .Times(testing::AtMost(1)) | |
| 373 .WillOnce(QUIT_LOOP(loop)); | |
| 374 | |
| 375 HRESULT hr = mock.LaunchIEAndNavigate(kWindowOpenUrl); | |
| 376 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 377 if (hr == S_FALSE) | |
| 378 return; | |
| 379 | |
| 380 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 381 | |
| 382 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 383 | |
| 384 ASSERT_TRUE(new_window_mock.web_browser2() != NULL); | |
| 385 } | |
| 386 | |
| 387 const wchar_t kSubFrameUrl1[] = | |
| 388 L"http://localhost:1337/files/sub_frame1.html"; | |
| 389 const wchar_t kSubFrameUrl2[] = | |
| 390 L"http://localhost:1337/files/sub_frame2.html"; | |
| 391 const wchar_t kSubFrameUrl3[] = | |
| 392 L"http://localhost:1337/files/sub_frame3.html"; | |
| 393 | |
| 394 // Test new window behavior with ctrl+N | |
| 395 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_CtrlN) { | |
| 396 CloseIeAtEndOfScope last_resort_close_ie; | |
| 397 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 398 chrome_frame_test::TimedMsgLoop loop; | |
| 399 | |
| 400 // Ideally we want to use a mock to watch for finer grained | |
| 401 // events for New Window, but for Crl+N we don't get any | |
| 402 // OnNewWindowX notifications. :( | |
| 403 const wchar_t* kIEFrameClass = L"IEFrame"; | |
| 404 mock.ExpectNavigationAndSwitch(kKeyEventUrl); | |
| 405 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kKeyEventUrl))) | |
| 406 .WillOnce(testing::DoAll( | |
| 407 WatchWindow(&mock, kIEFrameClass), | |
| 408 SetFocusToChrome(&mock), | |
| 409 DelaySendChar(&loop, 1500, 'n', simulate_input::CONTROL))); | |
| 410 | |
| 411 // Watch for new window | |
| 412 const char* kNewWindowTitle = "Internet Explorer"; | |
| 413 EXPECT_CALL(mock, OnWindowDetected(_, testing::HasSubstr(kNewWindowTitle))) | |
| 414 .WillOnce(testing::DoAll( | |
| 415 DoCloseWindow(), | |
| 416 CloseBrowserMock(&mock))); | |
| 417 | |
| 418 EXPECT_CALL(mock, OnQuit()) | |
| 419 .Times(testing::AtMost(1)) | |
| 420 .WillOnce(QUIT_LOOP(loop)); | |
| 421 | |
| 422 HRESULT hr = mock.LaunchIEAndNavigate(kKeyEventUrl); | |
| 423 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 424 if (hr == S_FALSE) | |
| 425 return; | |
| 426 | |
| 427 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 428 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 429 } | |
| 430 | |
| 431 // Test page reload with ctrl+R | |
| 432 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_CtrlR) { | |
| 433 CloseIeAtEndOfScope last_resort_close_ie; | |
| 434 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 435 chrome_frame_test::TimedMsgLoop loop; | |
| 436 | |
| 437 // In sequence since we want to do different things on two loads | |
| 438 // on the same mock for the same URLs | |
| 439 ::testing::InSequence sequence; | |
| 440 | |
| 441 mock.ExpectNavigationAndSwitchSequence(kKeyEventUrl); | |
| 442 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kKeyEventUrl))) | |
| 443 .WillOnce(testing::DoAll( | |
| 444 SetFocusToChrome(&mock), | |
| 445 DelaySendChar(&loop, 1500, 'r', simulate_input::CONTROL))); | |
| 446 | |
| 447 // mock.ExpectNavigation(kKeyEventUrl); | |
| 448 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kKeyEventUrl))) | |
| 449 .WillOnce(testing::DoAll( | |
| 450 VerifyAddressBarUrl(&mock), | |
| 451 CloseBrowserMock(&mock))); | |
| 452 | |
| 453 EXPECT_CALL(mock, OnQuit()) | |
| 454 .Times(testing::AtMost(1)) | |
| 455 .WillOnce(QUIT_LOOP(loop)); | |
| 456 | |
| 457 HRESULT hr = mock.LaunchIEAndNavigate(kKeyEventUrl); | |
| 458 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 459 if (hr == S_FALSE) | |
| 460 return; | |
| 461 | |
| 462 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 463 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 464 } | |
| 465 | |
| 466 // Test window close with ctrl+w | |
| 467 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_CtrlW) { | |
| 468 CloseIeAtEndOfScope last_resort_close_ie; | |
| 469 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 470 chrome_frame_test::TimedMsgLoop loop; | |
| 471 | |
| 472 mock.ExpectNavigationAndSwitch(kKeyEventUrl); | |
| 473 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kKeyEventUrl))) | |
| 474 .WillOnce(testing::DoAll( | |
| 475 SetFocusToChrome(&mock), | |
| 476 DelaySendChar(&loop, 1500, 'w', simulate_input::CONTROL))); | |
| 477 | |
| 478 EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop)); | |
| 479 | |
| 480 HRESULT hr = mock.LaunchIEAndNavigate(kKeyEventUrl); | |
| 481 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 482 if (hr == S_FALSE) | |
| 483 return; | |
| 484 | |
| 485 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 486 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 487 } | |
| 488 | |
| 489 // Test address bar navigation with Alt+d and URL | |
| 490 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_AltD) { | |
| 491 CloseIeAtEndOfScope last_resort_close_ie; | |
| 492 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 493 chrome_frame_test::TimedMsgLoop loop; | |
| 494 ::testing::InSequence sequence; | |
| 495 | |
| 496 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl1); | |
| 497 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 498 .WillOnce(testing::DoAll( | |
| 499 SetFocusToChrome(&mock), | |
| 500 TypeUrlInAddressBar(&loop, kSubFrameUrl2, 1500))); | |
| 501 | |
| 502 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl2); | |
| 503 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl2))) | |
| 504 .WillOnce(CloseBrowserMock(&mock)); | |
| 505 | |
| 506 EXPECT_CALL(mock, OnQuit()) | |
| 507 .Times(testing::AtMost(1)) | |
| 508 .WillOnce(QUIT_LOOP(loop)); | |
| 509 | |
| 510 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | |
| 511 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 512 if (hr == S_FALSE) | |
| 513 return; | |
| 514 | |
| 515 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 516 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 517 } | |
| 518 | |
| 519 // This test launches chrome frame in full tab mode in IE by having IE navigate | |
| 520 // to a url. It then looks for the chrome renderer window and posts | |
| 521 // the WM_RBUTTONDOWN/WM_RBUTTONUP messages to it, which bring up the context | |
| 522 // menu. This is followed by keyboard messages sent via SendInput to select | |
| 523 // the About chrome frame menu option, which would then bring up a new window | |
| 524 // with the chrome revision. The test finally checks for success by comparing | |
| 525 // the URL of the window being opened with cf:about:version, which indicates | |
| 526 // that the operation succeeded. | |
| 527 // Marking this test FLAKY as it fails at times on the buildbot. | |
| 528 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
| 529 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_AboutChromeFrame) { | |
| 530 CloseIeAtEndOfScope last_resort_close_ie; | |
| 531 | |
| 532 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 533 ComStackObjectWithUninitialize<MockWebBrowserEventSink> new_window_mock; | |
| 534 chrome_frame_test::TimedMsgLoop loop; | |
| 535 | |
| 536 mock.ExpectNavigationAndSwitch(kSubFrameUrl1); | |
| 537 | |
| 538 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 539 .WillOnce(testing::DoAll( | |
| 540 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::RIGHT), | |
| 541 SendExtendedKeysEnter(&loop, 500, VK_UP, 1, simulate_input::NONE))); | |
| 542 | |
| 543 // Watch for new window | |
| 544 mock.ExpectNewWindow(&new_window_mock); | |
| 545 | |
| 546 EXPECT_CALL(new_window_mock, OnLoad(testing::StrCaseEq(kAboutVersion))) | |
| 547 .WillOnce(testing::DoAll( | |
| 548 VerifyAddressBarUrlWithGcf(&new_window_mock), | |
| 549 CloseBrowserMock(&new_window_mock))); | |
| 550 EXPECT_CALL(new_window_mock, OnQuit()) | |
| 551 .Times(testing::AtMost(1)) | |
| 552 .WillOnce(CloseBrowserMock(&mock)); | |
| 553 EXPECT_CALL(mock, OnQuit()) | |
| 554 .Times(testing::AtMost(1)) | |
| 555 .WillOnce(QUIT_LOOP(loop)); | |
| 556 | |
| 557 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | |
| 558 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 559 if (hr == S_FALSE) | |
| 560 return; | |
| 561 | |
| 562 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 563 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 564 } | |
| 565 | |
| 566 // Hack to pass a reference to the argument instead of value. Passing by | |
| 567 // value evaluates the argument at the mock specification time which is | |
| 568 // not always ideal. For e.g. At the time of mock creation, web_browser2_ | |
| 569 // pointer is not set up yet so by passing a reference to it instead of | |
| 570 // a value we allow it to be created later. | |
| 571 template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT | |
| 572 return reinterpret_cast<T**>(&p); | |
| 573 } | |
| 574 | |
| 575 // Full tab mode back/forward test | |
| 576 // Launch and navigate chrome frame to a set of URLs and test back forward | |
| 577 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { | |
| 578 CloseIeAtEndOfScope last_resort_close_ie; | |
| 579 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 580 chrome_frame_test::TimedMsgLoop loop; | |
| 581 ::testing::InSequence sequence; // Everything in sequence | |
| 582 | |
| 583 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl1); | |
| 584 | |
| 585 // Navigate to url 2 after the previous navigation is complete. | |
| 586 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 587 .WillOnce(testing::DoAll( | |
| 588 VerifyAddressBarUrl(&mock), | |
| 589 Navigate(&mock, kSubFrameUrl2))); | |
| 590 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl2); | |
| 591 | |
| 592 // Navigate to url 3 after the previous navigation is complete | |
| 593 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl2))) | |
| 594 .WillOnce(testing::DoAll( | |
| 595 VerifyAddressBarUrl(&mock), | |
| 596 Navigate(&mock, kSubFrameUrl3))); | |
| 597 | |
| 598 // We have reached url 3 and have two back entries for url 1 & 2 | |
| 599 // Go back to url 2 now | |
| 600 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl3); | |
| 601 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl3))) | |
| 602 .WillOnce(testing::DoAll( | |
| 603 VerifyAddressBarUrl(&mock), | |
| 604 testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( | |
| 605 ReceivePointer(mock.web_browser2_), &IWebBrowser::GoBack))))); | |
| 606 | |
| 607 // We have reached url 2 and have 1 back & 1 forward entries for url 1 & 3 | |
| 608 // Go back to url 1 now | |
| 609 mock.ExpectNavigation(kSubFrameUrl2); | |
| 610 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl2))) | |
| 611 .WillOnce(testing::DoAll( | |
| 612 VerifyAddressBarUrl(&mock), | |
| 613 testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( | |
| 614 ReceivePointer(mock.web_browser2_), &IWebBrowser::GoBack))))); | |
| 615 | |
| 616 // We have reached url 1 and have 0 back & 2 forward entries for url 2 & 3 | |
| 617 // Go back to url 1 now | |
| 618 mock.ExpectNavigation(kSubFrameUrl1); | |
| 619 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 620 .WillOnce(testing::DoAll( | |
| 621 VerifyAddressBarUrl(&mock), | |
| 622 CloseBrowserMock(&mock))); | |
| 623 EXPECT_CALL(mock, OnQuit()) | |
| 624 .Times(testing::AtMost(1)) | |
| 625 .WillOnce(QUIT_LOOP(loop)); | |
| 626 | |
| 627 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | |
| 628 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 629 if (hr == S_FALSE) | |
| 630 return; | |
| 631 | |
| 632 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 633 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 634 } | |
| 635 | |
| 636 const wchar_t kAnchorUrl[] = L"http://localhost:1337/files/anchor.html"; | |
| 637 const wchar_t kAnchor1Url[] = L"http://localhost:1337/files/anchor.html#a1"; | |
| 638 const wchar_t kAnchor2Url[] = L"http://localhost:1337/files/anchor.html#a2"; | |
| 639 const wchar_t kAnchor3Url[] = L"http://localhost:1337/files/anchor.html#a3"; | |
| 640 | |
| 641 // Full tab mode back/forward test | |
| 642 // Launch and navigate chrome frame to a set of URLs and test back forward | |
| 643 // Marking this test FLAKY as it fails at times on the buildbot. | |
| 644 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
| 645 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_BackForwardAnchor) { | |
| 646 CloseIeAtEndOfScope last_resort_close_ie; | |
| 647 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 648 chrome_frame_test::TimedMsgLoop loop; | |
| 649 ::testing::InSequence sequence; // Everything in sequence | |
| 650 | |
| 651 // Back/Forward state at this point: | |
| 652 // Back: 0 | |
| 653 // Forward: 0 | |
| 654 mock.ExpectNavigationAndSwitchSequence(kAnchorUrl); | |
| 655 | |
| 656 // Navigate to anchor 1: | |
| 657 // - First set focus to chrome renderer window | |
| 658 // Call WebBrowserEventSink::SetFocusToChrome only once | |
| 659 // in the beginning. Calling it again will change focus from the | |
| 660 // current location to an element near the simulated mouse.click. | |
| 661 // - Then send keyboard input of TAB + ENTER to cause navigation. | |
| 662 // It's better to send input as PostDelayedTask since the Activex | |
| 663 // message loop on the other side might be blocked when we get | |
| 664 // called in Onload. | |
| 665 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchorUrl))) | |
| 666 .WillOnce(testing::DoAll( | |
| 667 SetFocusToChrome(&mock), | |
| 668 DelaySendString(&loop, 200, tab_enter_keys))); | |
| 669 | |
| 670 mock.ExpectNavigationSequenceForAnchors(kAnchor1Url); | |
| 671 // Navigate to anchor 2 after the previous navigation is complete | |
| 672 // Back/Forward state at this point: | |
| 673 // Back: 1 (kAnchorUrl) | |
| 674 // Forward: 0 | |
| 675 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchor1Url))) | |
| 676 .WillOnce(testing::DoAll( | |
| 677 VerifyAddressBarUrl(&mock), | |
| 678 DelaySendString(&loop, 200, tab_enter_keys))); | |
| 679 mock.ExpectNavigationSequenceForAnchors(kAnchor2Url); | |
| 680 | |
| 681 // Navigate to anchor 3 after the previous navigation is complete | |
| 682 // Back/Forward state at this point: | |
| 683 // Back: 2 (kAnchorUrl, kAnchor1Url) | |
| 684 // Forward: 0 | |
| 685 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchor2Url))) | |
| 686 .WillOnce(testing::DoAll( | |
| 687 VerifyAddressBarUrl(&mock), | |
| 688 DelaySendString(&loop, 200, tab_enter_keys))); | |
| 689 mock.ExpectNavigationSequenceForAnchors(kAnchor3Url); | |
| 690 | |
| 691 // We will reach anchor 3 once the navigation is complete, | |
| 692 // then go back to anchor 2 | |
| 693 // Back/Forward state at this point: | |
| 694 // Back: 3 (kAnchorUrl, kAnchor1Url, kAnchor2Url) | |
| 695 // Forward: 0 | |
| 696 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchor3Url))) | |
| 697 .WillOnce(testing::DoAll( | |
| 698 VerifyAddressBarUrl(&mock), | |
| 699 testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( | |
| 700 ReceivePointer(mock.web_browser2_), &IWebBrowser::GoBack))))); | |
| 701 mock.ExpectNavigationSequenceForAnchors(kAnchor2Url); | |
| 702 | |
| 703 // We will reach anchor 2 once the navigation is complete, | |
| 704 // then go back to anchor 1 | |
| 705 // Back/Forward state at this point: | |
| 706 // Back: 3 (kAnchorUrl, kAnchor1Url, kAnchor2Url) | |
| 707 // Forward: 1 (kAnchor3Url) | |
| 708 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchor2Url))) | |
| 709 .WillOnce(testing::DoAll( | |
| 710 VerifyAddressBarUrl(&mock), | |
| 711 testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( | |
| 712 ReceivePointer(mock.web_browser2_), &IWebBrowser::GoBack))))); | |
| 713 mock.ExpectNavigationSequenceForAnchors(kAnchor1Url); | |
| 714 | |
| 715 // We will reach anchor 1 once the navigation is complete, | |
| 716 // now go forward to anchor 2 | |
| 717 // Back/Forward state at this point: | |
| 718 // Back: 2 (kAnchorUrl, kAnchor1Url) | |
| 719 // Forward: 2 (kAnchor2Url, kAnchor3Url) | |
| 720 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchor1Url))) | |
| 721 .WillOnce(testing::DoAll( | |
| 722 VerifyAddressBarUrl(&mock), | |
| 723 testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( | |
| 724 ReceivePointer(mock.web_browser2_), &IWebBrowser::GoForward))))); | |
| 725 mock.ExpectNavigationSequenceForAnchors(kAnchor2Url); | |
| 726 | |
| 727 // We have reached anchor 2, go forward to anchor 3 again | |
| 728 // Back/Forward state at this point: | |
| 729 // Back: 3 (kAnchorUrl, kAnchor1Url, kAnchor2Url) | |
| 730 // Forward: 1 (kAnchor3Url) | |
| 731 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchor2Url))) | |
| 732 .WillOnce(testing::DoAll( | |
| 733 VerifyAddressBarUrl(&mock), | |
| 734 testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( | |
| 735 ReceivePointer(mock.web_browser2_), &IWebBrowser::GoForward))))); | |
| 736 mock.ExpectNavigationSequenceForAnchors(kAnchor3Url); | |
| 737 | |
| 738 // We have gone a few steps back and forward, this should be enough for now. | |
| 739 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchor3Url))) | |
| 740 .WillOnce(CloseBrowserMock(&mock)); | |
| 741 EXPECT_CALL(mock, OnQuit()) | |
| 742 .Times(testing::AtMost(1)) | |
| 743 .WillOnce(QUIT_LOOP(loop)); | |
| 744 | |
| 745 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); | |
| 746 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 747 if (hr == S_FALSE) | |
| 748 return; | |
| 749 | |
| 750 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 751 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 752 } | |
| 753 | |
| 754 // Full tab mode view source test | |
| 755 // Launch and navigate chrome frame and invoke view source functionality | |
| 756 // This test has been marked FLAKY | |
| 757 // http://code.google.com/p/chromium/issues/detail?id=35370 | |
| 758 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_ViewSource) { | |
| 759 CloseIeAtEndOfScope last_resort_close_ie; | |
| 760 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 761 ComStackObjectWithUninitialize<MockWebBrowserEventSink> view_source_mock; | |
| 762 chrome_frame_test::TimedMsgLoop loop; | |
| 763 ::testing::InSequence sequence; // Everything in sequence | |
| 764 | |
| 765 // After navigation invoke view soruce action using IWebBrowser2::ExecWB | |
| 766 mock.ExpectNavigationAndSwitchSequence(kAnchorUrl); | |
| 767 | |
| 768 VARIANT empty = ScopedVariant::kEmptyVariant; | |
| 769 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchorUrl))) | |
| 770 .WillOnce(testing::InvokeWithoutArgs( | |
| 771 CreateFunctor(&mock, &MockWebBrowserEventSink::Exec, &CGID_MSHTML, | |
| 772 static_cast<OLECMDID>(IDM_VIEWSOURCE), | |
| 773 OLECMDEXECOPT_DONTPROMPTUSER, &empty, &empty))); | |
| 774 | |
| 775 // Expect notification for view-source window, handle new window event | |
| 776 // and attach a new mock to the received web browser | |
| 777 std::wstring view_source_url; | |
| 778 view_source_url += UTF8ToWide(chrome::kViewSourceScheme); | |
| 779 view_source_url += L":"; | |
| 780 view_source_url += kAnchorUrl; | |
| 781 std::wstring url_in_new_window = kChromeProtocolPrefix; | |
| 782 url_in_new_window += view_source_url; | |
| 783 | |
| 784 mock.ExpectNewWindow(&view_source_mock); | |
| 785 EXPECT_CALL(view_source_mock, OnLoad(testing::StrCaseEq(view_source_url))) | |
| 786 .WillOnce(testing::DoAll( | |
| 787 VerifyAddressBarUrlWithGcf(&view_source_mock), | |
| 788 CloseBrowserMock(&view_source_mock))); | |
| 789 | |
| 790 EXPECT_CALL(view_source_mock, OnQuit()) | |
| 791 .Times(testing::AtMost(1)) | |
| 792 .WillOnce(CloseBrowserMock(&mock)); | |
| 793 | |
| 794 EXPECT_CALL(mock, OnQuit()) | |
| 795 .Times(testing::AtMost(1)) | |
| 796 .WillOnce(QUIT_LOOP(loop)); | |
| 797 | |
| 798 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); | |
| 799 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 800 if (hr == S_FALSE) | |
| 801 return; | |
| 802 | |
| 803 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 804 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 805 } | |
| 806 | |
| 807 const wchar_t kBeforeUnloadTest[] = | |
| 808 L"http://localhost:1337/files/fulltab_before_unload_event_test.html"; | |
| 809 | |
| 810 const wchar_t kBeforeUnloadMain[] = | |
| 811 L"http://localhost:1337/files/fulltab_before_unload_event_main.html"; | |
| 812 | |
| 813 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_UnloadEventTest) { | |
| 814 CloseIeAtEndOfScope last_resort_close_ie; | |
| 815 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 816 chrome_frame_test::TimedMsgLoop loop; | |
| 817 ::testing::InSequence sequence; // Everything in sequence | |
| 818 | |
| 819 mock.ExpectNavigationAndSwitchSequence(kBeforeUnloadTest); | |
| 820 EXPECT_CALL(mock, OnLoad(_)); | |
| 821 | |
| 822 mock.ExpectNavigationAndSwitchSequence(kBeforeUnloadMain); | |
| 823 EXPECT_CALL(mock, OnLoad(_)); | |
| 824 | |
| 825 EXPECT_CALL(mock, OnMessage(_, _, _)) | |
| 826 .WillOnce(CloseBrowserMock(&mock)); | |
| 827 EXPECT_CALL(mock, OnQuit()) | |
| 828 .Times(testing::AtMost(1)) | |
| 829 .WillOnce(QUIT_LOOP(loop)); | |
| 830 | |
| 831 HRESULT hr = mock.LaunchIEAndNavigate(kBeforeUnloadTest); | |
| 832 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 833 if (hr == S_FALSE) | |
| 834 return; | |
| 835 | |
| 836 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 837 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 838 } | |
| 839 | |
| 840 // NOTE: This test is currently disabled as we haven't finished implementing | |
| 841 // support for this yet. The test (as written) works fine for IE. CF might | |
| 842 // have a different set of requirements once we fully support this and hence | |
| 843 // the test might need some refining before being enabled. | |
| 844 TEST_F(ChromeFrameTestWithWebServer, | |
| 845 DISABLED_FullTabModeIE_DownloadInNewWindow) { | |
| 846 CloseIeAtEndOfScope last_resort_close_ie; | |
| 847 const wchar_t kDownloadFromNewWin[] = | |
| 848 L"http://localhost:1337/files/full_tab_download_from_new_window.html"; | |
| 849 | |
| 850 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 851 chrome_frame_test::TimedMsgLoop loop; | |
| 852 | |
| 853 mock.ExpectNavigationAndSwitch(kDownloadFromNewWin); | |
| 854 | |
| 855 EXPECT_CALL(mock, OnNewWindow3(_, _, _, _, _)); | |
| 856 | |
| 857 ComStackObjectWithUninitialize<MockWebBrowserEventSink> new_window_mock; | |
| 858 EXPECT_CALL(mock, OnNewBrowserWindow(_, _)) | |
| 859 .WillOnce(testing::WithArgs<0>(testing::Invoke(CreateFunctor( | |
| 860 &new_window_mock, &MockWebBrowserEventSink::Attach)))); | |
| 861 EXPECT_CALL(new_window_mock, OnBeforeNavigate2(_, _, _, _, _, _, _)); | |
| 862 | |
| 863 EXPECT_CALL(new_window_mock, OnFileDownload(VARIANT_FALSE, _)) | |
| 864 .Times(2) | |
| 865 .WillRepeatedly(CloseBrowserMock(&new_window_mock)); | |
| 866 | |
| 867 EXPECT_CALL(new_window_mock, OnNavigateComplete2(_, _)); | |
| 868 | |
| 869 EXPECT_CALL(new_window_mock, OnQuit()).WillOnce(CloseBrowserMock(&mock)); | |
| 870 EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop)); | |
| 871 | |
| 872 HRESULT hr = mock.LaunchIEAndNavigate(kDownloadFromNewWin); | |
| 873 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 874 if (hr == S_FALSE) | |
| 875 return; | |
| 876 | |
| 877 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 878 | |
| 879 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 880 } | |
| 881 | |
| 882 // Test Back/Forward from context menu. Loads page 1 in chrome and page 2 | |
| 883 // in IE. Then it tests back and forward using context menu | |
| 884 // Disabling this test as it won't work as per the current chrome external tab | |
| 885 // design. | |
| 886 // http://code.google.com/p/chromium/issues/detail?id=46615 | |
| 887 TEST_F(ChromeFrameTestWithWebServer, | |
| 888 DISABLED_FullTabModeIE_ContextMenuBackForward) { | |
| 889 CloseIeAtEndOfScope last_resort_close_ie; | |
| 890 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 891 chrome_frame_test::TimedMsgLoop loop; | |
| 892 | |
| 893 ::testing::InSequence sequence; // Everything in sequence | |
| 894 | |
| 895 // Navigate to url 2 after the previous navigation is complete. | |
| 896 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl1); | |
| 897 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 898 .WillOnce(Navigate(&mock, kSubFrameUrl2)); | |
| 899 | |
| 900 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl2); | |
| 901 | |
| 902 // Go back using Rt-Click + DOWN + ENTER | |
| 903 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl2))) | |
| 904 .WillOnce(testing::DoAll( | |
| 905 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::RIGHT), | |
| 906 SendExtendedKeysEnter(&loop, 500, VK_DOWN, 1, simulate_input::NONE))); | |
| 907 mock.ExpectNavigation(kSubFrameUrl1); | |
| 908 | |
| 909 // Go forward using Rt-Click + DOWN + DOWN + ENTER | |
| 910 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 911 .WillOnce(testing::DoAll( | |
| 912 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::RIGHT), | |
| 913 SendExtendedKeysEnter(&loop, 500, VK_DOWN, 2, simulate_input::NONE))); | |
| 914 mock.ExpectNavigation(kSubFrameUrl2); | |
| 915 | |
| 916 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl2))) | |
| 917 .WillOnce(CloseBrowserMock(&mock)); | |
| 918 EXPECT_CALL(mock, OnQuit()) | |
| 919 .Times(testing::AtMost(1)) | |
| 920 .WillOnce(QUIT_LOOP(loop)); | |
| 921 | |
| 922 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | |
| 923 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 924 if (hr == S_FALSE) | |
| 925 return; | |
| 926 | |
| 927 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 928 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 929 } | |
| 930 | |
| 931 // Test Reload from context menu. | |
| 932 // Marking this test FLAKY as it fails at times on the buildbot. | |
| 933 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
| 934 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_ContextMenuReload) { | |
| 935 CloseIeAtEndOfScope last_resort_close_ie; | |
| 936 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 937 chrome_frame_test::TimedMsgLoop loop; | |
| 938 | |
| 939 ::testing::InSequence sequence; // Everything in sequence | |
| 940 | |
| 941 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl1); | |
| 942 | |
| 943 // Reload using Rt-Click + DOWN + DOWN + DOWN + ENTER | |
| 944 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 945 .WillOnce(testing::DoAll( | |
| 946 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::RIGHT), | |
| 947 SendExtendedKeysEnter(&loop, 500, VK_DOWN, 3, simulate_input::NONE))); | |
| 948 | |
| 949 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 950 .WillOnce(CloseBrowserMock(&mock)); | |
| 951 EXPECT_CALL(mock, OnQuit()) | |
| 952 .Times(testing::AtMost(1)) | |
| 953 .WillOnce(QUIT_LOOP(loop)); | |
| 954 | |
| 955 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | |
| 956 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 957 if (hr == S_FALSE) | |
| 958 return; | |
| 959 | |
| 960 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 961 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 962 } | |
| 963 | |
| 964 // Test view source using context menu | |
| 965 // Marking this test FLAKY as it fails at times on the buildbot. | |
| 966 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
| 967 TEST_F(ChromeFrameTestWithWebServer, | |
| 968 FLAKY_FullTabModeIE_ContextMenuViewSource) { | |
| 969 CloseIeAtEndOfScope last_resort_close_ie; | |
| 970 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 971 ComStackObjectWithUninitialize<MockWebBrowserEventSink> view_source_mock; | |
| 972 chrome_frame_test::TimedMsgLoop loop; | |
| 973 ::testing::InSequence sequence; // Everything in sequence | |
| 974 | |
| 975 // View source using Rt-Click + UP + UP + UP + UP + ENTER | |
| 976 mock.ExpectNavigationAndSwitchSequence(kAnchorUrl); | |
| 977 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchorUrl))) | |
| 978 .WillOnce(testing::DoAll( | |
| 979 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::RIGHT), | |
| 980 SendExtendedKeysEnter(&loop, 500, VK_UP, 4, simulate_input::NONE))); | |
| 981 | |
| 982 // Expect notification for view-source window, handle new window event | |
| 983 // and attach a new mock to the received web browser | |
| 984 std::wstring view_source_url; | |
| 985 view_source_url += UTF8ToWide(chrome::kViewSourceScheme); | |
| 986 view_source_url += L":"; | |
| 987 view_source_url += kAnchorUrl; | |
| 988 std::wstring url_in_new_window = kChromeProtocolPrefix; | |
| 989 url_in_new_window += view_source_url; | |
| 990 | |
| 991 mock.ExpectNewWindow(&view_source_mock); | |
| 992 EXPECT_CALL(view_source_mock, OnLoad(testing::StrCaseEq(view_source_url))) | |
| 993 .WillOnce(testing::DoAll( | |
| 994 VerifyAddressBarUrlWithGcf(&view_source_mock), | |
| 995 CloseBrowserMock(&view_source_mock))); | |
| 996 EXPECT_CALL(view_source_mock, OnQuit()) | |
| 997 .Times(testing::AtMost(1)) | |
| 998 .WillOnce(CloseBrowserMock(&mock)); | |
| 999 | |
| 1000 EXPECT_CALL(mock, OnQuit()) | |
| 1001 .Times(testing::AtMost(1)) | |
| 1002 .WillOnce(QUIT_LOOP(loop)); | |
| 1003 | |
| 1004 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); | |
| 1005 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1006 if (hr == S_FALSE) | |
| 1007 return; | |
| 1008 | |
| 1009 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1010 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 1011 } | |
| 1012 | |
| 1013 TEST_F(ChromeFrameTestWithWebServer, | |
| 1014 FLAKY_FullTabModeIE_ContextMenuPageInfo) { | |
| 1015 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1016 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1017 chrome_frame_test::TimedMsgLoop loop; | |
| 1018 ::testing::InSequence sequence; // Everything in sequence | |
| 1019 | |
| 1020 // View page information using Rt-Click + UP + UP + UP + ENTER | |
| 1021 const wchar_t* kPageInfoWindowClass = L"Chrome_WidgetWin_0"; | |
| 1022 mock.ExpectNavigationAndSwitchSequence(kAnchorUrl); | |
| 1023 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchorUrl))) | |
| 1024 .WillOnce(testing::DoAll( | |
| 1025 WatchWindow(&mock, kPageInfoWindowClass), | |
| 1026 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::RIGHT), | |
| 1027 SendExtendedKeysEnter(&loop, 500, VK_UP, 3, simulate_input::NONE))); | |
| 1028 | |
| 1029 // Expect page info dialog to pop up. Dismiss the dialog with 'Esc' key | |
| 1030 const char* kPageInfoCaption = "Security Information"; | |
| 1031 EXPECT_CALL(mock, OnWindowDetected(_, testing::StrCaseEq(kPageInfoCaption))) | |
| 1032 .WillOnce(testing::DoAll( | |
| 1033 DelaySendChar(&loop, 100, VK_ESCAPE, simulate_input::NONE), | |
| 1034 DelayCloseBrowserMock(&loop, 2000, &mock))); | |
| 1035 | |
| 1036 EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop)); | |
| 1037 | |
| 1038 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); | |
| 1039 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1040 if (hr == S_FALSE) | |
| 1041 return; | |
| 1042 | |
| 1043 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1044 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 1045 } | |
| 1046 | |
| 1047 TEST_F(ChromeFrameTestWithWebServer, | |
| 1048 FLAKY_FullTabModeIE_ContextMenuInspector) { | |
| 1049 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1050 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1051 chrome_frame_test::TimedMsgLoop loop; | |
| 1052 ::testing::InSequence sequence; // Everything in sequence | |
| 1053 | |
| 1054 // Open developer tools using Rt-Click + UP + UP + ENTER | |
| 1055 const wchar_t* kPageInfoWindowClass = L"Chrome_WidgetWin_0"; | |
| 1056 mock.ExpectNavigationAndSwitchSequence(kAnchorUrl); | |
| 1057 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchorUrl))) | |
| 1058 .WillOnce(testing::DoAll( | |
| 1059 WatchWindow(&mock, kPageInfoWindowClass), | |
| 1060 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::RIGHT), | |
| 1061 SendExtendedKeysEnter(&loop, 500, VK_UP, 2, simulate_input::NONE))); | |
| 1062 | |
| 1063 // Devtools begins life with "Untitled" caption and it changes | |
| 1064 // later to the 'Developer Tools - <url> form. | |
| 1065 const char* kPageInfoCaption = "Untitled"; | |
| 1066 EXPECT_CALL(mock, OnWindowDetected(_, testing::StartsWith(kPageInfoCaption))) | |
| 1067 .WillOnce(testing::DoAll( | |
| 1068 StopWindowWatching(&mock), | |
| 1069 SetFocusToChrome(&mock), | |
| 1070 DelayCloseBrowserMock(&loop, 2000, &mock))); | |
| 1071 | |
| 1072 EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop)); | |
| 1073 | |
| 1074 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); | |
| 1075 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1076 if (hr == S_FALSE) | |
| 1077 return; | |
| 1078 | |
| 1079 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1080 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 1081 } | |
| 1082 | |
| 1083 TEST_F(ChromeFrameTestWithWebServer, | |
| 1084 FLAKY_FullTabModeIE_ContextMenuSaveAs) { | |
| 1085 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1086 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1087 chrome_frame_test::TimedMsgLoop loop; | |
| 1088 ::testing::InSequence sequence; // Everything in sequence | |
| 1089 | |
| 1090 // Open'Save As' dialog using Rt-Click + DOWN + DOWN + DOWN + DOWN + ENTER | |
| 1091 const wchar_t* kSaveDlgClass = L"#32770"; | |
| 1092 mock.ExpectNavigationAndSwitchSequence(kAnchorUrl); | |
| 1093 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchorUrl))) | |
| 1094 .WillOnce(testing::DoAll( | |
| 1095 WatchWindow(&mock, kSaveDlgClass), | |
| 1096 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::RIGHT), | |
| 1097 SendExtendedKeysEnter(&loop, 500, VK_DOWN, 4, simulate_input::NONE))); | |
| 1098 | |
| 1099 FilePath temp_file_path; | |
| 1100 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | |
| 1101 temp_file_path = temp_file_path.ReplaceExtension(L".htm"); | |
| 1102 | |
| 1103 const wchar_t* kSaveFileName = temp_file_path.value().c_str(); | |
| 1104 DeleteFile(kSaveFileName); | |
| 1105 | |
| 1106 const char* kSaveDlgCaption = "Save As"; | |
| 1107 EXPECT_CALL(mock, OnWindowDetected(_, testing::StrCaseEq(kSaveDlgCaption))) | |
| 1108 .WillOnce(testing::DoAll( | |
| 1109 StopWindowWatching(&mock), | |
| 1110 DelaySendString(&loop, 100, kSaveFileName), | |
| 1111 DelaySendChar(&loop, 200, VK_RETURN, simulate_input::NONE), | |
| 1112 DelayCloseBrowserMock(&loop, 4000, &mock))); | |
| 1113 | |
| 1114 EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop)); | |
| 1115 | |
| 1116 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); | |
| 1117 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1118 if (hr == S_FALSE) | |
| 1119 return; | |
| 1120 | |
| 1121 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1122 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 1123 | |
| 1124 ASSERT_NE(INVALID_FILE_ATTRIBUTES, GetFileAttributes(kSaveFileName)); | |
| 1125 ASSERT_TRUE(DeleteFile(kSaveFileName)); | |
| 1126 } | |
| 1127 | |
| 1128 // Marking this test FLAKY as it fails at times on the buildbot. | |
| 1129 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
| 1130 TEST_F(ChromeFrameTestWithWebServer, | |
| 1131 FLAKY_FullTabModeIE_KeyboardBackForwardTest) { | |
| 1132 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1133 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1134 chrome_frame_test::TimedMsgLoop loop; | |
| 1135 | |
| 1136 ::testing::InSequence sequence; // Everything in sequence | |
| 1137 | |
| 1138 // This test performs the following steps. | |
| 1139 // 1. Launches IE and navigates to | |
| 1140 // http://localhost:1337/files/sub_frame1.html | |
| 1141 // 2. It then navigates to | |
| 1142 // http://localhost:1337/files/sub_frame2.html | |
| 1143 // 3. Sends the VK_BACK keystroke to IE, which should navigate back to | |
| 1144 // http://localhost:1337/files/sub_frame1.html | |
| 1145 // 4. Sends the Shift + VK_BACK keystroke to IE which should navigate | |
| 1146 // forward to http://localhost:1337/files/sub_frame2.html | |
| 1147 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl1); | |
| 1148 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 1149 .WillOnce(Navigate(&mock, kSubFrameUrl2)); | |
| 1150 | |
| 1151 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl2); | |
| 1152 | |
| 1153 short bkspace = VkKeyScanA(VK_BACK); // NOLINT | |
| 1154 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl2))) | |
| 1155 .WillOnce(testing::DoAll( | |
| 1156 SetFocusToChrome(&mock), | |
| 1157 DelaySendScanCode(&loop, 500, bkspace, simulate_input::NONE))); | |
| 1158 | |
| 1159 mock.ExpectNavigation(kSubFrameUrl1); | |
| 1160 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 1161 .WillOnce(testing::DoAll( | |
| 1162 SetFocusToChrome(&mock), | |
| 1163 DelaySendScanCode(&loop, 1500, bkspace, simulate_input::SHIFT))); | |
| 1164 | |
| 1165 mock.ExpectNavigation(kSubFrameUrl2); | |
| 1166 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl2))) | |
| 1167 .WillOnce(CloseBrowserMock(&mock)); | |
| 1168 | |
| 1169 EXPECT_CALL(mock, OnQuit()) | |
| 1170 .Times(testing::AtMost(1)) | |
| 1171 .WillOnce(QUIT_LOOP(loop)); | |
| 1172 | |
| 1173 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | |
| 1174 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1175 if (hr == S_FALSE) | |
| 1176 return; | |
| 1177 | |
| 1178 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1179 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 1180 } | |
| 1181 | |
| 1182 // http://code.google.com/p/chromium/issues/detail?id=38566 | |
| 1183 TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_MenuSaveAs) { | |
| 1184 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1185 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1186 chrome_frame_test::TimedMsgLoop loop; | |
| 1187 ::testing::InSequence sequence; // Everything in sequence | |
| 1188 | |
| 1189 // Open'Save As' dialog using Alt+F, a, note the small 'f' | |
| 1190 // in DelaySendChar (otherwise DelaySendChar will | |
| 1191 // OR in a shift. | |
| 1192 const wchar_t* kSaveDlgClass = L"#32770"; | |
| 1193 mock.ExpectNavigationAndSwitchSequence(kKeyEventUrl); | |
| 1194 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kKeyEventUrl))) | |
| 1195 .WillOnce(testing::DoAll( | |
| 1196 WatchWindow(&mock, kSaveDlgClass), | |
| 1197 SetFocusToChrome(&mock), | |
| 1198 DelaySendChar(&loop, 1500, 'f', simulate_input::ALT), | |
| 1199 DelaySendChar(&loop, 2500, 'a', simulate_input::NONE))); | |
| 1200 | |
| 1201 FilePath temp_file_path; | |
| 1202 EXPECT_TRUE(file_util::CreateTemporaryFile(&temp_file_path)); | |
| 1203 | |
| 1204 const wchar_t* kSaveFileName = temp_file_path.value().c_str(); | |
| 1205 const char* kSaveDlgCaption = "Save As"; | |
| 1206 EXPECT_CALL(mock, OnWindowDetected(_, testing::StrCaseEq(kSaveDlgCaption))) | |
| 1207 .WillOnce(testing::DoAll( | |
| 1208 StopWindowWatching(&mock), | |
| 1209 DelaySendString(&loop, 100, kSaveFileName), | |
| 1210 DelaySendChar(&loop, 200, VK_RETURN, simulate_input::NONE), | |
| 1211 DelayCloseBrowserMock(&loop, 4000, &mock))); | |
| 1212 | |
| 1213 EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop)); | |
| 1214 | |
| 1215 HRESULT hr = mock.LaunchIEAndNavigate(kKeyEventUrl); | |
| 1216 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1217 if (hr == S_FALSE) | |
| 1218 return; | |
| 1219 | |
| 1220 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1221 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 1222 | |
| 1223 ASSERT_NE(INVALID_FILE_ATTRIBUTES, GetFileAttributes(kSaveFileName)); | |
| 1224 ASSERT_TRUE(DeleteFile(kSaveFileName)); | |
| 1225 } | |
| 1226 | |
| 1227 const wchar_t kHostBrowserUrl[] = | |
| 1228 L"http://localhost:1337/files/host_browser.html"; | |
| 1229 | |
| 1230 TEST_F(ChromeFrameTestWithWebServer, | |
| 1231 FLAKY_FullTabMode_SwitchFromIEToChromeFrame) { | |
| 1232 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1233 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1234 chrome_frame_test::TimedMsgLoop loop; | |
| 1235 | |
| 1236 EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) | |
| 1237 .Times(testing::AnyNumber()); | |
| 1238 | |
| 1239 ::testing::InSequence sequence; // Everything in sequence | |
| 1240 | |
| 1241 // This test performs the following steps. | |
| 1242 // 1. Launches IE and navigates to | |
| 1243 // http://localhost:1337/files/back_to_ie.html, which should render in IE. | |
| 1244 // 2. It then navigates to | |
| 1245 // http://localhost:1337/files/sub_frame1.html which should render in | |
| 1246 // ChromeFrame | |
| 1247 EXPECT_CALL(mock, OnBeforeNavigate2(_, | |
| 1248 testing::Field(&VARIANT::bstrVal, | |
| 1249 testing::StrCaseEq(kHostBrowserUrl)), _, _, _, _, _)); | |
| 1250 | |
| 1251 // When we receive a navigate complete notification for the initial URL | |
| 1252 // initiate a navigation to a url which should be rendered in ChromeFrame. | |
| 1253 EXPECT_CALL(mock, OnNavigateComplete2(_, | |
| 1254 testing::Field(&VARIANT::bstrVal, | |
| 1255 testing::StrCaseEq(kHostBrowserUrl)))) | |
| 1256 .Times(1) | |
| 1257 .WillOnce(TypeUrlInAddressBar(&loop, kSubFrameUrl1, 1500)); | |
| 1258 | |
| 1259 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kHostBrowserUrl))) | |
| 1260 .Times(0); | |
| 1261 | |
| 1262 mock.ExpectNavigationAndSwitch(kSubFrameUrl1); | |
| 1263 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 1264 .WillOnce(testing::DoAll( | |
| 1265 VerifyAddressBarUrl(&mock), | |
| 1266 CloseBrowserMock(&mock))); | |
| 1267 | |
| 1268 EXPECT_CALL(mock, OnQuit()) | |
| 1269 .Times(testing::AtMost(1)) | |
| 1270 .WillOnce(QUIT_LOOP(loop)); | |
| 1271 | |
| 1272 HRESULT hr = mock.LaunchIEAndNavigate(kHostBrowserUrl); | |
| 1273 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1274 if (hr == S_FALSE) | |
| 1275 return; | |
| 1276 | |
| 1277 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1278 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds * 2); | |
| 1279 } | |
| 1280 | |
| 1281 // Test has been disabled as it causes the IE8 bot to hang at times. | |
| 1282 // http://crbug.com/47596 | |
| 1283 TEST(IEPrivacy, DISABLED_NavigationToRestrictedSite) { | |
| 1284 if (IsIBrowserServicePatchEnabled()) { | |
| 1285 LOG(ERROR) << "Not running test. IBrowserServicePatch is in place."; | |
| 1286 return; | |
| 1287 } | |
| 1288 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1289 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1290 chrome_frame_test::TimedMsgLoop loop; | |
| 1291 ChromeFrameHTTPServer server; | |
| 1292 server.SetUp(); | |
| 1293 | |
| 1294 ScopedComPtr<IInternetSecurityManager> security_manager; | |
| 1295 HRESULT hr = security_manager.CreateInstance(CLSID_InternetSecurityManager); | |
| 1296 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1297 // Add localhost to restricted sites zone. | |
| 1298 hr = security_manager->SetZoneMapping(URLZONE_UNTRUSTED, | |
| 1299 L"http://localhost:1337", SZM_CREATE); | |
| 1300 | |
| 1301 EXPECT_CALL(mock, OnFileDownload(_, _)) | |
| 1302 .Times(testing::AnyNumber()); | |
| 1303 | |
| 1304 ProtocolPatchMethod patch_method = GetPatchMethod(); | |
| 1305 | |
| 1306 const wchar_t* url = L"http://localhost:1337/files/meta_tag.html"; | |
| 1307 const wchar_t* kDialogClass = L"#32770"; | |
| 1308 | |
| 1309 EXPECT_CALL(mock, OnBeforeNavigate2(_, | |
| 1310 testing::Field(&VARIANT::bstrVal, | |
| 1311 testing::StrCaseEq(url)), _, _, _, _, _)) | |
| 1312 .Times(1) | |
| 1313 .WillOnce(WatchWindow(&mock, kDialogClass)); | |
| 1314 | |
| 1315 if (patch_method == PATCH_METHOD_INET_PROTOCOL) { | |
| 1316 EXPECT_CALL(mock, OnBeforeNavigate2(_, | |
| 1317 testing::Field(&VARIANT::bstrVal, | |
| 1318 testing::HasSubstr(L"res://")), _, _, _, _, _)) | |
| 1319 .Times(1); | |
| 1320 } | |
| 1321 | |
| 1322 EXPECT_CALL(mock, OnNavigateComplete2(_, | |
| 1323 testing::Field(&VARIANT::bstrVal, testing::StrCaseEq(url)))) | |
| 1324 .Times(testing::AtMost(1)); | |
| 1325 | |
| 1326 const char* kAlertDlgCaption = "Security Alert"; | |
| 1327 EXPECT_CALL(mock, OnWindowDetected(_, testing::StrEq(kAlertDlgCaption))) | |
| 1328 .Times(1) | |
| 1329 .WillOnce(testing::DoAll( | |
| 1330 DoCloseWindow(), | |
| 1331 QUIT_LOOP_SOON(loop, 1))); | |
| 1332 | |
| 1333 EXPECT_CALL(mock, OnLoad(_)).Times(0); | |
| 1334 | |
| 1335 hr = mock.LaunchIEAndNavigate(url); | |
| 1336 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1337 if (hr == S_OK) { | |
| 1338 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1339 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds * 2); | |
| 1340 } | |
| 1341 | |
| 1342 ASSERT_HRESULT_SUCCEEDED(security_manager->SetZoneMapping(URLZONE_UNTRUSTED, | |
| 1343 L"http://localhost:1337", SZM_DELETE)); | |
| 1344 } | |
| 1345 | |
| 1346 // See bug 36694 for details. http://crbug.com/36694 | |
| 1347 TEST_F(ChromeFrameTestWithWebServer, | |
| 1348 DISABLED_FullTabModeIE_TestDownloadFromForm) { | |
| 1349 if (IsIBrowserServicePatchEnabled()) { | |
| 1350 LOG(ERROR) << "Not running test. IBrowserServicePatch is in place."; | |
| 1351 return; | |
| 1352 } | |
| 1353 | |
| 1354 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1355 | |
| 1356 // The content of our HTML test page. This will be returned whenever | |
| 1357 // we reply to a GET request. | |
| 1358 static const char kHtml[] = | |
| 1359 "<html><head>\n" | |
| 1360 "<title>ChromeFrame Form Download Test</title>\n" | |
| 1361 // To see how this test runs with only IE (no CF in the picture), comment | |
| 1362 // out this meta tag. The outcome of the test should be identical. | |
| 1363 "<meta http-equiv=\"X-UA-Compatible\" content=\"chrome=1\" />\n" | |
| 1364 "</head>\n" | |
| 1365 "<script language=\"javascript\">\n" | |
| 1366 "function SubmitForm() {\n" | |
| 1367 " var form = document.forms['myform'];\n" | |
| 1368 " form.action = document.location;\n" | |
| 1369 " form.submit();\n" | |
| 1370 " return true;\n" | |
| 1371 "}\n" | |
| 1372 "</script>\n" | |
| 1373 "<body onload=\"SubmitForm();\">\n" | |
| 1374 "<form method=\"post\" action=\"foo.html\" id=\"myform\">\n" | |
| 1375 " <input type=\"hidden\" name=\"Field1\" value=\"myvalue\" />\n" | |
| 1376 " <input type=\"button\" name=\"btn\" value=\"Test Download\" " | |
| 1377 "onclick=\"return SubmitForm();\" id=\"Button1\"/>\n" | |
| 1378 "</form></body></html>\n"; | |
| 1379 | |
| 1380 // The content of our HTML test page. This will be returned whenever | |
| 1381 // we reply to a POST request. | |
| 1382 static const char kText[] = | |
| 1383 "This is a text file (in case you were wondering)."; | |
| 1384 | |
| 1385 // This http response class will return an HTML document that contains | |
| 1386 // a form whenever it receives a GET request. Whenever it gets a POST | |
| 1387 // request, it will respond with a text file that needs to be downloaded | |
| 1388 // (content-disposition is "attachment"). | |
| 1389 class CustomResponse : public test_server::ResponseForPath { | |
| 1390 public: | |
| 1391 explicit CustomResponse(const char* path) | |
| 1392 : test_server::ResponseForPath(path), is_post_(false), | |
| 1393 post_requests_(0), get_requests_(0) { | |
| 1394 } | |
| 1395 | |
| 1396 virtual bool GetContentType(std::string* content_type) const { | |
| 1397 DCHECK(!is_post_); | |
| 1398 return false; | |
| 1399 } | |
| 1400 | |
| 1401 virtual size_t ContentLength() const { | |
| 1402 DCHECK(!is_post_); | |
| 1403 return sizeof(kHtml) - 1; | |
| 1404 } | |
| 1405 | |
| 1406 virtual bool GetCustomHeaders(std::string* headers) const { | |
| 1407 if (!is_post_) | |
| 1408 return false; | |
| 1409 *headers = StringPrintf( | |
| 1410 "HTTP/1.1 200 OK\r\n" | |
| 1411 "Content-Disposition: attachment;filename=\"test.txt\"\r\n" | |
| 1412 "Content-Type: application/text\r\n" | |
| 1413 "Connection: close\r\n" | |
| 1414 "Content-Length: %i\r\n\r\n", sizeof(kText) - 1); | |
| 1415 return true; | |
| 1416 } | |
| 1417 | |
| 1418 virtual bool Matches(const test_server::Request& r) const { | |
| 1419 bool match = __super::Matches(r); | |
| 1420 if (match) { | |
| 1421 is_post_ = LowerCaseEqualsASCII(r.method().c_str(), "post"); | |
| 1422 } | |
| 1423 return match; | |
| 1424 } | |
| 1425 | |
| 1426 virtual void WriteContents(ListenSocket* socket) const { | |
| 1427 if (is_post_) { | |
| 1428 socket->Send(kText, sizeof(kText) - 1, false); | |
| 1429 } else { | |
| 1430 socket->Send(kHtml, sizeof(kHtml) - 1, false); | |
| 1431 } | |
| 1432 } | |
| 1433 | |
| 1434 virtual void IncrementAccessCounter() { | |
| 1435 __super::IncrementAccessCounter(); | |
| 1436 if (is_post_) { | |
| 1437 post_requests_++; | |
| 1438 } else { | |
| 1439 get_requests_++; | |
| 1440 } | |
| 1441 } | |
| 1442 | |
| 1443 size_t get_request_count() const { | |
| 1444 return get_requests_; | |
| 1445 } | |
| 1446 | |
| 1447 size_t post_request_count() const { | |
| 1448 return get_requests_; | |
| 1449 } | |
| 1450 | |
| 1451 protected: | |
| 1452 mutable bool is_post_; | |
| 1453 size_t post_requests_; | |
| 1454 size_t get_requests_; | |
| 1455 }; | |
| 1456 | |
| 1457 chrome_frame_test::TimedMsgLoop loop; // must come before the server. | |
| 1458 SimpleWebServerTest server(46664); | |
| 1459 CustomResponse* response = new CustomResponse("/form.html"); | |
| 1460 server.web_server()->AddResponse(response); | |
| 1461 | |
| 1462 std::wstring url(server.FormatHttpPath(L"form.html")); | |
| 1463 | |
| 1464 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1465 | |
| 1466 // Will get called twice. Once for HTML, once for the download. | |
| 1467 EXPECT_CALL(mock, OnBeforeNavigate2(_, | |
| 1468 testing::Field(&VARIANT::bstrVal, | |
| 1469 testing::StrCaseEq(url)), _, _, _, _, _)).Times(2); | |
| 1470 // Will get called twice in the case of CF, once if no CF. | |
| 1471 EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) | |
| 1472 .Times(testing::AnyNumber()); | |
| 1473 EXPECT_CALL(mock, OnNavigateComplete2(_, | |
| 1474 testing::Field(&VARIANT::bstrVal, testing::StrCaseEq(url)))) | |
| 1475 .Times(testing::AnyNumber()); | |
| 1476 EXPECT_CALL(mock, OnFileDownload(VARIANT_FALSE, _)) | |
| 1477 .Times(testing::AnyNumber()) | |
| 1478 .WillRepeatedly(CloseBrowserMock(&mock)); | |
| 1479 | |
| 1480 EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop)); | |
| 1481 | |
| 1482 HRESULT hr = mock.LaunchIEAndNavigate(url); | |
| 1483 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1484 if (hr == S_OK) { | |
| 1485 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1486 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds * 2); | |
| 1487 } | |
| 1488 | |
| 1489 EXPECT_EQ(1, response->get_request_count()); | |
| 1490 EXPECT_EQ(1, response->post_request_count()); | |
| 1491 } | |
| 1492 | |
| 1493 // This test validates that typing in URLs with a fragment in them switch to | |
| 1494 // to ChromeFrame correctly. | |
| 1495 TEST_F(ChromeFrameTestWithWebServer, | |
| 1496 FLAKY_FullTabModeIE_AltD_AnchorUrlNavigate) { | |
| 1497 if (IsIBrowserServicePatchEnabled()) { | |
| 1498 LOG(ERROR) << "Not running test. IBrowserServicePatch is in place."; | |
| 1499 return; | |
| 1500 } | |
| 1501 | |
| 1502 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1503 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1504 chrome_frame_test::TimedMsgLoop loop; | |
| 1505 ::testing::InSequence sequence; | |
| 1506 | |
| 1507 mock.ExpectNavigationAndSwitchSequence(kSubFrameUrl1); | |
| 1508 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kSubFrameUrl1))) | |
| 1509 .WillOnce(testing::DoAll( | |
| 1510 SetFocusToChrome(&mock), | |
| 1511 TypeUrlInAddressBar(&loop, kAnchor1Url, 1500))); | |
| 1512 | |
| 1513 mock.ExpectNavigationAndSwitchSequence(kAnchor1Url); | |
| 1514 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kAnchor1Url))) | |
| 1515 .WillOnce(CloseBrowserMock(&mock)); | |
| 1516 | |
| 1517 EXPECT_CALL(mock, OnQuit()) | |
| 1518 .Times(testing::AtMost(1)) | |
| 1519 .WillOnce(QUIT_LOOP(loop)); | |
| 1520 | |
| 1521 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | |
| 1522 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1523 if (hr == S_FALSE) | |
| 1524 return; | |
| 1525 | |
| 1526 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1527 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 1528 } | |
| 1529 | |
| 1530 // This test checks if window.open calls issued by a full tab mode ChromeFrame | |
| 1531 // instance make it back to IE and then transitions back to Chrome as the | |
| 1532 // window.open target page is supposed to render within Chrome and whether this | |
| 1533 // window can be closed correctly. | |
| 1534 // Marking this test as FLAKY initially as it relies on getting focus and user | |
| 1535 // input which don't work correctly at times. | |
| 1536 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
| 1537 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_WindowCloseInChrome) { | |
| 1538 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1539 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1540 ComStackObjectWithUninitialize<MockWebBrowserEventSink> new_window_mock; | |
| 1541 chrome_frame_test::TimedMsgLoop loop; | |
| 1542 | |
| 1543 mock.ExpectNavigationAndSwitch(kWindowOpenUrl); | |
| 1544 | |
| 1545 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kWindowOpenUrl))) | |
| 1546 .WillOnce(testing::DoAll( | |
| 1547 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::LEFT), | |
| 1548 DelaySendChar(&loop, 500, 'O', simulate_input::NONE))); | |
| 1549 // Watch for new window | |
| 1550 mock.ExpectNewWindow(&new_window_mock); | |
| 1551 | |
| 1552 EXPECT_CALL(new_window_mock, OnLoad(testing::StrCaseEq(kWindowOpenPopupUrl))) | |
| 1553 .WillOnce(testing::DoAll( | |
| 1554 VerifyAddressBarUrl(&new_window_mock), | |
| 1555 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::LEFT), | |
| 1556 DelaySendChar(&loop, 500, 'C', simulate_input::NONE))); | |
| 1557 | |
| 1558 EXPECT_CALL(new_window_mock, OnQuit()) | |
| 1559 .Times(testing::AtMost(1)) | |
| 1560 .WillOnce(CloseBrowserMock(&mock)); | |
| 1561 | |
| 1562 EXPECT_CALL(mock, OnQuit()) | |
| 1563 .Times(testing::AtMost(1)) | |
| 1564 .WillOnce(QUIT_LOOP_SOON(loop, 2)); | |
| 1565 | |
| 1566 HRESULT hr = mock.LaunchIEAndNavigate(kWindowOpenUrl); | |
| 1567 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1568 if (hr == S_FALSE) | |
| 1569 return; | |
| 1570 | |
| 1571 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1572 | |
| 1573 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 1574 } | |
| 1575 | |
| 1576 const wchar_t kWindowOpenTargetBlankUrl[] = | |
| 1577 L"http://localhost:1337/files/chrome_frame_target_blank.html"; | |
| 1578 | |
| 1579 // This test checks if window.open calls with target blank issued for a | |
| 1580 // different domain make it back to IE instead of completing the navigation | |
| 1581 // within Chrome. We validate this by initiating a navigation to a non existent | |
| 1582 // url which ensures we would get an error during navigation. | |
| 1583 // Marking this test as FLAKY initially as it relies on getting focus and user | |
| 1584 // input which don't work correctly at times. | |
| 1585 // http://code.google.com/p/chromium/issues/detail?id=26549 | |
| 1586 TEST_F(ChromeFrameTestWithWebServer, | |
| 1587 FLAKY_FullTabModeIE_WindowOpenTargetBlankInChrome) { | |
| 1588 CloseIeAtEndOfScope last_resort_close_ie; | |
| 1589 ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; | |
| 1590 ComStackObjectWithUninitialize<MockWebBrowserEventSink> new_window_mock; | |
| 1591 chrome_frame_test::TimedMsgLoop loop; | |
| 1592 | |
| 1593 mock.ExpectNavigationAndSwitch(kWindowOpenTargetBlankUrl); | |
| 1594 | |
| 1595 EXPECT_CALL(mock, OnLoad(testing::StrCaseEq(kWindowOpenTargetBlankUrl))) | |
| 1596 .WillOnce(testing::DoAll( | |
| 1597 DelaySendMouseClick(&mock, &loop, 0, 10, 10, simulate_input::LEFT), | |
| 1598 DelaySendChar(&loop, 500, 'O', simulate_input::NONE))); | |
| 1599 // Watch for new window | |
| 1600 mock.ExpectNewWindow(&new_window_mock); | |
| 1601 | |
| 1602 EXPECT_CALL(new_window_mock, OnBeforeNavigate2(_, | |
| 1603 testing::Field(&VARIANT::bstrVal, | |
| 1604 testing::HasSubstr(L"attach_external_tab")), _, _, _, _, _)) | |
| 1605 .Times(testing::AtMost(1)); | |
| 1606 | |
| 1607 EXPECT_CALL(new_window_mock, OnBeforeNavigate2(_, | |
| 1608 testing::Field(&VARIANT::bstrVal, | |
| 1609 testing::StrCaseEq(kHostBrowserUrl)), _, _, _, _, _)) | |
| 1610 .Times(testing::AtMost(1)); | |
| 1611 | |
| 1612 EXPECT_CALL(new_window_mock, OnNavigateError(_, _, _, _, _)) | |
| 1613 .Times(1) | |
| 1614 .WillOnce(CloseBrowserMock(&new_window_mock)); | |
| 1615 | |
| 1616 EXPECT_CALL(new_window_mock, OnQuit()) | |
| 1617 .Times(1) | |
| 1618 .WillOnce(CloseBrowserMock(&mock)); | |
| 1619 | |
| 1620 EXPECT_CALL(mock, OnQuit()) | |
| 1621 .Times(1) | |
| 1622 .WillOnce(QUIT_LOOP(loop)); | |
| 1623 | |
| 1624 HRESULT hr = mock.LaunchIEAndNavigate(kWindowOpenTargetBlankUrl); | |
| 1625 ASSERT_HRESULT_SUCCEEDED(hr); | |
| 1626 if (hr == S_FALSE) | |
| 1627 return; | |
| 1628 | |
| 1629 ASSERT_TRUE(mock.web_browser2() != NULL); | |
| 1630 | |
| 1631 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds * 2); | |
| 1632 | |
| 1633 ASSERT_TRUE(new_window_mock.web_browser2() != NULL); | |
| 1634 } | |
| 1635 | |
| OLD | NEW |