| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/ui/search/instant_test_utils.h" | 5 #include "chrome/browser/ui/search/instant_test_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 contents, WrapScript(script), result); | 111 contents, WrapScript(script), result); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool InstantTestBase::GetIntFromJS(content::WebContents* contents, | 114 bool InstantTestBase::GetIntFromJS(content::WebContents* contents, |
| 115 const std::string& script, | 115 const std::string& script, |
| 116 int* result) { | 116 int* result) { |
| 117 return content::ExecuteScriptAndExtractInt( | 117 return content::ExecuteScriptAndExtractInt( |
| 118 contents, WrapScript(script), result); | 118 contents, WrapScript(script), result); |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool InstantTestBase::GetDoubleFromJS(content::WebContents* contents, |
| 122 const std::string& script, |
| 123 double* result) { |
| 124 return content::ExecuteScriptAndExtractDouble(contents, WrapScript(script), |
| 125 result); |
| 126 } |
| 127 |
| 121 bool InstantTestBase::GetStringFromJS(content::WebContents* contents, | 128 bool InstantTestBase::GetStringFromJS(content::WebContents* contents, |
| 122 const std::string& script, | 129 const std::string& script, |
| 123 std::string* result) { | 130 std::string* result) { |
| 124 return content::ExecuteScriptAndExtractString( | 131 return content::ExecuteScriptAndExtractString( |
| 125 contents, WrapScript(script), result); | 132 contents, WrapScript(script), result); |
| 126 } | 133 } |
| 127 | 134 |
| 128 std::string InstantTestBase::GetOmniboxText() { | 135 std::string InstantTestBase::GetOmniboxText() { |
| 129 return base::UTF16ToUTF8(omnibox()->GetText()); | 136 return base::UTF16ToUTF8(omnibox()->GetText()); |
| 130 } | 137 } |
| 131 | 138 |
| 132 bool InstantTestBase::LoadImage(content::RenderViewHost* rvh, | 139 bool InstantTestBase::LoadImage(content::RenderViewHost* rvh, |
| 133 const std::string& image, | 140 const std::string& image, |
| 134 bool* loaded) { | 141 bool* loaded) { |
| 135 std::string js_chrome = | 142 std::string js_chrome = |
| 136 "var img = document.createElement('img');" | 143 "var img = document.createElement('img');" |
| 137 "img.onerror = function() { domAutomationController.send(false); };" | 144 "img.onerror = function() { domAutomationController.send(false); };" |
| 138 "img.onload = function() { domAutomationController.send(true); };" | 145 "img.onload = function() { domAutomationController.send(true); };" |
| 139 "img.src = '" + image + "';"; | 146 "img.src = '" + image + "';"; |
| 140 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); | 147 return content::ExecuteScriptAndExtractBool(rvh, js_chrome, loaded); |
| 141 } | 148 } |
| OLD | NEW |