diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-02 22:44:13 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-02 22:44:13 +0000 |
commit | 06bc5d9a46ad798452b317fc47be8acd5ff041c5 (patch) | |
tree | fe194e49cf0ea3f31a88b60821abb82c4fe6a853 /content/public/test/browser_test_utils.cc | |
parent | 78e2370448246f03b6f795b105746bf82ba5f4f4 (diff) | |
download | chromium_src-06bc5d9a46ad798452b317fc47be8acd5ff041c5.zip chromium_src-06bc5d9a46ad798452b317fc47be8acd5ff041c5.tar.gz chromium_src-06bc5d9a46ad798452b317fc47be8acd5ff041c5.tar.bz2 |
Change ExecuteJavaScript* helper functions in browser_test_utils.{h,cc}
to take std::string (UTF-8) instead of std::wstring. This seems to help
simplify callsites considerably.
TBR=jam@chromium.org
BUG=none
Review URL: https://chromiumcodereview.appspot.com/11728003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174880 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public/test/browser_test_utils.cc')
-rw-r--r-- | content/public/test/browser_test_utils.cc | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc index 6efa0a6..5de453b 100644 --- a/content/public/test/browser_test_utils.cc +++ b/content/public/test/browser_test_utils.cc @@ -33,7 +33,6 @@ static const int kDefaultWsPort = 8880; namespace content { - namespace { class DOMOperationObserver : public NotificationObserver, @@ -79,24 +78,24 @@ class DOMOperationObserver : public NotificationObserver, // Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute. bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host, - const std::wstring& frame_xpath, - const std::wstring& original_script, + const std::string& frame_xpath, + const std::string& original_script, scoped_ptr<Value>* result) WARN_UNUSED_RESULT; // Executes the passed |original_script| in the frame pointed to by // |frame_xpath|. If |result| is not NULL, stores the value that the evaluation // of the script in |result|. Returns true on success. bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host, - const std::wstring& frame_xpath, - const std::wstring& original_script, + const std::string& frame_xpath, + const std::string& original_script, scoped_ptr<Value>* result) { // TODO(jcampan): we should make the domAutomationController not require an // automation id. - std::wstring script = L"window.domAutomationController.setAutomationId(0);" + - original_script; + std::string script = + "window.domAutomationController.setAutomationId(0);" + original_script; DOMOperationObserver dom_op_observer(render_view_host); - render_view_host->ExecuteJavascriptInWebFrame(WideToUTF16Hack(frame_xpath), - WideToUTF16Hack(script)); + render_view_host->ExecuteJavascriptInWebFrame(UTF8ToUTF16(frame_xpath), + UTF8ToUTF16(script)); std::string json; if (!dom_op_observer.WaitAndGetResponse(&json)) { DLOG(ERROR) << "Cannot communicate with DOMOperationObserver."; @@ -281,16 +280,16 @@ void SimulateKeyPress(WebContents* web_contents, } bool ExecuteJavaScript(RenderViewHost* render_view_host, - const std::wstring& frame_xpath, - const std::wstring& original_script) { - std::wstring script = - original_script + L";window.domAutomationController.send(0);"; + const std::string& frame_xpath, + const std::string& original_script) { + std::string script = + original_script + ";window.domAutomationController.send(0);"; return ExecuteJavaScriptHelper(render_view_host, frame_xpath, script, NULL); } bool ExecuteJavaScriptAndExtractInt(RenderViewHost* render_view_host, - const std::wstring& frame_xpath, - const std::wstring& script, + const std::string& frame_xpath, + const std::string& script, int* result) { DCHECK(result); scoped_ptr<Value> value; @@ -302,8 +301,8 @@ bool ExecuteJavaScriptAndExtractInt(RenderViewHost* render_view_host, } bool ExecuteJavaScriptAndExtractBool(RenderViewHost* render_view_host, - const std::wstring& frame_xpath, - const std::wstring& script, + const std::string& frame_xpath, + const std::string& script, bool* result) { DCHECK(result); scoped_ptr<Value> value; @@ -315,8 +314,8 @@ bool ExecuteJavaScriptAndExtractBool(RenderViewHost* render_view_host, } bool ExecuteJavaScriptAndExtractString(RenderViewHost* render_view_host, - const std::wstring& frame_xpath, - const std::wstring& script, + const std::string& frame_xpath, + const std::string& script, std::string* result) { DCHECK(result); scoped_ptr<Value> value; |