| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 UTF8ToWide(wait_js_frame_xpath), | 70 UTF8ToWide(wait_js_frame_xpath), |
| 71 UTF8ToWide(wait_js_expr), | 71 UTF8ToWide(wait_js_expr), |
| 72 wait_js_timeout); | 72 wait_js_timeout); |
| 73 ASSERT_TRUE(completed); | 73 ASSERT_TRUE(completed); |
| 74 } | 74 } |
| 75 if (var_to_fetch) { | 75 if (var_to_fetch) { |
| 76 std::string script = base::StringPrintf( | 76 std::string script = base::StringPrintf( |
| 77 "window.domAutomationController.send(%s);", var_to_fetch); | 77 "window.domAutomationController.send(%s);", var_to_fetch); |
| 78 | 78 |
| 79 std::wstring value; | 79 std::wstring value; |
| 80 bool success = tab->ExecuteAndExtractString(L"", ASCIIToWide(script), | 80 bool success = tab->ExecuteAndExtractString( |
| 81 &value); | 81 std::wstring(), ASCIIToWide(script), &value); |
| 82 ASSERT_TRUE(success); | 82 ASSERT_TRUE(success); |
| 83 result->javascript_variable = WideToUTF8(value); | 83 result->javascript_variable = WideToUTF8(value); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 bool WriteValueToFile(std::string value, const base::FilePath& path) { | 88 bool WriteValueToFile(std::string value, const base::FilePath& path) { |
| 89 int retval = file_util::WriteFile(path, value.c_str(), value.length()); | 89 int retval = file_util::WriteFile(path, value.c_str(), value.length()); |
| 90 return retval == static_cast<int>(value.length()); | 90 return retval == static_cast<int>(value.length()); |
| 91 } | 91 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // Write out the JS Variable if requested | 175 // Write out the JS Variable if requested |
| 176 base::FilePath jsvar_output_path = | 176 base::FilePath jsvar_output_path = |
| 177 cmd_line->GetSwitchValuePath("jsvar_output"); | 177 cmd_line->GetSwitchValuePath("jsvar_output"); |
| 178 if (!jsvar_output_path.value().empty()) { | 178 if (!jsvar_output_path.value().empty()) { |
| 179 ASSERT_TRUE(WriteValueToFile(result.javascript_variable, | 179 ASSERT_TRUE(WriteValueToFile(result.javascript_variable, |
| 180 jsvar_output_path)); | 180 jsvar_output_path)); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace | 184 } // namespace |
| OLD | NEW |