summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 20:06:02 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-04 20:06:02 +0000
commitcc290f902d239d9373db36787cd51e8bdd00eb68 (patch)
tree535d112e9cca7c22f8474e0c43285597fa13c704
parent7568877302c9ef1e69e2939d345a52a91872a086 (diff)
downloadchromium_src-cc290f902d239d9373db36787cd51e8bdd00eb68.zip
chromium_src-cc290f902d239d9373db36787cd51e8bdd00eb68.tar.gz
chromium_src-cc290f902d239d9373db36787cd51e8bdd00eb68.tar.bz2
[content shell] manage focus synchronously from the renderer for layout tests
The majority of layout tests expects the focus to be changed instantly, so going via the browser process doesn't work. BUG=111316 R=piman@chromium.org TEST=fast/dom/Window/window-onFocus.html passes Review URL: https://codereview.chromium.org/12391061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185954 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/public/test/layouttest_support.h5
-rw-r--r--content/renderer/render_view_impl.cc14
-rw-r--r--content/renderer/render_view_impl.h5
-rw-r--r--content/shell/webkit_test_runner.cc1
-rw-r--r--content/test/layouttest_support.cc5
5 files changed, 30 insertions, 0 deletions
diff --git a/content/public/test/layouttest_support.h b/content/public/test/layouttest_support.h
index 85a1eab..2064f75 100644
--- a/content/public/test/layouttest_support.h
+++ b/content/public/test/layouttest_support.h
@@ -46,6 +46,11 @@ void DoNotRequireUserGestureForFocusChanges();
// Sync the current session history to the browser process.
void SyncNavigationState(RenderView* render_view);
+// Sets the focus of the render view depending on |enable|. This only overrides
+// the state of the renderer, and does not sync the focus to the browser
+// process.
+void SetFocusAndActivate(RenderView* render_view, bool enable);
+
} // namespace content
#endif // CONTENT_PUBLIC_TEST_LAYOUTTEST_SUPPORT_H_
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 6ee6915..e29914a 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -6728,6 +6728,20 @@ unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const {
return history_list_length_;
}
+void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) {
+ if (enable) {
+ if (has_focus())
+ return;
+ OnSetActive(true);
+ OnSetFocus(true);
+ } else {
+ if (!has_focus())
+ return;
+ OnSetFocus(false);
+ OnSetActive(false);
+ }
+}
+
void RenderViewImpl::OnReleaseDisambiguationPopupDIB(
TransportDIB::Handle dib_handle) {
TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle);
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 6b26d8f..41ed61e 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -403,6 +403,11 @@ class CONTENT_EXPORT RenderViewImpl
// RenderView is the currently active RenderView of a WebContents.
unsigned GetLocalSessionHistoryLengthForTesting() const;
+ // Invokes OnSetFocus and marks the widget as active depending on the value
+ // of |enable|. This is used for layout tests that need to control the focus
+ // synchronously from the renderer.
+ void SetFocusAndActivateForTesting(bool enable);
+
// IPC::Listener implementation ----------------------------------------------
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc
index 90bd416..ad2449c 100644
--- a/content/shell/webkit_test_runner.cc
+++ b/content/shell/webkit_test_runner.cc
@@ -322,6 +322,7 @@ void WebKitTestRunner::setFocus(WebTestProxyBase* proxy, bool focus) {
void WebKitTestRunner::setFocus(bool focus) {
// TODO(jochen): Remove once the new WebKit API is rolled.
+ SetFocusAndActivate(render_view(), focus);
}
void WebKitTestRunner::setAcceptAllCookies(bool accept) {
diff --git a/content/test/layouttest_support.cc b/content/test/layouttest_support.cc
index 3a7b852..272dbde 100644
--- a/content/test/layouttest_support.cc
+++ b/content/test/layouttest_support.cc
@@ -77,4 +77,9 @@ void SyncNavigationState(RenderView* render_view) {
static_cast<RenderViewImpl*>(render_view)->SyncNavigationState();
}
+void SetFocusAndActivate(RenderView* render_view, bool enable) {
+ static_cast<RenderViewImpl*>(render_view)
+ ->SetFocusAndActivateForTesting(enable);
+}
+
} // namespace content