Index: chrome/test/pyautolib/pyautolib.cc |
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc |
index 58ac2dd379557d0c8420fc34c8fa8fcb312a11c9..9d300d0e190bc9e0892d9fdf9fc1a7a7917b0fa9 100644 |
--- a/chrome/test/pyautolib/pyautolib.cc |
+++ b/chrome/test/pyautolib/pyautolib.cc |
@@ -295,6 +295,36 @@ std::string PyUITestBase::_SendJSONRequest(int window_index, |
return response; |
} |
+std::wstring PyUITestBase::ExecuteJavascript(const std::wstring& script, |
+ int window_index, |
+ int tab_index, |
+ const std::wstring& frame_xpath) { |
+ scoped_refptr<BrowserProxy> browser_proxy = |
+ automation()->GetBrowserWindow(window_index); |
+ EXPECT_TRUE(browser_proxy.get()); |
+ std::wstring response; |
+ if (!browser_proxy.get()) |
+ return response; |
+ scoped_refptr<TabProxy> tab_proxy = |
+ browser_proxy->GetTab(tab_index); |
+ EXPECT_TRUE(tab_proxy.get()); |
+ if (!tab_proxy.get()) |
+ return response; |
+ |
+ EXPECT_TRUE(tab_proxy->ExecuteAndExtractString(frame_xpath, script, |
+ &response)); |
+ return response; |
+} |
+ |
+std::wstring PyUITestBase::GetDOMValue(const std::wstring& expr, |
+ int window_index, |
+ int tab_index, |
+ const std::wstring& frame_xpath) { |
+ std::wstring script = std::wstring(L"window.domAutomationController.send(") + |
+ expr + std::wstring(L")"); |
+ return ExecuteJavascript(script, window_index, tab_index, frame_xpath); |
+} |
+ |
bool PyUITestBase::ResetToDefaultTheme() { |
return automation()->ResetToDefaultTheme(); |
} |