Commit c1c758e1 authored by sail@chromium.org's avatar sail@chromium.org

Revert 113015 - speculative revert to see if this fixes the interactive test breakage

Remove OnMessageReceived that was using internal content IPCs in a chrome test. Dispatch the IPC in RenderViewHost instead of TabContents to solve this (it's only used by tests anyways). Remove test_utils methods that weren't being used.

BUG=98716
Review URL: http://codereview.chromium.org/8801002

TBR=jam@chromium.org
Review URL: http://codereview.chromium.org/8817007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113110 0039d316-1c4b-4281-b951-d872f2087c98
parent a1e60da8
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "content/browser/tab_contents/interstitial_page.h" #include "content/browser/tab_contents/interstitial_page.h"
#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/tab_contents/tab_contents_view.h" #include "content/browser/tab_contents/tab_contents_view.h"
#include "content/common/view_messages.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "net/test/test_server.h" #include "net/test/test_server.h"
...@@ -63,9 +64,9 @@ ...@@ -63,9 +64,9 @@
#define MAYBE_TabsRememberFocusFindInPage FAILS_TabsRememberFocusFindInPage #define MAYBE_TabsRememberFocusFindInPage FAILS_TabsRememberFocusFindInPage
#elif defined(OS_WIN) #elif defined(OS_WIN)
// Disabled, http://crbug.com/62543. // Disabled, http://crbug.com/62543.
#define MAYBE_FocusTraversal FocusTraversal #define MAYBE_FocusTraversal DISABLED_FocusTraversal
// Disabled, http://crbug.com/62544. // Disabled, http://crbug.com/62544.
#define MAYBE_FocusTraversalOnInterstitial FocusTraversalOnInterstitial #define MAYBE_FocusTraversalOnInterstitial DISABLED_FocusTraversalOnInterstitial
// Flaky, http://crbug.com/62537. // Flaky, http://crbug.com/62537.
#define MAYBE_TabsRememberFocusFindInPage FLAKY_TabsRememberFocusFindInPage #define MAYBE_TabsRememberFocusFindInPage FLAKY_TabsRememberFocusFindInPage
#endif #endif
...@@ -172,6 +173,23 @@ class TestInterstitialPage : public InterstitialPage { ...@@ -172,6 +173,23 @@ class TestInterstitialPage : public InterstitialPage {
return render_view_host()->view()->HasFocus(); return render_view_host()->view()->HasFocus();
} }
protected:
bool OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(TestInterstitialPage, message)
IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void OnFocusedNodeChanged(bool is_editable_node) {
content::NotificationService::current()->Notify(
content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<TabContents>(tab()),
content::Details<const bool>(&is_editable_node));
}
private: private:
std::string html_contents_; std::string html_contents_;
}; };
...@@ -493,8 +511,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) { ...@@ -493,8 +511,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) {
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWaitWithDetails( ASSERT_TRUE(ui_test_utils::SendKeyPressAndWaitWithDetails(
browser(), ui::VKEY_TAB, false, false, false, false, browser(), ui::VKEY_TAB, false, false, false, false,
content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::NotificationSource(content::Source<RenderViewHost>( content::NotificationSource(content::Source<TabContents>(
browser()->GetSelectedTabContents()->render_view_host())), browser()->GetSelectedTabContents())),
details)); details));
} else { } else {
// On the last tab key press, the focus returns to the browser. // On the last tab key press, the focus returns to the browser.
...@@ -536,8 +554,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) { ...@@ -536,8 +554,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversal) {
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWaitWithDetails( ASSERT_TRUE(ui_test_utils::SendKeyPressAndWaitWithDetails(
browser(), ui::VKEY_TAB, false, true, false, false, browser(), ui::VKEY_TAB, false, true, false, false,
content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::NotificationSource(content::Source<RenderViewHost>( content::NotificationSource(content::Source<TabContents>(
browser()->GetSelectedTabContents()->render_view_host())), browser()->GetSelectedTabContents())),
details)); details));
} else { } else {
// On the last tab key press, the focus returns to the browser. // On the last tab key press, the focus returns to the browser.
...@@ -620,8 +638,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { ...@@ -620,8 +638,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
content::NotificationService::AllSources(); content::NotificationService::AllSources();
if (j < arraysize(kExpElementIDs) - 1) { if (j < arraysize(kExpElementIDs) - 1) {
notification_type = content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE; notification_type = content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE;
notification_source = content::Source<RenderViewHost>( notification_source = content::Source<TabContents>(
interstitial_page->render_view_host()); interstitial_page->tab());
} else { } else {
// On the last tab key press, the focus returns to the browser. // On the last tab key press, the focus returns to the browser.
notification_type = chrome::NOTIFICATION_FOCUS_RETURNED_TO_BROWSER; notification_type = chrome::NOTIFICATION_FOCUS_RETURNED_TO_BROWSER;
...@@ -655,8 +673,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { ...@@ -655,8 +673,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) {
content::NotificationService::AllSources(); content::NotificationService::AllSources();
if (j < arraysize(kExpElementIDs) - 1) { if (j < arraysize(kExpElementIDs) - 1) {
notification_type = content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE; notification_type = content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE;
notification_source = content::Source<RenderViewHost>( notification_source = content::Source<TabContents>(
interstitial_page->render_view_host()); interstitial_page->tab());
} else { } else {
// On the last tab key press, the focus returns to the browser. // On the last tab key press, the focus returns to the browser.
notification_type = chrome::NOTIFICATION_FOCUS_RETURNED_TO_BROWSER; notification_type = chrome::NOTIFICATION_FOCUS_RETURNED_TO_BROWSER;
......
...@@ -549,6 +549,18 @@ void CrashTab(TabContents* tab) { ...@@ -549,6 +549,18 @@ void CrashTab(TabContents* tab) {
content::Source<content::RenderProcessHost>(rph)); content::Source<content::RenderProcessHost>(rph));
} }
void WaitForFocusChange(TabContents* tab_contents) {
TestNotificationObserver observer;
RegisterAndWait(&observer, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<TabContents>(tab_contents));
}
void WaitForFocusInBrowser(Browser* browser) {
TestNotificationObserver observer;
RegisterAndWait(&observer, chrome::NOTIFICATION_FOCUS_RETURNED_TO_BROWSER,
content::Source<Browser>(browser));
}
int FindInPage(TabContentsWrapper* tab_contents, const string16& search_string, int FindInPage(TabContentsWrapper* tab_contents, const string16& search_string,
bool forward, bool match_case, int* ordinal) { bool forward, bool match_case, int* ordinal) {
tab_contents-> tab_contents->
......
...@@ -194,6 +194,13 @@ AppModalDialog* WaitForAppModalDialog(); ...@@ -194,6 +194,13 @@ AppModalDialog* WaitForAppModalDialog();
// Causes the specified tab to crash. Blocks until it is crashed. // Causes the specified tab to crash. Blocks until it is crashed.
void CrashTab(TabContents* tab); void CrashTab(TabContents* tab);
// Waits for the focus to change in the specified tab.
void WaitForFocusChange(TabContents* tab_contents);
// Waits for the renderer to return focus to the browser (happens through tab
// traversal).
void WaitForFocusInBrowser(Browser* browser);
// Performs a find in the page of the specified tab. Returns the number of // Performs a find in the page of the specified tab. Returns the number of
// matches found. |ordinal| is an optional parameter which is set to the index // matches found. |ordinal| is an optional parameter which is set to the index
// of the current match. // of the current match.
......
...@@ -712,7 +712,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { ...@@ -712,7 +712,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK) IPC_MESSAGE_HANDLER(DragHostMsg_TargetDrop_ACK, OnTargetDropACK)
IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole)
IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK)
IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK) IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnMsgClosePageACK)
...@@ -1132,13 +1131,6 @@ void RenderViewHost::OnTakeFocus(bool reverse) { ...@@ -1132,13 +1131,6 @@ void RenderViewHost::OnTakeFocus(bool reverse) {
view->TakeFocus(reverse); view->TakeFocus(reverse);
} }
void RenderViewHost::OnFocusedNodeChanged(bool is_editable_node) {
content::NotificationService::current()->Notify(
content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<RenderViewHost>(this),
content::Details<const bool>(&is_editable_node));
}
void RenderViewHost::OnAddMessageToConsole(int32 level, void RenderViewHost::OnAddMessageToConsole(int32 level,
const string16& message, const string16& message,
int32 line_no, int32 line_no,
......
...@@ -564,7 +564,6 @@ class CONTENT_EXPORT RenderViewHost : public RenderWidgetHost { ...@@ -564,7 +564,6 @@ class CONTENT_EXPORT RenderViewHost : public RenderWidgetHost {
void OnUpdateDragCursor(WebKit::WebDragOperation drag_operation); void OnUpdateDragCursor(WebKit::WebDragOperation drag_operation);
void OnTargetDropACK(); void OnTargetDropACK();
void OnTakeFocus(bool reverse); void OnTakeFocus(bool reverse);
void OnFocusedNodeChanged(bool is_editable_node);
void OnAddMessageToConsole(int32 level, void OnAddMessageToConsole(int32 level,
const string16& message, const string16& message,
int32 line_no, int32 line_no,
......
...@@ -315,6 +315,7 @@ bool TabContents::OnMessageReceived(const IPC::Message& message) { ...@@ -315,6 +315,7 @@ bool TabContents::OnMessageReceived(const IPC::Message& message) {
OnUpdateContentRestrictions) OnUpdateContentRestrictions)
IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset) IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnGoToEntryAtOffset)
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits)
IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL) IPC_MESSAGE_HANDLER(ViewHostMsg_SaveURLAs, OnSaveURL)
IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory)
IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory) IPC_MESSAGE_HANDLER(ViewHostMsg_JSOutOfMemory, OnJSOutOfMemory)
...@@ -1151,6 +1152,13 @@ void TabContents::OnUpdateZoomLimits(int minimum_percent, ...@@ -1151,6 +1152,13 @@ void TabContents::OnUpdateZoomLimits(int minimum_percent,
temporary_zoom_settings_ = !remember; temporary_zoom_settings_ = !remember;
} }
void TabContents::OnFocusedNodeChanged(bool is_editable_node) {
content::NotificationService::current()->Notify(
content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
content::Source<TabContents>(this),
content::Details<const bool>(&is_editable_node));
}
void TabContents::OnEnumerateDirectory(int request_id, void TabContents::OnEnumerateDirectory(int request_id,
const FilePath& path) { const FilePath& path) {
delegate()->EnumerateDirectory(this, request_id, path); delegate()->EnumerateDirectory(this, request_id, path);
......
...@@ -642,6 +642,7 @@ class CONTENT_EXPORT TabContents : public PageNavigator, ...@@ -642,6 +642,7 @@ class CONTENT_EXPORT TabContents : public PageNavigator,
void OnUpdateZoomLimits(int minimum_percent, void OnUpdateZoomLimits(int minimum_percent,
int maximum_percent, int maximum_percent,
bool remember); bool remember);
void OnFocusedNodeChanged(bool is_editable_node);
void OnEnumerateDirectory(int request_id, const FilePath& path); void OnEnumerateDirectory(int request_id, const FilePath& path);
void OnJSOutOfMemory(); void OnJSOutOfMemory();
void OnRegisterProtocolHandler(const std::string& protocol, void OnRegisterProtocolHandler(const std::string& protocol,
......
...@@ -357,8 +357,9 @@ enum NotificationType { ...@@ -357,8 +357,9 @@ enum NotificationType {
NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
// The focused element inside a page has changed. The source is the // The focused element inside a page has changed. The source is the
// RenderViewHost. The details is a Details<const bool> that indicates whether // TabContents containing the render view host for the page. The details is
// or not an editable node was focused. // a Details<const bool> that indicates whether or not an editable node was
// focused.
NOTIFICATION_FOCUS_CHANGED_IN_PAGE, NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
// Notification posted from ExecuteJavascriptInWebFrameNotifyResult. The // Notification posted from ExecuteJavascriptInWebFrameNotifyResult. The
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment