diff options
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.cc | 11 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_unittests.cc | 216 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_unittests.h | 83 | ||||
-rw-r--r-- | chrome_frame/test/data/anchor.html | 51 | ||||
-rw-r--r-- | chrome_frame/test/data/frame_test.html | 18 | ||||
-rw-r--r-- | chrome_frame/test/data/sub_frame1.html | 15 | ||||
-rw-r--r-- | chrome_frame/test/data/sub_frame2.html | 15 | ||||
-rw-r--r-- | chrome_frame/test/data/sub_frame3.html | 15 | ||||
-rw-r--r-- | chrome_frame/test/data/sub_frame4.html | 15 | ||||
-rw-r--r-- | chrome_frame/test/perf/chrome_frame_perftest.cc | 66 |
10 files changed, 407 insertions, 98 deletions
diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 54d18de..cb59615 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -421,7 +421,7 @@ int CloseAllIEWindows() { return ret; } -void ShowChromeFrameContextMenuTask() { +void ShowChromeFrameContextMenu() { static const int kChromeFrameContextMenuTimeout = 500; HWND renderer_window = GetChromeRendererWindow(); EXPECT_TRUE(IsWindow(renderer_window)); @@ -438,15 +438,6 @@ void ShowChromeFrameContextMenuTask() { kChromeFrameContextMenuTimeout); } -void ShowChromeFrameContextMenu() { - static const int kContextMenuDelay = 5000; - - MessageLoop::current()->PostDelayedTask( - FROM_HERE, - NewRunnableFunction(ShowChromeFrameContextMenuTask), - kContextMenuDelay); -} - void SetKeyboardFocusToWindow(HWND window, int x, int y) { if (!IsTopLevelWindow(window)) { window = GetAncestor(window, GA_ROOT); diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc index d43cd52..875695e 100644 --- a/chrome_frame/test/chrome_frame_unittests.cc +++ b/chrome_frame/test/chrome_frame_unittests.cc @@ -24,10 +24,12 @@ #include "chrome_frame/crash_reporting/vectored_handler-impl.h" #include "chrome_frame/test/chrome_frame_test_utils.h" #include "chrome_frame/test_utils.h" -#include "chrome_frame/utils.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/helper.h" + +#define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING #include "testing/gmock_mutant.h" + using testing::CreateFunctor; const wchar_t kDocRoot[] = L"chrome_frame\\test\\data"; @@ -73,6 +75,8 @@ _ATL_FUNC_INFO WebBrowserEventSink::kNewWindow3Info = { } }; +_ATL_FUNC_INFO WebBrowserEventSink::kVoidMethodInfo = { + CC_STDCALL, VT_EMPTY, 0, {NULL}}; void ChromeFrameTestWithWebServer::SetUp() { server_.SetUp(); @@ -1334,8 +1338,45 @@ HRESULT LaunchIEAsComServer(IWebBrowser2** web_browser) { } // WebBrowserEventSink member defines +STDMETHODIMP WebBrowserEventSink::OnBeforeNavigate2Internal( + IDispatch* dispatch, VARIANT* url, VARIANT* flags, + VARIANT* target_frame_name, VARIANT* post_data, VARIANT* headers, + VARIANT_BOOL* cancel) { + DLOG(INFO) << __FUNCTION__; + // Reset any existing reference to chrome frame since this is a new + // navigation. + chrome_frame_ = NULL; + return OnBeforeNavigate2(dispatch, url, flags, target_frame_name, + post_data, headers, cancel); +} + +STDMETHODIMP_(void) WebBrowserEventSink::OnNavigateComplete2Internal( + IDispatch* dispatch, VARIANT* url) { + DLOG(INFO) << __FUNCTION__; + ConnectToChromeFrame(); + OnNavigateComplete2(dispatch, url); +} + +HRESULT WebBrowserEventSink::OnLoadInternal(const VARIANT* param) { + DLOG(INFO) << __FUNCTION__ << " " << param->bstrVal; + OnLoad(param->bstrVal); + return S_OK; +} + +HRESULT WebBrowserEventSink::OnLoadErrorInternal(const VARIANT* param) { + DLOG(INFO) << __FUNCTION__ << " " << param->bstrVal; + OnLoadError(param->bstrVal); + return S_OK; +} + +HRESULT WebBrowserEventSink::OnMessageInternal(const VARIANT* param) { + DLOG(INFO) << __FUNCTION__ << " " << param->bstrVal; + OnMessage(param->bstrVal); + return S_OK; +} + HRESULT WebBrowserEventSink::LaunchIEAndNavigate( - const std::wstring& navigate_url, _IDispEvent* sink) { + const std::wstring& navigate_url) { int major_version = 0; int minor_version = 0; int bugfix_version = 0; @@ -1351,19 +1392,47 @@ HRESULT WebBrowserEventSink::LaunchIEAndNavigate( EXPECT_TRUE(S_OK == LaunchIEAsComServer(web_browser2_.Receive())); web_browser2_->put_Visible(VARIANT_TRUE); - HRESULT hr = sink->DispEventAdvise(web_browser2_, - &DIID_DWebBrowserEvents2); + HRESULT hr = DispEventAdvise(web_browser2_, &DIID_DWebBrowserEvents2); EXPECT_TRUE(hr == S_OK); + return Navigate(navigate_url); +} +HRESULT WebBrowserEventSink::Navigate(const std::wstring& navigate_url) { VARIANT empty = ScopedVariant::kEmptyVariant; ScopedVariant url; url.Set(navigate_url.c_str()); + HRESULT hr = S_OK; hr = web_browser2_->Navigate2(url.AsInput(), &empty, &empty, &empty, &empty); EXPECT_TRUE(hr == S_OK); return hr; } +void WebBrowserEventSink::ConnectToChromeFrame() { + DCHECK(web_browser2_); + ScopedComPtr<IShellBrowser> shell_browser; + DoQueryService(SID_STopLevelBrowser, web_browser2_, + shell_browser.Receive()); + + if (shell_browser) { + ScopedComPtr<IShellView> shell_view; + shell_browser->QueryActiveShellView(shell_view.Receive()); + if (shell_view) { + shell_view->GetItemObject(SVGIO_BACKGROUND, __uuidof(IChromeFrame), + reinterpret_cast<void**>(chrome_frame_.Receive())); + } + + if (chrome_frame_) { + ScopedVariant onmessage(onmessage_.ToDispatch()); + ScopedVariant onloaderror(onloaderror_.ToDispatch()); + ScopedVariant onload(onload_.ToDispatch()); + EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onmessage(onmessage)); + EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onloaderror(onloaderror)); + EXPECT_HRESULT_SUCCEEDED(chrome_frame_->put_onload(onload)); + } + } +} + const int kChromeFrameLaunchDelay = 5; const int kChromeFrameLongNavigationTimeoutInSeconds = 10; @@ -1402,6 +1471,10 @@ class MockWebBrowserEventSink : public WebBrowserEventSink { VARIANT* frame_name, VARIANT* status_code, VARIANT* cancel)); + + MOCK_METHOD1(OnLoad, void (const wchar_t* url)); // NOLINT + MOCK_METHOD1(OnLoadError, void (const wchar_t* url)); // NOLINT + MOCK_METHOD1(OnMessage, void (const wchar_t* message)); // NOLINT }; using testing::_; @@ -1431,7 +1504,7 @@ TEST(ChromeFrameTest, FullTabModeIE_DisallowedUrls) { QUIT_LOOP(loop), testing::Return(S_OK))); - HRESULT hr = mock.LaunchIEAndNavigate(kChromeFrameFileUrl, &mock); + HRESULT hr = mock.LaunchIEAndNavigate(kChromeFrameFileUrl); ASSERT_HRESULT_SUCCEEDED(hr); if (hr == S_FALSE) return; @@ -1455,29 +1528,34 @@ const wchar_t kChromeFrameFullTabWindowOpenPopupUrl[] = // window.open target page is supposed to render within Chrome. TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_WindowOpen) { TimedMsgLoop loop; - CComObjectStackEx<MockWebBrowserEventSink> mock; + ::testing::InSequence sequence; EXPECT_CALL(mock, OnBeforeNavigate2( _, testing::Field(&VARIANT::bstrVal, testing::StrCaseEq(kChromeFrameFullTabWindowOpenTestUrl)), _, _, _, _, _)) - .Times(1) .WillOnce(testing::Return(S_OK)); + EXPECT_CALL(mock, OnNavigateComplete2(_, _)) + .WillOnce(testing::Return()); + EXPECT_CALL(mock, + OnLoad(testing::StrEq(kChromeFrameFullTabWindowOpenTestUrl))) + .WillOnce(testing::Return()); EXPECT_CALL(mock, OnBeforeNavigate2( _, testing::Field(&VARIANT::bstrVal, testing::StrCaseEq(kChromeFrameFullTabWindowOpenPopupUrl)), _, _, _, _, _)) - .Times(1) - .WillOnce(testing::DoAll( - QUIT_LOOP_SOON(loop, 2), - testing::Return(S_OK))); + .WillOnce(testing::Return(S_OK)); + EXPECT_CALL(mock, OnNavigateComplete2(_, _)) + .WillOnce(testing::Return()); + EXPECT_CALL(mock, + OnLoad(testing::StrEq(kChromeFrameFullTabWindowOpenPopupUrl))) + .WillOnce(QUIT_LOOP_SOON(loop, 2)); - HRESULT hr = mock.LaunchIEAndNavigate(kChromeFrameFullTabWindowOpenTestUrl, - &mock); + HRESULT hr = mock.LaunchIEAndNavigate(kChromeFrameFullTabWindowOpenTestUrl); ASSERT_HRESULT_SUCCEEDED(hr); if (hr == S_FALSE) return; @@ -1492,8 +1570,8 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_WindowOpen) { chrome_frame_test::CloseAllIEWindows(); } -const wchar_t kChromeFrameAboutBlankUrl[] = - L"cf:about:blank"; +const wchar_t kSubFrameUrl1[] = + L"http://localhost:1337/files/sub_frame1.html"; const wchar_t kChromeFrameAboutVersion[] = L"cf:about:version"; @@ -1510,18 +1588,17 @@ const wchar_t kChromeFrameAboutVersion[] = // http://code.google.com/p/chromium/issues/detail?id=26549 TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_AboutChromeFrame) { TimedMsgLoop loop; - CComObjectStackEx<MockWebBrowserEventSink> mock; EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, - testing::StrCaseEq(kChromeFrameAboutBlankUrl)), + testing::StrCaseEq(kSubFrameUrl1)), _, _, _, _, _)) .Times(1) .WillOnce(testing::Return(S_OK)); - EXPECT_CALL(mock, OnNavigateComplete2(_, _)) - .Times(1) + .WillOnce(testing::Return()); + EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) .WillOnce(testing::InvokeWithoutArgs( &chrome_frame_test::ShowChromeFrameContextMenu)); @@ -1531,7 +1608,7 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_AboutChromeFrame) { .Times(1) .WillOnce(QUIT_LOOP(loop)); - HRESULT hr = mock.LaunchIEAndNavigate(kChromeFrameAboutBlankUrl, &mock); + HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); ASSERT_HRESULT_SUCCEEDED(hr); if (hr == S_FALSE) return; @@ -1565,3 +1642,102 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameKeyboardTest) { ASSERT_TRUE(CheckResultFile(L"FullTab_KeyboardTest", "OK")); } +const wchar_t kSubFrameUrl2[] = + L"http://localhost:1337/files/sub_frame2.html"; +const wchar_t kSubFrameUrl3[] = + L"http://localhost:1337/files/sub_frame3.html"; + +// Hack to pass a reference to the argument instead of value. Passing by +// value evaluates the argument at the mock specification time which is +// not always ideal. For e.g. At the time of mock creation, web_browser2_ +// pointer is not set up yet so by passing a reference to it instead of +// a value we allow it to be created later. +template <typename T> T** ReceivePointer(scoped_refptr<T>& p) { // NOLINT + return reinterpret_cast<T**>(&p); +} + +// Full tab mode back/forward test +// Launch and navigate chrome frame to a set of URLs and test back forward +TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { + TimedMsgLoop loop; + CComObjectStackEx<MockWebBrowserEventSink> mock; + ::testing::InSequence sequence; // Everything in sequence + + // Navigate to url 2 after the previous navigation is complete + EXPECT_CALL(mock, + OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, + testing::StrCaseEq(kSubFrameUrl1)), + _, _, _, _, _)) + .WillOnce(testing::Return(S_OK)); + EXPECT_CALL(mock, OnNavigateComplete2(_, _)) + .WillOnce(testing::Return()); + EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) + .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( + CreateFunctor(&mock, &WebBrowserEventSink::Navigate, + std::wstring(kSubFrameUrl2))))); + + // Navigate to url 3 after the previous navigation is complete + EXPECT_CALL(mock, + OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, + testing::StrCaseEq(kSubFrameUrl2)), + _, _, _, _, _)) + .WillOnce(testing::Return(S_OK)); + EXPECT_CALL(mock, OnNavigateComplete2(_, _)) + .WillOnce(testing::Return()); + EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl2))) + .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( + CreateFunctor(&mock, &WebBrowserEventSink::Navigate, + std::wstring(kSubFrameUrl3))))); + + // We have reached url 3 and have two back entries for url 1 & 2 + // Go back to url 2 now + EXPECT_CALL(mock, + OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, + testing::StrCaseEq(kSubFrameUrl3)), + _, _, _, _, _)) + .WillOnce(testing::Return(S_OK)); + EXPECT_CALL(mock, OnNavigateComplete2(_, _)) + .WillOnce(testing::Return()); + EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl3))) + .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( + CreateFunctor(ReceivePointer(mock.web_browser2_), + &IWebBrowser::GoBack)))); + + // We have reached url 2 and have 1 back & 1 forward entries for url 1 & 3 + // Go back to url 1 now + EXPECT_CALL(mock, + OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, + testing::StrCaseEq(kSubFrameUrl2)), + _, _, _, _, _)) + .WillOnce(testing::Return(S_OK)); + EXPECT_CALL(mock, OnNavigateComplete2(_, _)) + .WillOnce(testing::Return()); + EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl2))) + .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( + CreateFunctor(ReceivePointer(mock.web_browser2_), + &IWebBrowser::GoBack)))); + + // We have reached url 1 and have 0 back & 2 forward entries for url 2 & 3 + // Go back to url 1 now + EXPECT_CALL(mock, + OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, + testing::StrCaseEq(kSubFrameUrl1)), + _, _, _, _, _)); + EXPECT_CALL(mock, OnNavigateComplete2(_, _)) + .WillOnce(testing::Return()); + EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) + .WillOnce(QUIT_LOOP_SOON(loop, 2)); + + HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); + ASSERT_HRESULT_SUCCEEDED(hr); + if (hr == S_FALSE) + return; + + ASSERT_TRUE(mock.web_browser2() != NULL); + + loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + + mock.Uninitialize(); + chrome_frame_test::CloseAllIEWindows(); +} + diff --git a/chrome_frame/test/chrome_frame_unittests.h b/chrome_frame/test/chrome_frame_unittests.h index 9dcaadc..7ecdf50 100644 --- a/chrome_frame/test/chrome_frame_unittests.h +++ b/chrome_frame/test/chrome_frame_unittests.h @@ -9,14 +9,24 @@ #include <string> #include <exdisp.h> #include <exdispid.h> +#include <mshtml.h> +#include <shlguid.h> +#include <shobjidl.h> +#include "base/compiler_specific.h" #include "base/ref_counted.h" #include "base/scoped_comptr_win.h" +#include "base/scoped_variant_win.h" #include "base/scoped_handle_win.h" #include "googleurl/src/gurl.h" #include "chrome_frame/test/http_server.h" +#include "chrome_frame/test_utils.h" +#include "chrome_frame/utils.h" #include "testing/gtest/include/gtest/gtest.h" +// Include without path to make GYP build see it. +#include "chrome_tab.h" // NOLINT + // Class that: // 1) Starts the local webserver, // 2) Supports launching browsers - Internet Explorer and Firefox with local url @@ -105,35 +115,50 @@ class WebBrowserEventSink public: typedef IDispEventSimpleImpl<0, WebBrowserEventSink, &DIID_DWebBrowserEvents2> DispEventsImpl; - WebBrowserEventSink() {} + WebBrowserEventSink() + : ALLOW_THIS_IN_INITIALIZER_LIST( + onmessage_(this, &WebBrowserEventSink::OnMessageInternal)), + ALLOW_THIS_IN_INITIALIZER_LIST( + onloaderror_(this, &WebBrowserEventSink::OnLoadErrorInternal)), + ALLOW_THIS_IN_INITIALIZER_LIST( + onload_(this, &WebBrowserEventSink::OnLoadInternal)) { + } + ~WebBrowserEventSink() { Uninitialize(); } void Uninitialize() { + chrome_frame_ = NULL; if (web_browser2_.get()) { DispEventUnadvise(web_browser2_); + web_browser2_->Quit(); web_browser2_.Release(); + // Give IE some time to quit and release our references + Sleep(1000); } } // Helper function to launch IE and navigate to a URL. // Returns S_OK on success, S_FALSE if the test was not run, other // errors on failure. - HRESULT LaunchIEAndNavigate(const std::wstring& navigate_url, - _IDispEvent* sink); + HRESULT LaunchIEAndNavigate(const std::wstring& navigate_url); + + HRESULT Navigate(const std::wstring& navigate_url); BEGIN_COM_MAP(WebBrowserEventSink) END_COM_MAP() BEGIN_SINK_MAP(WebBrowserEventSink) - SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, - OnBeforeNavigate2, &kBeforeNavigate2Info) - SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_NAVIGATECOMPLETE2, - OnNavigateComplete2, &kNavigateComplete2Info) - SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_NAVIGATEERROR, + SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, + OnBeforeNavigate2Internal, &kBeforeNavigate2Info) + SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_DOWNLOADBEGIN, + OnDownloadBegin, &kVoidMethodInfo) + SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_NAVIGATECOMPLETE2, + OnNavigateComplete2Internal, &kNavigateComplete2Info) + SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_NAVIGATEERROR, OnNavigateError, &kNavigateErrorInfo) - SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_NEWWINDOW3, + SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_NEWWINDOW3, OnNewWindow3, &kNewWindow3Info) END_SINK_MAP() @@ -147,18 +172,20 @@ END_SINK_MAP() flags, VARIANT* target_frame_name, VARIANT* post_data, VARIANT* headers, VARIANT_BOOL* cancel) { - DLOG(INFO) << __FUNCTION__; return S_OK; } - STDMETHOD_(void, OnNavigateComplete2)(IDispatch* dispatch, VARIANT* url) { - DLOG(INFO) << __FUNCTION__; - } - + STDMETHOD(OnBeforeNavigate2Internal)(IDispatch* dispatch, VARIANT* url, + VARIANT* flags, + VARIANT* target_frame_name, + VARIANT* post_data, VARIANT* headers, + VARIANT_BOOL* cancel); + STDMETHOD_(void, OnDownloadBegin)() {} + STDMETHOD_(void, OnNavigateComplete2Internal)(IDispatch* dispatch, + VARIANT* url); + STDMETHOD_(void, OnNavigateComplete2)(IDispatch* dispatch, VARIANT* url) {} STDMETHOD_(void, OnNewWindow3)(IDispatch** dispatch, VARIANT_BOOL* Cancel, - DWORD flags, BSTR url_context, BSTR url) { - DLOG(INFO) << __FUNCTION__; - } + DWORD flags, BSTR url_context, BSTR url) {} #ifdef _DEBUG STDMETHOD(Invoke)(DISPID dispid, REFIID riid, @@ -170,16 +197,36 @@ END_SINK_MAP() } #endif // _DEBUG + // Chrome frame callbacks + virtual void OnLoad(const wchar_t* url) {} + virtual void OnLoadError(const wchar_t* url) {} + virtual void OnMessage(const wchar_t* message) {} + IWebBrowser2* web_browser2() { return web_browser2_.get(); } protected: + // IChromeFrame callbacks + HRESULT OnLoadInternal(const VARIANT* param); + HRESULT OnLoadErrorInternal(const VARIANT* param); + HRESULT OnMessageInternal(const VARIANT* param); + + void ConnectToChromeFrame(); + + public: + ScopedComPtr<IWebBrowser2> web_browser2_; + ScopedComPtr<IChromeFrame> chrome_frame_; + DispCallback<WebBrowserEventSink> onmessage_; + DispCallback<WebBrowserEventSink> onloaderror_; + DispCallback<WebBrowserEventSink> onload_; + + protected: static _ATL_FUNC_INFO kBeforeNavigate2Info; static _ATL_FUNC_INFO kNavigateComplete2Info; static _ATL_FUNC_INFO kNavigateErrorInfo; static _ATL_FUNC_INFO kNewWindow3Info; - ScopedComPtr<IWebBrowser2> web_browser2_; + static _ATL_FUNC_INFO kVoidMethodInfo; }; #endif // CHROME_FRAME_TEST_CHROME_FRAME_UNITTESTS_H_ diff --git a/chrome_frame/test/data/anchor.html b/chrome_frame/test/data/anchor.html new file mode 100644 index 0000000..2687982 --- /dev/null +++ b/chrome_frame/test/data/anchor.html @@ -0,0 +1,51 @@ +<HTML> + <HEAD> + <meta http-equiv="X-UA-Compatible" content="chrome=1" /> + <TITLE> Chrome Frame Test </TITLE> + </HEAD> + <BODY> + Chrome trame in tab mode + + Jump to different named sections here + <a href="#a1">Jump to A1</a> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <a name="a1"> A1 </a> + <a href="#a2">Jump to A2</a> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <a name="a2"> A2 </a> + <a href="#a3">Jump to A3</a> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <a name="a3"> A3 </a> + <a href="#a4">Jump to A4</a> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> + <a name="a4"> A4 </a> + </BODY> +</HTML> diff --git a/chrome_frame/test/data/frame_test.html b/chrome_frame/test/data/frame_test.html new file mode 100644 index 0000000..fc6e6f9 --- /dev/null +++ b/chrome_frame/test/data/frame_test.html @@ -0,0 +1,18 @@ +<html> + <head> + <meta http-equiv="x-ua-compatible" content="chrome=1" /> + </head> + <body> + <p> Frames </p> + Test of sub frame navigation + <P> <A href="sub_frame1.html" target="x">Frame 1</A> </p> + <P> <A href="sub_frame2.html" target="x">Frame 2</A> </p> + <P> <A href="sub_frame3.html" target="x">Frame 3</A> </p> + <P> <A href="sub_frame4.html" target="x">Frame 4</A> </p> + <br> + <br> + <iframe src ="about:blank" name="x" width="400" height="200"> + </iframe> + + </body> +</html> diff --git a/chrome_frame/test/data/sub_frame1.html b/chrome_frame/test/data/sub_frame1.html new file mode 100644 index 0000000..90ee623 --- /dev/null +++ b/chrome_frame/test/data/sub_frame1.html @@ -0,0 +1,15 @@ +<html> + <head> + <meta http-equiv="x-ua-compatible" content="chrome=1" /> + <title>Sub frame 1</title> + </head> + <body> + Sub frame 1 + <br/><br/> + <br> + <div id="statusPanel" style="border: 1px solid red; width: 100%"> + LOG: + </div> + </body> +</html> + diff --git a/chrome_frame/test/data/sub_frame2.html b/chrome_frame/test/data/sub_frame2.html new file mode 100644 index 0000000..3075a22 --- /dev/null +++ b/chrome_frame/test/data/sub_frame2.html @@ -0,0 +1,15 @@ +<html> + <head> + <meta http-equiv="x-ua-compatible" content="chrome=1" /> + <title>Sub frame 2</title> + </head> + <body> + Sub frame 2 + <br/><br/> + <br> + <div id="statusPanel" style="border: 1px solid red; width: 100%"> + LOG: + </div> + </body> +</html> + diff --git a/chrome_frame/test/data/sub_frame3.html b/chrome_frame/test/data/sub_frame3.html new file mode 100644 index 0000000..279d38f --- /dev/null +++ b/chrome_frame/test/data/sub_frame3.html @@ -0,0 +1,15 @@ +<html> + <head> + <meta http-equiv="x-ua-compatible" content="chrome=1" /> + <title>Sub frame 3</title> + </head> + <body> + Sub frame 3 + <br/><br/> + <br> + <div id="statusPanel" style="border: 1px solid red; width: 100%"> + LOG: + </div> + </body> +</html> + diff --git a/chrome_frame/test/data/sub_frame4.html b/chrome_frame/test/data/sub_frame4.html new file mode 100644 index 0000000..f50eba2 --- /dev/null +++ b/chrome_frame/test/data/sub_frame4.html @@ -0,0 +1,15 @@ +<html> + <head> + <meta http-equiv="x-ua-compatible" content="chrome=1" /> + <title>Sub frame 4</title> + </head> + <body> + Sub frame 4 + <br/><br/> + <br> + <div id="statusPanel" style="border: 1px solid red; width: 100%"> + LOG: + </div> + </body> +</html> + diff --git a/chrome_frame/test/perf/chrome_frame_perftest.cc b/chrome_frame/test/perf/chrome_frame_perftest.cc index d93ebd5..762b424 100644 --- a/chrome_frame/test/perf/chrome_frame_perftest.cc +++ b/chrome_frame/test/perf/chrome_frame_perftest.cc @@ -17,6 +17,7 @@ #include "base/scoped_ptr.h" #include "base/scoped_bstr_win.h" #include "base/scoped_comptr_win.h" +#include "base/scoped_variant_win.h" #include "base/string_util.h" #include "base/time.h" #include "chrome/common/chrome_constants.h" @@ -37,41 +38,6 @@ const wchar_t kFlashControlKey[] = using base::TimeDelta; using base::TimeTicks; -// Callback description for onload, onloaderror, onmessage -static _ATL_FUNC_INFO g_single_param = {CC_STDCALL, VT_EMPTY, 1, {VT_VARIANT}}; -// Simple class that forwards the callbacks. -template <typename T> -class DispCallback - : public IDispEventSimpleImpl<1, DispCallback<T>, &IID_IDispatch> { - public: - typedef HRESULT (T::*Method)(VARIANT* param); - - DispCallback(T* owner, Method method) : owner_(owner), method_(method) { - } - - BEGIN_SINK_MAP(DispCallback) - SINK_ENTRY_INFO(1, IID_IDispatch, DISPID_VALUE, OnCallback, &g_single_param) - END_SINK_MAP() - - virtual ULONG STDMETHODCALLTYPE AddRef() { - return owner_->AddRef(); - } - virtual ULONG STDMETHODCALLTYPE Release() { - return owner_->Release(); - } - - STDMETHOD(OnCallback)(VARIANT param) { - return (owner_->*method_)(¶m); - } - - IDispatch* ToDispatch() { - return reinterpret_cast<IDispatch*>(this); - } - - T* owner_; - Method method_; -}; - // This class implements an ActiveX container which hosts the ChromeFrame // ActiveX control. It provides hooks which can be implemented by derived // classes for implementing performance measurement, etc. @@ -98,19 +64,19 @@ class ChromeFrameActiveXContainer MESSAGE_HANDLER(WM_DESTROY, OnDestroy) END_MSG_MAP() - HRESULT OnMessageCallback(VARIANT* param) { + HRESULT OnMessageCallback(const VARIANT* param) { DLOG(INFO) << __FUNCTION__; OnMessageCallbackImpl(param); return S_OK; } - HRESULT OnLoadErrorCallback(VARIANT* param) { + HRESULT OnLoadErrorCallback(const VARIANT* param) { DLOG(INFO) << __FUNCTION__ << " " << param->bstrVal; OnLoadErrorCallbackImpl(param); return S_OK; } - HRESULT OnLoadCallback(VARIANT* param) { + HRESULT OnLoadCallback(const VARIANT* param) { DLOG(INFO) << __FUNCTION__ << " " << param->bstrVal; OnLoadCallbackImpl(param); return S_OK; @@ -210,9 +176,9 @@ class ChromeFrameActiveXContainer &prop_notify_cookie_); DCHECK(hr == S_OK) << "AtlAdvice for IPropertyNotifySink failed " << hr; - CComVariant onmessage(onmsg_.ToDispatch()); - CComVariant onloaderror(onloaderror_.ToDispatch()); - CComVariant onload(onload_.ToDispatch()); + ScopedVariant onmessage(onmsg_.ToDispatch()); + ScopedVariant onloaderror(onloaderror_.ToDispatch()); + ScopedVariant onload(onload_.ToDispatch()); EXPECT_HRESULT_SUCCEEDED(tab_->put_onmessage(onmessage)); EXPECT_HRESULT_SUCCEEDED(tab_->put_onloaderror(onloaderror)); EXPECT_HRESULT_SUCCEEDED(tab_->put_onload(onload)); @@ -224,13 +190,13 @@ class ChromeFrameActiveXContainer virtual void OnReadyStateChanged(long ready_state) {} virtual void OnRequestEditImpl(DISPID disp_id) {} - virtual void OnMessageCallbackImpl(VARIANT* param) {} + virtual void OnMessageCallbackImpl(const VARIANT* param) {} - virtual void OnLoadCallbackImpl(VARIANT* param) { + virtual void OnLoadCallbackImpl(const VARIANT* param) { PostMessage(WM_CLOSE); } - virtual void OnLoadErrorCallbackImpl(VARIANT* param) { + virtual void OnLoadErrorCallbackImpl(const VARIANT* param) { PostMessage(WM_CLOSE); } virtual void BeforeNavigateImpl(const char* url) {} @@ -281,12 +247,12 @@ class ChromeFrameActiveXContainerPerf : public ChromeFrameActiveXContainer { } } - virtual void OnLoadCallbackImpl(VARIANT* param) { + virtual void OnLoadCallbackImpl(const VARIANT* param) { PostMessage(WM_CLOSE); perf_navigate_->Done(); } - virtual void OnLoadErrorCallbackImpl(VARIANT* param) { + virtual void OnLoadErrorCallbackImpl(const VARIANT* param) { PostMessage(WM_CLOSE); perf_navigate_->Done(); } @@ -591,7 +557,7 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase { StartTest(url, test_name); } - void OnNavigationSuccess(VARIANT* param) { + void OnNavigationSuccess(const VARIANT* param) { ASSERT_TRUE(param != NULL); ASSERT_EQ(VT_BSTR, param->vt); @@ -599,7 +565,7 @@ class ChromeFrameMemoryTest : public ChromeFramePerfTestBase { InitiateNextNavigation(); } - void OnNavigationFailure(VARIANT* param) { + void OnNavigationFailure(const VARIANT* param) { ASSERT_TRUE(param != NULL); ASSERT_EQ(VT_BSTR, param->vt); @@ -809,11 +775,11 @@ class ChromeFrameActiveXContainerMemory : public ChromeFrameActiveXContainer { } protected: - virtual void OnLoadCallbackImpl(VARIANT* param) { + virtual void OnLoadCallbackImpl(const VARIANT* param) { delegate_->OnNavigationSuccess(param); } - virtual void OnLoadErrorCallbackImpl(VARIANT* param) { + virtual void OnLoadErrorCallbackImpl(const VARIANT* param) { delegate_->OnNavigationFailure(param); } |