| 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 #include "chrome/test/webdriver/webdriver_session.h" | 5 #include "chrome/test/webdriver/webdriver_session.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 base::Unretained(this))); | 157 base::Unretained(this))); |
| 158 delete this; | 158 delete this; |
| 159 } | 159 } |
| 160 | 160 |
| 161 Error* Session::ExecuteScript(const FrameId& frame_id, | 161 Error* Session::ExecuteScript(const FrameId& frame_id, |
| 162 const std::string& script, | 162 const std::string& script, |
| 163 const ListValue* const args, | 163 const ListValue* const args, |
| 164 Value** value) { | 164 Value** value) { |
| 165 std::string args_as_json; | 165 std::string args_as_json; |
| 166 base::JSONWriter::Write(static_cast<const Value* const>(args), | 166 base::JSONWriter::Write(static_cast<const Value* const>(args), |
| 167 /*pretty_print=*/false, | |
| 168 &args_as_json); | 167 &args_as_json); |
| 169 | 168 |
| 170 // Every injected script is fed through the executeScript atom. This atom | 169 // Every injected script is fed through the executeScript atom. This atom |
| 171 // will catch any errors that are thrown and convert them to the | 170 // will catch any errors that are thrown and convert them to the |
| 172 // appropriate JSON structure. | 171 // appropriate JSON structure. |
| 173 std::string jscript = base::StringPrintf( | 172 std::string jscript = base::StringPrintf( |
| 174 "window.domAutomationController.send((%s).apply(null," | 173 "window.domAutomationController.send((%s).apply(null," |
| 175 "[function(){%s\n},%s,true]));", | 174 "[function(){%s\n},%s,true]));", |
| 176 atoms::asString(atoms::EXECUTE_SCRIPT).c_str(), script.c_str(), | 175 atoms::asString(atoms::EXECUTE_SCRIPT).c_str(), script.c_str(), |
| 177 args_as_json.c_str()); | 176 args_as_json.c_str()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 209 } |
| 211 return NULL; | 210 return NULL; |
| 212 } | 211 } |
| 213 | 212 |
| 214 Error* Session::ExecuteAsyncScript(const FrameId& frame_id, | 213 Error* Session::ExecuteAsyncScript(const FrameId& frame_id, |
| 215 const std::string& script, | 214 const std::string& script, |
| 216 const ListValue* const args, | 215 const ListValue* const args, |
| 217 Value** value) { | 216 Value** value) { |
| 218 std::string args_as_json; | 217 std::string args_as_json; |
| 219 base::JSONWriter::Write(static_cast<const Value* const>(args), | 218 base::JSONWriter::Write(static_cast<const Value* const>(args), |
| 220 /*pretty_print=*/false, | |
| 221 &args_as_json); | 219 &args_as_json); |
| 222 | 220 |
| 223 int timeout_ms = async_script_timeout(); | 221 int timeout_ms = async_script_timeout(); |
| 224 | 222 |
| 225 // Every injected script is fed through the executeScript atom. This atom | 223 // Every injected script is fed through the executeScript atom. This atom |
| 226 // will catch any errors that are thrown and convert them to the | 224 // will catch any errors that are thrown and convert them to the |
| 227 // appropriate JSON structure. | 225 // appropriate JSON structure. |
| 228 std::string jscript = base::StringPrintf( | 226 std::string jscript = base::StringPrintf( |
| 229 "(%s).apply(null, [function(){%s},%s,%d,%s,true]);", | 227 "(%s).apply(null, [function(){%s},%s,%d,%s,true]);", |
| 230 atoms::asString(atoms::EXECUTE_ASYNC_SCRIPT).c_str(), | 228 atoms::asString(atoms::EXECUTE_ASYNC_SCRIPT).c_str(), |
| (...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 capabilities_.local_state->GetWithoutPathExpansion(*iter, &value); | 1885 capabilities_.local_state->GetWithoutPathExpansion(*iter, &value); |
| 1888 Error* error = SetPreference(*iter, false /* is_user_pref */, | 1886 Error* error = SetPreference(*iter, false /* is_user_pref */, |
| 1889 value->DeepCopy()); | 1887 value->DeepCopy()); |
| 1890 if (error) | 1888 if (error) |
| 1891 return error; | 1889 return error; |
| 1892 } | 1890 } |
| 1893 return NULL; | 1891 return NULL; |
| 1894 } | 1892 } |
| 1895 | 1893 |
| 1896 } // namespace webdriver | 1894 } // namespace webdriver |
| OLD | NEW |