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

Unified Diff: chrome/test/ui_test_utils.h

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/data/find_in_page/end_state.html ('k') | chrome/test/ui_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/ui_test_utils.h
===================================================================
--- chrome/test/ui_test_utils.h (revision 13871)
+++ chrome/test/ui_test_utils.h (working copy)
@@ -1,13 +1,17 @@
-// 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.
#ifndef CHROME_TEST_UI_TEST_UTILS_H_
#define CHROME_TEST_UI_TEST_UTILS_H_
+#include "base/basictypes.h"
+#include "chrome/common/notification_observer.h"
+
class Browser;
class GURL;
class NavigationController;
+class WebContents;
// A collections of functions designed for use with InProcessBrowserTest.
namespace ui_test_utils {
@@ -35,6 +39,40 @@
void NavigateToURLBlockUntilNavigationsComplete(Browser* browser,
const GURL& url,
int number_of_navigations);
+
+
+// This class enables you to send JavaScript as a string from the browser to the
+// renderer for execution in a frame of your choice.
+class JavaScriptRunner : public NotificationObserver {
+ public:
+ // Constructor. |web_contents| is a pointer to the WebContents you want to run
+ // the JavaScript code in. |frame_xpath| is a path to the frame to run it in.
+ // |jscript| is a string containing the JavaScript code to run, for example:
+ // "window.domAutomationController.send(alert('hello world'));". The
+ // JavaScript code will execute when Run is called. Note: In order for the
+ // domAutomationController to work, you must call EnableDOMAutomation() in
+ // your test class first.
+ JavaScriptRunner(WebContents* web_contents,
+ const std::wstring& frame_xpath,
+ const std::wstring& jscript);
+
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ // Executes the JavaScript code passed in to the constructor. See also comment
+ // about EnableDOMAutomation in the constructor.
+ std::string Run();
+
+ private:
+ WebContents* web_contents_;
+ std::wstring frame_xpath_;
+ std::wstring jscript_;
+ std::string result_;
+
+ DISALLOW_COPY_AND_ASSIGN(JavaScriptRunner);
+};
+
}
#endif // CHROME_TEST_UI_TEST_UTILS_H_
« no previous file with comments | « chrome/test/data/find_in_page/end_state.html ('k') | chrome/test/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698