diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 22:48:37 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-17 22:48:37 +0000 |
commit | e518c64aac17b27aa2bf0d0ed6cdac4210b3e946 (patch) | |
tree | 8606e2ab1a83b97ec6fd8398fe6889230b6ec874 /chrome_frame/test | |
parent | 2880fe18d26357c6b40d6ab2db1ba369043f9c33 (diff) | |
download | chromium_src-e518c64aac17b27aa2bf0d0ed6cdac4210b3e946.zip chromium_src-e518c64aac17b27aa2bf0d0ed6cdac4210b3e946.tar.gz chromium_src-e518c64aac17b27aa2bf0d0ed6cdac4210b3e946.tar.bz2 |
Only send an accessibility doc load event if the browser has a renderer window.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3162016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56442 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/ie_event_sink.cc | 44 | ||||
-rw-r--r-- | chrome_frame/test/ie_event_sink.h | 8 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_test.cc | 14 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_test.h | 9 |
4 files changed, 61 insertions, 14 deletions
diff --git a/chrome_frame/test/ie_event_sink.cc b/chrome_frame/test/ie_event_sink.cc index 853ee59..324a25f 100644 --- a/chrome_frame/test/ie_event_sink.cc +++ b/chrome_frame/test/ie_event_sink.cc @@ -254,8 +254,8 @@ HWND IEEventSink::GetRendererWindow() { EXPECT_TRUE(IsWindow(activex_window)); // chrome tab window is the first (and the only) child of activex - for (HWND first_child = activex_window; - IsWindow(first_child); first_child = GetWindow(first_child, GW_CHILD)) { + for (HWND first_child = activex_window; ::IsWindow(first_child); + first_child = ::GetWindow(first_child, GW_CHILD)) { renderer_window = first_child; } wchar_t class_name[MAX_PATH] = {0}; @@ -278,7 +278,45 @@ HWND IEEventSink::GetRendererWindow() { } } - EXPECT_TRUE(IsWindow(renderer_window)); + EXPECT_TRUE(::IsWindow(renderer_window)); + return renderer_window; +} + +HWND IEEventSink::GetRendererWindowSafe() { + HWND renderer_window = NULL; + if (IsCFRendering()) { + DCHECK(chrome_frame_); + ScopedComPtr<IOleWindow> ole_window; + ole_window.QueryFrom(chrome_frame_); + + if (ole_window) { + HWND activex_window = NULL; + ole_window->GetWindow(&activex_window); + + // chrome tab window is the first (and the only) child of activex + for (HWND first_child = activex_window; ::IsWindow(first_child); + first_child = ::GetWindow(first_child, GW_CHILD)) { + renderer_window = first_child; + } + wchar_t class_name[MAX_PATH] = {0}; + GetClassName(renderer_window, class_name, arraysize(class_name)); + if (_wcsicmp(class_name, L"Chrome_RenderWidgetHostHWND") != 0) + renderer_window = NULL; + } + } else { + DCHECK(web_browser2_); + ScopedComPtr<IDispatch> doc; + web_browser2_->get_Document(doc.Receive()); + if (doc) { + ScopedComPtr<IOleWindow> ole_window; + ole_window.QueryFrom(doc); + if (ole_window) { + ole_window->GetWindow(&renderer_window); + } + } + } + if (!::IsWindow(renderer_window)) + renderer_window = NULL; return renderer_window; } diff --git a/chrome_frame/test/ie_event_sink.h b/chrome_frame/test/ie_event_sink.h index feddcbf..aa0a2d7 100644 --- a/chrome_frame/test/ie_event_sink.h +++ b/chrome_frame/test/ie_event_sink.h @@ -108,11 +108,13 @@ class IEEventSink // SendInput API. void SendMouseClick(int x, int y, simulate_input::MouseButton button); - // Get the HWND for the browser's renderer window. + // Get the HWND for the browser's renderer window. Will fail test if + // renderer window not found. HWND GetRendererWindow(); - // Returns whether the browser has a renderer window. - bool HasRendererWindow(); + // Same as above, but does not fail the test if the window cannot be found. + // In that case, the returned handle will be NULL. + HWND GetRendererWindowSafe(); // Launch IE, use the given listener, and navigate to the given url. HRESULT LaunchIEAndNavigate(const std::wstring& navigate_url, diff --git a/chrome_frame/test/mock_ie_event_sink_test.cc b/chrome_frame/test/mock_ie_event_sink_test.cc index fb1493a..00eac00 100644 --- a/chrome_frame/test/mock_ie_event_sink_test.cc +++ b/chrome_frame/test/mock_ie_event_sink_test.cc @@ -24,6 +24,20 @@ using testing::StrCaseEq; namespace chrome_frame_test { // MockIEEventSink methods +void MockIEEventSink::OnDocumentComplete(IDispatch* dispatch, VARIANT* url) { + if (!event_sink_->IsCFRendering()) { + HWND renderer_window = event_sink_->GetRendererWindowSafe(); + if (renderer_window) { + ::NotifyWinEvent(IA2_EVENT_DOCUMENT_LOAD_COMPLETE, + renderer_window, + OBJID_CLIENT, 0L); + } else { + DLOG(INFO) << "Browser does not have renderer window"; + } + OnLoad(IN_IE, V_BSTR(url)); + } +} + ExpectationSet MockIEEventSink::ExpectNavigationCardinality( const std::wstring& url, Cardinality before_cardinality, Cardinality complete_cardinality) { diff --git a/chrome_frame/test/mock_ie_event_sink_test.h b/chrome_frame/test/mock_ie_event_sink_test.h index 044d6a0..75ecf4d 100644 --- a/chrome_frame/test/mock_ie_event_sink_test.h +++ b/chrome_frame/test/mock_ie_event_sink_test.h @@ -122,14 +122,7 @@ class MockIEEventSink : public IEEventListener { private: // Override IE's OnDocumentComplete to call our OnLoad, iff it is IE actually // rendering the page. - virtual void OnDocumentComplete(IDispatch* dispatch, VARIANT* url) { - if (!event_sink_->IsCFRendering()) { - ::NotifyWinEvent(IA2_EVENT_DOCUMENT_LOAD_COMPLETE, - event_sink_->GetRendererWindow(), - OBJID_CLIENT, 0L); - OnLoad(IN_IE, V_BSTR(url)); - } - } + virtual void OnDocumentComplete(IDispatch* dispatch, VARIANT* url); // Override CF's OnLoad to call our OnLoad. virtual void OnLoad(const wchar_t* url) { |