Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: chrome/test/ui_test_utils.cc

Issue 79024: Fix 10573: Dismissing FindInPage doesn't set focus to the link... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/ui_test_utils.h ('k') | webkit/glue/webframe_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/ui_test_utils.cc
===================================================================
--- chrome/test/ui_test_utils.cc (revision 13871)
+++ chrome/test/ui_test_utils.cc (working copy)
@@ -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,6 +6,7 @@
#include "base/message_loop.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/dom_operation_notification_details.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/common/notification_registrar.h"
@@ -98,4 +99,42 @@
WaitForNavigations(controller, number_of_navigations);
}
+JavaScriptRunner::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));
+}
+
+void JavaScriptRunner::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 JavaScriptRunner::Run() {
+ // The DOMAutomationController requires an automation ID, even though 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_;
+}
+
} // namespace ui_test_utils
« no previous file with comments | « chrome/test/ui_test_utils.h ('k') | webkit/glue/webframe_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698