summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_focus_uitest.cc
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 17:00:12 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 17:00:12 +0000
commitb5464901bd28beacfe68d7b0fae6d258d51e32f3 (patch)
tree9de0768dd47a4b2eef46847a56d6faf738e7bc43 /chrome/browser/browser_focus_uitest.cc
parent2e116bc834bd71cf306a62d6175ae2baa15851d5 (diff)
downloadchromium_src-b5464901bd28beacfe68d7b0fae6d258d51e32f3.zip
chromium_src-b5464901bd28beacfe68d7b0fae6d258d51e32f3.tar.gz
chromium_src-b5464901bd28beacfe68d7b0fae6d258d51e32f3.tar.bz2
Fix 10573: Dismissing Find-in page doesn't set focus
to the link found. We no longer use the selection controller to highlight the active match. Before this change, the focus would not be set if the user had changed the selection. After this change, the focus will be set unless the user has selected something on the page. I also wrote an in-browser unit test for this to catch this regression in the future, but it is disabled due to problem with running multiple in-process browser tests in a row (teardown problem). BUG=10573 TEST=Covered by in process browser test now, see bug for repro steps. Review URL: http://codereview.chromium.org/79024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13945 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_focus_uitest.cc')
-rw-r--r--chrome/browser/browser_focus_uitest.cc63
1 files changed, 4 insertions, 59 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 77d67b5..a19e072 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,16 +6,10 @@
#include "base/ref_counted.h"
#include "chrome/browser/automation/ui_controls.h"
#include "chrome/browser/browser.h"
-#include "chrome/browser/dom_operation_notification_details.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/browser/view_ids.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/location_bar_view.h"
-#include "chrome/common/notification_details.h"
-#include "chrome/common/notification_observer.h"
-#include "chrome/common/notification_service.h"
-#include "chrome/common/notification_source.h"
-#include "chrome/common/notification_type.h"
#include "chrome/views/focus/focus_manager.h"
#include "chrome/views/view.h"
#include "chrome/views/window/window.h"
@@ -40,55 +34,6 @@ class BrowserFocusTest : public InProcessBrowserTest {
}
};
-class JavaScriptRunner : public NotificationObserver {
- public:
- JavaScriptRunner(WebContents* web_contents,
- const std::wstring& frame_xpath,
- const std::wstring& jscript)
- : web_contents_(web_contents),
- frame_xpath_(frame_xpath),
- jscript_(jscript) {
- NotificationService::current()->
- AddObserver(this, NotificationType::DOM_OPERATION_RESPONSE,
- Source<WebContents>(web_contents));
- }
-
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- Details<DomOperationNotificationDetails> dom_op_details(details);
- result_ = dom_op_details->json();
- // The Jasonified response has quotes, remove them.
- if (result_.length() > 1 && result_[0] == '"')
- result_ = result_.substr(1, result_.length() - 2);
-
- NotificationService::current()->
- RemoveObserver(this, NotificationType::DOM_OPERATION_RESPONSE,
- Source<WebContents>(web_contents_));
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
- }
-
- std::string Run() {
- // The DOMAutomationController requires an automation ID, eventhough we are
- // not using it in this case.
- web_contents_->render_view_host()->ExecuteJavascriptInWebFrame(
- frame_xpath_, L"window.domAutomationController.setAutomationId(0);");
-
- web_contents_->render_view_host()->ExecuteJavascriptInWebFrame(frame_xpath_,
- jscript_);
- ui_test_utils::RunMessageLoop();
- return result_;
- }
-
- private:
- WebContents* web_contents_;
- std::wstring frame_xpath_;
- std::wstring jscript_;
- std::string result_;
-
- DISALLOW_COPY_AND_ASSIGN(JavaScriptRunner);
-};
-
} // namespace
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_BrowsersRememberFocus) {
@@ -319,7 +264,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) {
// Now let's press tab to move the focus.
for (int j = 0; j < 7; ++j) {
// Let's make sure the focus is on the expected element in the page.
- JavaScriptRunner js_runner(
+ ui_test_utils::JavaScriptRunner js_runner(
browser()->GetSelectedTabContents()->AsWebContents(),
L"",
L"window.domAutomationController.send(getFocusedElement());");
@@ -330,7 +275,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) {
new MessageLoop::QuitTask());
ui_test_utils::RunMessageLoop();
// Ideally, we wouldn't sleep here and instead would use the event
- // processed ack nofification from the renderer. I am reluctant to create
+ // processed ack notification from the renderer. I am reluctant to create
// a new notification/callback for that purpose just for this test.
::Sleep(kActionDelayMs);
}
@@ -355,7 +300,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) {
::Sleep(kActionDelayMs);
// Let's make sure the focus is on the expected element in the page.
- JavaScriptRunner js_runner(
+ ui_test_utils::JavaScriptRunner js_runner(
browser()->GetSelectedTabContents()->AsWebContents(),
L"",
L"window.domAutomationController.send(getFocusedElement());");