OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 bool shift, | 77 bool shift, |
78 bool alt, | 78 bool alt, |
79 bool command); | 79 bool command); |
80 | 80 |
81 // Executes the passed |script| in the frame pointed to by |frame_xpath| (use | 81 // Executes the passed |script| in the frame pointed to by |frame_xpath| (use |
82 // empty string for main frame). The |script| should not invoke | 82 // empty string for main frame). The |script| should not invoke |
83 // domAutomationController.send(); otherwise, your test will hang or be flaky. | 83 // domAutomationController.send(); otherwise, your test will hang or be flaky. |
84 // If you want to extract a result, use one of the below functions. | 84 // If you want to extract a result, use one of the below functions. |
85 // Returns true on success. | 85 // Returns true on success. |
86 bool ExecuteJavaScript(RenderViewHost* render_view_host, | 86 bool ExecuteJavaScript(RenderViewHost* render_view_host, |
87 const std::wstring& frame_xpath, | 87 const std::string& frame_xpath, |
88 const std::wstring& script) WARN_UNUSED_RESULT; | 88 const std::string& script) WARN_UNUSED_RESULT; |
89 | 89 |
90 // The following methods executes the passed |script| in the frame pointed to by | 90 // The following methods executes the passed |script| in the frame pointed to by |
91 // |frame_xpath| (use empty string for main frame) and sets |result| to the | 91 // |frame_xpath| (use empty string for main frame) and sets |result| to the |
92 // value returned by the script evaluation. | 92 // value returned by the script evaluation. |
93 // They return true on success, false if the script evaluation failed or did not | 93 // They return true on success, false if the script evaluation failed or did not |
94 // evaluate to the expected type. | 94 // evaluate to the expected type. |
95 bool ExecuteJavaScriptAndExtractInt(RenderViewHost* render_view_host, | 95 bool ExecuteJavaScriptAndExtractInt(RenderViewHost* render_view_host, |
96 const std::wstring& frame_xpath, | 96 const std::string& frame_xpath, |
97 const std::wstring& script, | 97 const std::string& script, |
98 int* result) WARN_UNUSED_RESULT; | 98 int* result) WARN_UNUSED_RESULT; |
99 bool ExecuteJavaScriptAndExtractBool(RenderViewHost* render_view_host, | 99 bool ExecuteJavaScriptAndExtractBool(RenderViewHost* render_view_host, |
100 const std::wstring& frame_xpath, | 100 const std::string& frame_xpath, |
101 const std::wstring& script, | 101 const std::string& script, |
102 bool* result) WARN_UNUSED_RESULT; | 102 bool* result) WARN_UNUSED_RESULT; |
103 bool ExecuteJavaScriptAndExtractString( | 103 bool ExecuteJavaScriptAndExtractString( |
104 RenderViewHost* render_view_host, | 104 RenderViewHost* render_view_host, |
105 const std::wstring& frame_xpath, | 105 const std::string& frame_xpath, |
106 const std::wstring& script, | 106 const std::string& script, |
107 std::string* result) WARN_UNUSED_RESULT; | 107 std::string* result) WARN_UNUSED_RESULT; |
108 | 108 |
109 // Returns the cookies for the given url. | 109 // Returns the cookies for the given url. |
110 std::string GetCookies(BrowserContext* browser_context, const GURL& url); | 110 std::string GetCookies(BrowserContext* browser_context, const GURL& url); |
111 | 111 |
112 // Sets a cookie for the given url. Returns true on success. | 112 // Sets a cookie for the given url. Returns true on success. |
113 bool SetCookie(BrowserContext* browser_context, | 113 bool SetCookie(BrowserContext* browser_context, |
114 const GURL& url, | 114 const GURL& url, |
115 const std::string& value); | 115 const std::string& value); |
116 | 116 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 std::queue<std::string> message_queue_; | 179 std::queue<std::string> message_queue_; |
180 bool waiting_for_message_; | 180 bool waiting_for_message_; |
181 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 181 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
182 | 182 |
183 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | 183 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); |
184 }; | 184 }; |
185 | 185 |
186 } // namespace content | 186 } // namespace content |
187 | 187 |
188 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 188 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |