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 CHROME_TEST_CHROMEDRIVER_CHROME_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_H_ |
6 #define CHROME_TEST_CHROMEDRIVER_CHROME_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_CHROME_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class ListValue; | 13 class ListValue; |
14 class Value; | 14 class Value; |
15 } | 15 } |
16 | 16 |
17 class Status; | 17 class Status; |
18 | 18 |
19 class Chrome { | 19 class Chrome { |
20 public: | 20 public: |
21 virtual ~Chrome() {} | 21 virtual ~Chrome() {} |
22 | 22 |
| 23 // Load a given URL in the main frame. |
23 virtual Status Load(const std::string& url) = 0; | 24 virtual Status Load(const std::string& url) = 0; |
24 virtual Status EvaluateScript(const std::string& expression, | 25 |
| 26 // Evaluates a JavaScript expression in a specified frame and returns |
| 27 // the result. |frame| is a frame ID or an empty string for the main frame. |
| 28 // If the expression evaluates to a element, it will be bound to a unique ID |
| 29 // (per frame) and the ID will be returned. |
| 30 virtual Status EvaluateScript(const std::string& frame, |
| 31 const std::string& expression, |
25 scoped_ptr<base::Value>* result) = 0; | 32 scoped_ptr<base::Value>* result) = 0; |
26 virtual Status CallFunction(const std::string& function, | 33 |
| 34 // Calls a JavaScript function in a specified frame with the given args and |
| 35 // returns the result. |frame| is a frame ID or an empty string for the main |
| 36 // frame. |args| may contain IDs that refer to previously returned elements. |
| 37 // These will be translated back to their referred objects before invoking the |
| 38 // function. |
| 39 virtual Status CallFunction(const std::string& frame, |
| 40 const std::string& function, |
27 const base::ListValue& args, | 41 const base::ListValue& args, |
28 scoped_ptr<base::Value>* result) = 0; | 42 scoped_ptr<base::Value>* result) = 0; |
| 43 |
| 44 // Gets the frame ID for a frame element returned by invoking the given |
| 45 // JavaScript function. |frame| is a frame ID or an empty string for the main |
| 46 // frame. |
| 47 virtual Status GetFrameByFunction(const std::string& frame, |
| 48 const std::string& function, |
| 49 const base::ListValue& args, |
| 50 std::string* out_frame) = 0; |
| 51 |
| 52 // Quits Chrome. |
29 virtual Status Quit() = 0; | 53 virtual Status Quit() = 0; |
30 }; | 54 }; |
31 | 55 |
32 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_H_ | 56 #endif // CHROME_TEST_CHROMEDRIVER_CHROME_H_ |
OLD | NEW |