| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #include <windows.h> | 4 #include <windows.h> |
| 5 #include <stdarg.h> | 5 #include <stdarg.h> |
| 6 | 6 |
| 7 // IShellWindows includes. Unfortunately we can't keep these in | 7 // IShellWindows includes. Unfortunately we can't keep these in |
| 8 // alphabetic order since exdisp will bark if some interfaces aren't fully | 8 // alphabetic order since exdisp will bark if some interfaces aren't fully |
| 9 // defined. | 9 // defined. |
| 10 #include <mshtml.h> | 10 #include <mshtml.h> |
| (...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 | 841 |
| 842 // MessageLoopForUI wrapper that runs only for a limited time. | 842 // MessageLoopForUI wrapper that runs only for a limited time. |
| 843 // We need a UI message loop in the main thread. | 843 // We need a UI message loop in the main thread. |
| 844 struct TimedMsgLoop { | 844 struct TimedMsgLoop { |
| 845 public: | 845 public: |
| 846 void RunFor(int seconds) { | 846 void RunFor(int seconds) { |
| 847 QuitAfter(seconds); | 847 QuitAfter(seconds); |
| 848 loop_.MessageLoop::Run(); | 848 loop_.MessageLoop::Run(); |
| 849 } | 849 } |
| 850 | 850 |
| 851 void PostDelayedTask( |
| 852 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { |
| 853 loop_.PostDelayedTask(from_here, task, delay_ms); |
| 854 } |
| 855 |
| 851 void Quit() { | 856 void Quit() { |
| 852 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); | 857 loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); |
| 853 } | 858 } |
| 854 | 859 |
| 855 void QuitAfter(int seconds) { | 860 void QuitAfter(int seconds) { |
| 856 loop_.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, 1000 * seconds); | 861 loop_.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, 1000 * seconds); |
| 857 } | 862 } |
| 858 | 863 |
| 859 MessageLoopForUI loop_; | 864 MessageLoopForUI loop_; |
| 860 }; | 865 }; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 } | 1219 } |
| 1215 | 1220 |
| 1216 hr = ::CoCreateInstance(CLSID_InternetExplorer, NULL, | 1221 hr = ::CoCreateInstance(CLSID_InternetExplorer, NULL, |
| 1217 cocreate_flags, IID_IWebBrowser2, | 1222 cocreate_flags, IID_IWebBrowser2, |
| 1218 reinterpret_cast<void**>(web_browser)); | 1223 reinterpret_cast<void**>(web_browser)); |
| 1219 // ~LowIntegrityToken() will switch integrity back to medium. | 1224 // ~LowIntegrityToken() will switch integrity back to medium. |
| 1220 return hr; | 1225 return hr; |
| 1221 } | 1226 } |
| 1222 | 1227 |
| 1223 // WebBrowserEventSink member defines | 1228 // WebBrowserEventSink member defines |
| 1229 void WebBrowserEventSink::Uninitialize() { |
| 1230 chrome_frame_ = NULL; |
| 1231 if (web_browser2_.get()) { |
| 1232 DispEventUnadvise(web_browser2_); |
| 1233 web_browser2_->Quit(); |
| 1234 web_browser2_.Release(); |
| 1235 } |
| 1236 } |
| 1237 |
| 1224 STDMETHODIMP WebBrowserEventSink::OnBeforeNavigate2Internal( | 1238 STDMETHODIMP WebBrowserEventSink::OnBeforeNavigate2Internal( |
| 1225 IDispatch* dispatch, VARIANT* url, VARIANT* flags, | 1239 IDispatch* dispatch, VARIANT* url, VARIANT* flags, |
| 1226 VARIANT* target_frame_name, VARIANT* post_data, VARIANT* headers, | 1240 VARIANT* target_frame_name, VARIANT* post_data, VARIANT* headers, |
| 1227 VARIANT_BOOL* cancel) { | 1241 VARIANT_BOOL* cancel) { |
| 1228 DLOG(INFO) << __FUNCTION__; | 1242 DLOG(INFO) << __FUNCTION__; |
| 1229 // Reset any existing reference to chrome frame since this is a new | 1243 // Reset any existing reference to chrome frame since this is a new |
| 1230 // navigation. | 1244 // navigation. |
| 1231 chrome_frame_ = NULL; | 1245 chrome_frame_ = NULL; |
| 1232 return OnBeforeNavigate2(dispatch, url, flags, target_frame_name, | 1246 return OnBeforeNavigate2(dispatch, url, flags, target_frame_name, |
| 1233 post_data, headers, cancel); | 1247 post_data, headers, cancel); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 VARIANT empty = ScopedVariant::kEmptyVariant; | 1289 VARIANT empty = ScopedVariant::kEmptyVariant; |
| 1276 ScopedVariant url; | 1290 ScopedVariant url; |
| 1277 url.Set(navigate_url.c_str()); | 1291 url.Set(navigate_url.c_str()); |
| 1278 | 1292 |
| 1279 HRESULT hr = S_OK; | 1293 HRESULT hr = S_OK; |
| 1280 hr = web_browser2_->Navigate2(url.AsInput(), &empty, &empty, &empty, &empty); | 1294 hr = web_browser2_->Navigate2(url.AsInput(), &empty, &empty, &empty, &empty); |
| 1281 EXPECT_TRUE(hr == S_OK); | 1295 EXPECT_TRUE(hr == S_OK); |
| 1282 return hr; | 1296 return hr; |
| 1283 } | 1297 } |
| 1284 | 1298 |
| 1299 void WebBrowserEventSink::SetFocusToChrome() { |
| 1300 chrome_frame_test::SetKeyboardFocusToWindow(GetChromeRendererWindow(), 1, 1); |
| 1301 } |
| 1302 |
| 1303 void WebBrowserEventSink::SendInputToChrome( |
| 1304 const std::string& input_string) { |
| 1305 chrome_frame_test::SendInputToWindow(GetChromeRendererWindow(), input_string); |
| 1306 } |
| 1307 |
| 1285 void WebBrowserEventSink::ConnectToChromeFrame() { | 1308 void WebBrowserEventSink::ConnectToChromeFrame() { |
| 1286 DCHECK(web_browser2_); | 1309 DCHECK(web_browser2_); |
| 1287 ScopedComPtr<IShellBrowser> shell_browser; | 1310 ScopedComPtr<IShellBrowser> shell_browser; |
| 1288 DoQueryService(SID_STopLevelBrowser, web_browser2_, | 1311 DoQueryService(SID_STopLevelBrowser, web_browser2_, |
| 1289 shell_browser.Receive()); | 1312 shell_browser.Receive()); |
| 1290 | 1313 |
| 1291 if (shell_browser) { | 1314 if (shell_browser) { |
| 1292 ScopedComPtr<IShellView> shell_view; | 1315 ScopedComPtr<IShellView> shell_view; |
| 1293 shell_browser->QueryActiveShellView(shell_view.Receive()); | 1316 shell_browser->QueryActiveShellView(shell_view.Receive()); |
| 1294 if (shell_view) { | 1317 if (shell_view) { |
| 1295 shell_view->GetItemObject(SVGIO_BACKGROUND, __uuidof(IChromeFrame), | 1318 shell_view->GetItemObject(SVGIO_BACKGROUND, __uuidof(IChromeFrame), |
| 1296 reinterpret_cast<void**>(chrome_frame_.Receive())); | 1319 reinterpret_cast<void**>(chrome_frame_.Receive())); |
| 1297 } | 1320 } |
| 1298 | 1321 |
| 1299 if (chrome_frame_) { | 1322 if (chrome_frame_) { |
| 1300 ScopedVariant onmessage(onmessage_.ToDispatch()); | 1323 ScopedVariant onmessage(onmessage_.ToDispatch()); |
| 1301 ScopedVariant onloaderror(onloaderror_.ToDispatch()); | 1324 ScopedVariant onloaderror(onloaderror_.ToDispatch()); |
| 1302 ScopedVariant onload(onload_.ToDispatch()); | 1325 ScopedVariant onload(onload_.ToDispatch()); |
| 1303 EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onmessage(onmessage)); | 1326 EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onmessage(onmessage)); |
| 1304 EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onloaderror(onloaderror)); | 1327 EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onloaderror(onloaderror)); |
| 1305 EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onload(onload)); | 1328 EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onload(onload)); |
| 1306 } | 1329 } |
| 1307 } | 1330 } |
| 1308 } | 1331 } |
| 1309 | 1332 |
| 1333 HWND WebBrowserEventSink::GetChromeRendererWindow() { |
| 1334 DCHECK(chrome_frame_); |
| 1335 HWND renderer_window = NULL; |
| 1336 ScopedComPtr<IOleWindow> ole_window; |
| 1337 ole_window.QueryFrom(chrome_frame_); |
| 1338 EXPECT_TRUE(ole_window.get()); |
| 1339 |
| 1340 if (ole_window) { |
| 1341 HWND activex_window = NULL; |
| 1342 ole_window->GetWindow(&activex_window); |
| 1343 EXPECT_TRUE(IsWindow(activex_window)); |
| 1344 |
| 1345 // chrome tab window is the first (and the only) child of activex |
| 1346 HWND chrome_tab_window = GetWindow(activex_window, GW_CHILD); |
| 1347 EXPECT_TRUE(IsWindow(chrome_tab_window)); |
| 1348 renderer_window = GetWindow(chrome_tab_window, GW_CHILD); |
| 1349 } |
| 1350 |
| 1351 DCHECK(IsWindow(renderer_window)); |
| 1352 return renderer_window; |
| 1353 } |
| 1354 |
| 1310 const int kChromeFrameLaunchDelay = 5; | 1355 const int kChromeFrameLaunchDelay = 5; |
| 1311 const int kChromeFrameLongNavigationTimeoutInSeconds = 10; | 1356 const int kChromeFrameLongNavigationTimeoutInSeconds = 10; |
| 1312 | 1357 |
| 1313 // This class provides functionality to add expectations to IE full tab mode | 1358 // This class provides functionality to add expectations to IE full tab mode |
| 1314 // tests. | 1359 // tests. |
| 1315 class MockWebBrowserEventSink : public WebBrowserEventSink { | 1360 class MockWebBrowserEventSink : public WebBrowserEventSink { |
| 1316 public: | 1361 public: |
| 1317 // Needed to support PostTask. | 1362 // Needed to support PostTask. |
| 1318 static bool ImplementsThreadSafeReferenceCounting() { | 1363 static bool ImplementsThreadSafeReferenceCounting() { |
| 1319 return true; | 1364 return true; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 TimedMsgLoop loop; | 1546 TimedMsgLoop loop; |
| 1502 | 1547 |
| 1503 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeKeyEventUrl)); | 1548 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeKeyEventUrl)); |
| 1504 | 1549 |
| 1505 // Allow some time for chrome to be launched. | 1550 // Allow some time for chrome to be launched. |
| 1506 loop.RunFor(kChromeFrameLaunchDelay); | 1551 loop.RunFor(kChromeFrameLaunchDelay); |
| 1507 | 1552 |
| 1508 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); | 1553 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); |
| 1509 EXPECT_TRUE(IsWindow(renderer_window)); | 1554 EXPECT_TRUE(IsWindow(renderer_window)); |
| 1510 | 1555 |
| 1556 chrome_frame_test::SetKeyboardFocusToWindow(renderer_window, 1, 1); |
| 1511 chrome_frame_test::SendInputToWindow(renderer_window, "Chrome"); | 1557 chrome_frame_test::SendInputToWindow(renderer_window, "Chrome"); |
| 1512 | 1558 |
| 1513 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 1559 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 1514 | 1560 |
| 1515 chrome_frame_test::CloseAllIEWindows(); | 1561 chrome_frame_test::CloseAllIEWindows(); |
| 1516 ASSERT_TRUE(CheckResultFile(L"FullTab_KeyboardTest", "OK")); | 1562 ASSERT_TRUE(CheckResultFile(L"FullTab_KeyboardTest", "OK")); |
| 1517 } | 1563 } |
| 1518 | 1564 |
| 1519 const wchar_t kSubFrameUrl2[] = | 1565 const wchar_t kSubFrameUrl2[] = |
| 1520 L"http://localhost:1337/files/sub_frame2.html"; | 1566 L"http://localhost:1337/files/sub_frame2.html"; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 | 1639 |
| 1594 // We have reached url 1 and have 0 back & 2 forward entries for url 2 & 3 | 1640 // We have reached url 1 and have 0 back & 2 forward entries for url 2 & 3 |
| 1595 // Go back to url 1 now | 1641 // Go back to url 1 now |
| 1596 EXPECT_CALL(mock, | 1642 EXPECT_CALL(mock, |
| 1597 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, | 1643 OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1598 testing::StrCaseEq(kSubFrameUrl1)), | 1644 testing::StrCaseEq(kSubFrameUrl1)), |
| 1599 _, _, _, _, _)); | 1645 _, _, _, _, _)); |
| 1600 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) | 1646 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1601 .WillOnce(testing::Return()); | 1647 .WillOnce(testing::Return()); |
| 1602 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) | 1648 EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) |
| 1603 .WillOnce(QUIT_LOOP_SOON(loop, 2)); | 1649 .WillOnce(testing::DoAll( |
| 1650 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 1651 &WebBrowserEventSink::Uninitialize)), |
| 1652 testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1653 &chrome_frame_test::CloseAllIEWindows)), |
| 1654 QUIT_LOOP_SOON(loop, 2))); |
| 1604 | 1655 |
| 1605 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); | 1656 HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); |
| 1606 ASSERT_HRESULT_SUCCEEDED(hr); | 1657 ASSERT_HRESULT_SUCCEEDED(hr); |
| 1607 if (hr == S_FALSE) | 1658 if (hr == S_FALSE) |
| 1608 return; | 1659 return; |
| 1609 | 1660 |
| 1610 ASSERT_TRUE(mock.web_browser2() != NULL); | 1661 ASSERT_TRUE(mock.web_browser2() != NULL); |
| 1662 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 1663 } |
| 1611 | 1664 |
| 1612 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | |
| 1613 | |
| 1614 mock.Uninitialize(); | |
| 1615 chrome_frame_test::CloseAllIEWindows(); | |
| 1616 } | |
| 1617 | 1665 |
| 1618 const wchar_t kChromeFrameAboutBlankUrl[] = L"cf:about:blank"; | 1666 const wchar_t kChromeFrameAboutBlankUrl[] = L"cf:about:blank"; |
| 1619 | 1667 |
| 1620 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameFocusTest) { | 1668 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameFocusTest) { |
| 1621 TimedMsgLoop loop; | 1669 TimedMsgLoop loop; |
| 1622 | 1670 |
| 1623 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameAboutBlankUrl)); | 1671 ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameAboutBlankUrl)); |
| 1624 | 1672 |
| 1625 // Allow some time for chrome to be launched. | 1673 // Allow some time for chrome to be launched. |
| 1626 loop.RunFor(kChromeFrameLaunchDelay); | 1674 loop.RunFor(kChromeFrameLaunchDelay); |
| 1627 | 1675 |
| 1628 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); | 1676 HWND renderer_window = chrome_frame_test::GetChromeRendererWindow(); |
| 1629 EXPECT_TRUE(IsWindow(renderer_window)); | 1677 EXPECT_TRUE(IsWindow(renderer_window)); |
| 1630 | 1678 |
| 1631 DWORD renderer_thread_id = 0; | 1679 DWORD renderer_thread_id = 0; |
| 1632 DWORD renderer_process_id = 0; | 1680 DWORD renderer_process_id = 0; |
| 1633 renderer_thread_id = GetWindowThreadProcessId(renderer_window, | 1681 renderer_thread_id = GetWindowThreadProcessId(renderer_window, |
| 1634 &renderer_process_id); | 1682 &renderer_process_id); |
| 1635 | 1683 |
| 1636 AttachThreadInput(GetCurrentThreadId(), renderer_thread_id, TRUE); | 1684 AttachThreadInput(GetCurrentThreadId(), renderer_thread_id, TRUE); |
| 1637 HWND focus_window = GetFocus(); | 1685 HWND focus_window = GetFocus(); |
| 1638 EXPECT_TRUE(focus_window == renderer_window); | 1686 EXPECT_TRUE(focus_window == renderer_window); |
| 1639 AttachThreadInput(GetCurrentThreadId(), renderer_thread_id, FALSE); | 1687 AttachThreadInput(GetCurrentThreadId(), renderer_thread_id, FALSE); |
| 1640 | 1688 |
| 1641 chrome_frame_test::CloseAllIEWindows(); | 1689 chrome_frame_test::CloseAllIEWindows(); |
| 1642 } | 1690 } |
| 1643 | 1691 |
| 1692 const wchar_t kAnchorUrl[] = L"http://localhost:1337/files/anchor.html"; |
| 1693 const wchar_t kAnchor1Url[] = L"http://localhost:1337/files/anchor.html#a1"; |
| 1694 const wchar_t kAnchor2Url[] = L"http://localhost:1337/files/anchor.html#a2"; |
| 1695 const wchar_t kAnchor3Url[] = L"http://localhost:1337/files/anchor.html#a3"; |
| 1696 |
| 1697 // Full tab mode back/forward test |
| 1698 // Launch and navigate chrome frame to a set of URLs and test back forward |
| 1699 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForwardAnchor) { |
| 1700 const char tab_enter_keystrokes[] = { VK_TAB, VK_RETURN, 0 }; |
| 1701 static const std::string tab_enter(tab_enter_keystrokes); |
| 1702 TimedMsgLoop loop; |
| 1703 CComObjectStackEx<MockWebBrowserEventSink> mock; |
| 1704 ::testing::InSequence sequence; // Everything in sequence |
| 1705 |
| 1706 // Back/Forward state at this point: |
| 1707 // Back: 0 |
| 1708 // Forward: 0 |
| 1709 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1710 testing::StrCaseEq(kAnchorUrl)), |
| 1711 _, _, _, _, _)) |
| 1712 .WillOnce(testing::Return(S_OK)); |
| 1713 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1714 .WillOnce(testing::Return()); |
| 1715 |
| 1716 // Navigate to anchor 1: |
| 1717 // - First set focus to chrome renderer window |
| 1718 // Call WebBrowserEventSink::SetFocusToChrome only once |
| 1719 // in the beginning. Calling it again will change focus from the |
| 1720 // current location to an element near the simulated mouse.click. |
| 1721 // - Then send keyboard input of TAB + ENTER to cause navigation. |
| 1722 // It's better to send input as PostDelayedTask since the Activex |
| 1723 // message loop on the other side might be blocked when we get |
| 1724 // called in Onload. |
| 1725 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchorUrl))) |
| 1726 .WillOnce(testing::DoAll( |
| 1727 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 1728 &WebBrowserEventSink::SetFocusToChrome)), |
| 1729 testing::InvokeWithoutArgs(CreateFunctor(&loop, |
| 1730 &TimedMsgLoop::PostDelayedTask, FROM_HERE, NewRunnableMethod( |
| 1731 &mock, &WebBrowserEventSink::SendInputToChrome, |
| 1732 std::string(tab_enter)), 0)))); |
| 1733 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1734 testing::StrCaseEq(kAnchor1Url)), |
| 1735 _, _, _, _, _)) |
| 1736 .WillOnce(testing::Return(S_OK)); |
| 1737 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1738 .WillOnce(testing::Return()); |
| 1739 |
| 1740 // Navigate to anchor 2 after the previous navigation is complete |
| 1741 // Back/Forward state at this point: |
| 1742 // Back: 1 (kAnchorUrl) |
| 1743 // Forward: 0 |
| 1744 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor1Url))) |
| 1745 .WillOnce(testing::InvokeWithoutArgs( |
| 1746 CreateFunctor(&loop, &TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 1747 NewRunnableMethod(&mock, &WebBrowserEventSink::SendInputToChrome, |
| 1748 std::string(tab_enter)), 0))); |
| 1749 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1750 testing::StrCaseEq(kAnchor2Url)), |
| 1751 _, _, _, _, _)) |
| 1752 .WillOnce(testing::Return(S_OK)); |
| 1753 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1754 .WillOnce(testing::Return()); |
| 1755 |
| 1756 // Navigate to anchor 3 after the previous navigation is complete |
| 1757 // Back/Forward state at this point: |
| 1758 // Back: 2 (kAnchorUrl, kAnchor1Url) |
| 1759 // Forward: 0 |
| 1760 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor2Url))) |
| 1761 .WillOnce(testing::InvokeWithoutArgs( |
| 1762 CreateFunctor(&loop, &TimedMsgLoop::PostDelayedTask, FROM_HERE, |
| 1763 NewRunnableMethod(&mock, &WebBrowserEventSink::SendInputToChrome, |
| 1764 std::string(tab_enter)), 0))); |
| 1765 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1766 testing::StrCaseEq(kAnchor3Url)), |
| 1767 _, _, _, _, _)) |
| 1768 .WillOnce(testing::Return(S_OK)); |
| 1769 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1770 .WillOnce(testing::Return()); |
| 1771 |
| 1772 // We will reach anchor 3 once the navigation is complete, |
| 1773 // then go back to anchor 2 |
| 1774 // Back/Forward state at this point: |
| 1775 // Back: 3 (kAnchorUrl, kAnchor1Url, kAnchor2Url) |
| 1776 // Forward: 0 |
| 1777 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor3Url))) |
| 1778 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1779 CreateFunctor(ReceivePointer(mock.web_browser2_), |
| 1780 &IWebBrowser::GoBack)))); |
| 1781 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1782 testing::StrCaseEq(kAnchor2Url)), |
| 1783 _, _, _, _, _)) |
| 1784 .WillOnce(testing::Return(S_OK)); |
| 1785 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1786 .WillOnce(testing::Return()); |
| 1787 |
| 1788 // We will reach anchor 2 once the navigation is complete, |
| 1789 // then go back to anchor 1 |
| 1790 // Back/Forward state at this point: |
| 1791 // Back: 3 (kAnchorUrl, kAnchor1Url, kAnchor2Url) |
| 1792 // Forward: 1 (kAnchor3Url) |
| 1793 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor2Url))) |
| 1794 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1795 CreateFunctor(ReceivePointer(mock.web_browser2_), |
| 1796 &IWebBrowser::GoBack)))); |
| 1797 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1798 testing::StrCaseEq(kAnchor1Url)), |
| 1799 _, _, _, _, _)) |
| 1800 .WillOnce(testing::Return(S_OK)); |
| 1801 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1802 .WillOnce(testing::Return()); |
| 1803 |
| 1804 // We will reach anchor 1 once the navigation is complete, |
| 1805 // now go forward to anchor 2 |
| 1806 // Back/Forward state at this point: |
| 1807 // Back: 2 (kAnchorUrl, kAnchor1Url) |
| 1808 // Forward: 2 (kAnchor2Url, kAnchor3Url) |
| 1809 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor1Url))) |
| 1810 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1811 CreateFunctor(ReceivePointer(mock.web_browser2_), |
| 1812 &IWebBrowser::GoForward)))); |
| 1813 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1814 testing::StrCaseEq(kAnchor2Url)), |
| 1815 _, _, _, _, _)) |
| 1816 .WillOnce(testing::Return(S_OK)); |
| 1817 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1818 .WillOnce(testing::Return()); |
| 1819 |
| 1820 // We have reached anchor 2, go forward to anchor 3 again |
| 1821 // Back/Forward state at this point: |
| 1822 // Back: 3 (kAnchorUrl, kAnchor1Url, kAnchor2Url) |
| 1823 // Forward: 1 (kAnchor3Url) |
| 1824 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor2Url))) |
| 1825 .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1826 CreateFunctor(ReceivePointer(mock.web_browser2_), |
| 1827 &IWebBrowser::GoForward)))); |
| 1828 EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, |
| 1829 testing::StrCaseEq(kAnchor3Url)), |
| 1830 _, _, _, _, _)) |
| 1831 .WillOnce(testing::Return(S_OK)); |
| 1832 EXPECT_CALL(mock, OnNavigateComplete2(_, _)) |
| 1833 .WillOnce(testing::Return()); |
| 1834 |
| 1835 // We have gone a few steps back and forward, this should be enough for now. |
| 1836 EXPECT_CALL(mock, OnLoad(testing::StrEq(kAnchor3Url))) |
| 1837 .WillOnce(testing::DoAll( |
| 1838 testing::InvokeWithoutArgs(CreateFunctor(&mock, |
| 1839 &WebBrowserEventSink::Uninitialize)), |
| 1840 testing::IgnoreResult(testing::InvokeWithoutArgs( |
| 1841 &chrome_frame_test::CloseAllIEWindows)), |
| 1842 QUIT_LOOP_SOON(loop, 2))); |
| 1843 |
| 1844 HRESULT hr = mock.LaunchIEAndNavigate(kAnchorUrl); |
| 1845 ASSERT_HRESULT_SUCCEEDED(hr); |
| 1846 if (hr == S_FALSE) |
| 1847 return; |
| 1848 |
| 1849 ASSERT_TRUE(mock.web_browser2() != NULL); |
| 1850 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
| 1851 } |
| OLD | NEW |