summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/media/media_player_browsertest.cc1
-rw-r--r--chrome/chrome.gyp4
-rw-r--r--chrome/chrome_tests.gypi6
-rw-r--r--chrome/test/automation/dom_automation_browsertest.cc345
-rw-r--r--chrome/test/automation/dom_element_proxy.cc267
-rw-r--r--chrome/test/automation/dom_element_proxy.h175
-rw-r--r--chrome/test/automation/javascript_execution_controller.cc110
-rw-r--r--chrome/test/automation/javascript_execution_controller.h125
-rw-r--r--chrome/test/automation/javascript_message_utils.h111
-rw-r--r--chrome/test/automation/tab_proxy.cc23
-rw-r--r--chrome/test/automation/tab_proxy.h14
-rw-r--r--chrome/test/base/ui_test_utils.cc44
-rw-r--r--chrome/test/base/ui_test_utils.h5
-rw-r--r--chrome/test/perf/tab_switching_test.cc1
-rw-r--r--chrome/test/perf/url_fetch_test.cc1
-rw-r--r--chrome/test/pyautolib/pyautolib.cc1
-rw-r--r--chrome/test/reliability/automated_ui_tests.cc1
-rw-r--r--chrome/test/ui/ui_test.cc3
-rw-r--r--chrome/test/webdriver/webdriver_element_id.cc2
-rw-r--r--content/test/layout_browsertest.cc10
20 files changed, 11 insertions, 1238 deletions
diff --git a/chrome/browser/chromeos/media/media_player_browsertest.cc b/chrome/browser/chromeos/media/media_player_browsertest.cc
index 7290387..278e4b1 100644
--- a/chrome/browser/chromeos/media/media_player_browsertest.cc
+++ b/chrome/browser/chromeos/media/media_player_browsertest.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
-#include "chrome/test/automation/dom_element_proxy.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 26dd016..860a1dd 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -980,10 +980,6 @@
'test/automation/automation_proxy.h',
'test/automation/browser_proxy.cc',
'test/automation/browser_proxy.h',
- 'test/automation/dom_element_proxy.cc',
- 'test/automation/dom_element_proxy.h',
- 'test/automation/javascript_execution_controller.cc',
- 'test/automation/javascript_execution_controller.h',
'test/automation/tab_proxy.cc',
'test/automation/tab_proxy.h',
'test/automation/value_conversion_traits.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 18d9832..3652db9 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -206,11 +206,6 @@
'test/automation/automation_proxy.h',
'test/automation/browser_proxy.cc',
'test/automation/browser_proxy.h',
- 'test/automation/dom_element_proxy.cc',
- 'test/automation/dom_element_proxy.h',
- 'test/automation/javascript_execution_controller.cc',
- 'test/automation/javascript_execution_controller.h',
- 'test/automation/javascript_message_utils.h',
'test/automation/tab_proxy.cc',
'test/automation/tab_proxy.h',
'test/automation/value_conversion_traits.cc',
@@ -3008,7 +3003,6 @@
'renderer/safe_browsing/phishing_dom_feature_extractor_browsertest.cc',
'renderer/safe_browsing/phishing_thumbnailer_browsertest.cc',
'renderer/translate_helper_browsertest.cc',
- 'test/automation/dom_automation_browsertest.cc',
'test/base/layout_test_http_server.cc',
'test/base/layout_test_http_server.h',
'test/base/empty_browser_test.cc',
diff --git a/chrome/test/automation/dom_automation_browsertest.cc b/chrome/test/automation/dom_automation_browsertest.cc
deleted file mode 100644
index 2467f7a..0000000
--- a/chrome/test/automation/dom_automation_browsertest.cc
+++ /dev/null
@@ -1,345 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/memory/ref_counted.h"
-#include "base/string_number_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/test/automation/dom_element_proxy.h"
-#include "chrome/test/automation/javascript_execution_controller.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/ui_test_utils.h"
-
-namespace {
-
-// Asserts that |expected_text| matches all the text in this element. This
-// includes the value of textfields and inputs.
-void EnsureTextMatches(
- DOMElementProxyRef proxy, const std::string& expected_text) {
- std::string text;
- ASSERT_TRUE(proxy->GetText(&text));
- ASSERT_EQ(expected_text, text);
-}
-
-// Asserts that |expected_html| matches the element's inner html.
-void EnsureInnerHTMLMatches(
- DOMElementProxyRef proxy, const std::string& expected_html) {
- std::string html;
- ASSERT_TRUE(proxy->GetInnerHTML(&html));
- ASSERT_EQ(expected_html, html);
-}
-
-// Asserts that |expected_name| matches the element's name.
-void EnsureNameMatches(
- DOMElementProxyRef proxy, const std::string& expected_name) {
- std::string name;
- ASSERT_TRUE(proxy->GetName(&name));
- ASSERT_EQ(expected_name, name);
-}
-
-// Asserts that |expected_value| eventually matches the element's value for
-// |attribute|. This function will block until the timeout is exceeded, in
-// which case it will fail, or until the two values match.
-void EnsureAttributeEventuallyMatches(
- DOMElementProxyRef proxy,
- const std::string& attribute,
- const std::string& new_value) {
- ASSERT_TRUE(proxy->is_valid());
- if (!proxy->DoesAttributeEventuallyMatch(attribute, new_value))
- FAIL() << "Executing or parsing JavaScript failed";
-}
-
-// Tests the DOMAutomation framework for manipulating DOMElements within
-// browser tests.
-class DOMAutomationTest : public InProcessBrowserTest {
- public:
- DOMAutomationTest() {
- JavaScriptExecutionController::set_timeout(
- base::TimeDelta::FromSeconds(30));
- }
-
- GURL GetTestURL(const char* path) {
- std::string url_path = "files/dom_automation/";
- url_path.append(path);
- return test_server()->GetURL(url_path);
- }
-};
-
-typedef DOMElementProxy::By By;
-
-#if defined(OS_WIN)
-// See http://crbug.com/61636
-#define MAYBE_FindByXPath DISABLED_FindByXPath
-#else
-#define MAYBE_FindByXPath FindByXPath
-#endif
-IN_PROC_BROWSER_TEST_F(DOMAutomationTest, MAYBE_FindByXPath) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(),
- GetTestURL("find_elements/test.html"));
- DOMElementProxyRef main_doc = ui_test_utils::GetActiveDOMDocument(browser());
-
- // Find first element.
- DOMElementProxyRef first_div = main_doc->FindElement(By::XPath("//div"));
- ASSERT_TRUE(first_div);
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(first_div, "0"));
-
- // Find many elements.
- std::vector<DOMElementProxyRef> elements;
- ASSERT_TRUE(main_doc->FindElements(By::XPath("//div"), &elements));
- ASSERT_EQ(2u, elements.size());
- for (size_t i = 0; i < elements.size(); i++) {
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(
- elements[i], base::UintToString(i)));
- }
-
- // Find 0 elements.
- ASSERT_FALSE(main_doc->FindElement(By::XPath("//nosuchtag")));
- elements.clear();
- ASSERT_TRUE(main_doc->FindElements(By::XPath("//nosuchtag"), &elements));
- elements.clear();
- ASSERT_EQ(0u, elements.size());
-
- // Find with invalid xpath.
- ASSERT_FALSE(main_doc->FindElement(By::XPath("'invalid'")));
- ASSERT_FALSE(main_doc->FindElement(By::XPath(" / / ")));
- ASSERT_FALSE(main_doc->FindElements(By::XPath("'invalid'"), &elements));
- ASSERT_FALSE(main_doc->FindElements(By::XPath(" / / "), &elements));
-
- // Find nested elements.
- int nested_count = 0;
- std::string span_name;
- DOMElementProxyRef node = main_doc->FindElement(By::XPath("/html/body/span"));
- while (node) {
- nested_count++;
- span_name.append("span");
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(node, span_name));
- node = node->FindElement(By::XPath("./span"));
- }
- ASSERT_EQ(3, nested_count);
-}
-
-IN_PROC_BROWSER_TEST_F(DOMAutomationTest, FindBySelectors) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(),
- GetTestURL("find_elements/test.html"));
- DOMElementProxyRef main_doc = ui_test_utils::GetActiveDOMDocument(browser());
-
- // Find first element.
- DOMElementProxyRef first_myclass =
- main_doc->FindElement(By::Selectors(".myclass"));
- ASSERT_TRUE(first_myclass);
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(first_myclass, "0"));
-
- // Find many elements.
- std::vector<DOMElementProxyRef> elements;
- ASSERT_TRUE(main_doc->FindElements(By::Selectors(".myclass"), &elements));
- ASSERT_EQ(2u, elements.size());
- for (size_t i = 0; i < elements.size(); i++) {
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(
- elements[i], base::UintToString(i)));
- }
-
- // Find 0 elements.
- ASSERT_FALSE(main_doc->FindElement(By::Selectors("#nosuchid")));
- elements.clear();
- ASSERT_TRUE(main_doc->FindElements(By::Selectors("#nosuchid"), &elements));
- ASSERT_EQ(0u, elements.size());
-
- // Find with invalid selectors.
- ASSERT_FALSE(main_doc->FindElement(By::Selectors("1#2")));
- ASSERT_FALSE(main_doc->FindElements(By::Selectors("1#2"), &elements));
-
- // Find nested elements.
- int nested_count = 0;
- std::string span_name;
- DOMElementProxyRef node = main_doc->FindElement(By::Selectors("span"));
- while (node) {
- nested_count++;
- span_name.append("span");
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(node, span_name));
- node = node->FindElement(By::Selectors("span"));
- }
- ASSERT_EQ(3, nested_count);
-}
-
-#if defined(OS_WIN)
-// http://crbug.com/72745
-#define MAYBE_FindByText DISABLED_FindByText
-#else
-#define MAYBE_FindByText FindByText
-#endif
-IN_PROC_BROWSER_TEST_F(DOMAutomationTest, MAYBE_FindByText) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(),
- GetTestURL("find_elements/test.html"));
- DOMElementProxyRef main_doc = ui_test_utils::GetActiveDOMDocument(browser());
-
- // Find first element.
- DOMElementProxyRef first_text = main_doc->FindElement(By::Text("div_text"));
- ASSERT_TRUE(first_text);
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(first_text, "0"));
-
- // Find many elements.
- std::vector<DOMElementProxyRef> elements;
- ASSERT_TRUE(main_doc->FindElements(By::Text("div_text"), &elements));
- ASSERT_EQ(2u, elements.size());
- for (size_t i = 0; i < elements.size(); i++) {
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(
- elements[i], base::UintToString(i)));
- }
-
- // Find 0 elements.
- ASSERT_FALSE(main_doc->FindElement(By::Text("nosuchtext")));
- elements.clear();
- ASSERT_TRUE(main_doc->FindElements(By::Text("nosuchtext"), &elements));
- ASSERT_EQ(0u, elements.size());
-
- // Find nested elements.
- int nested_count = 0;
- std::string span_name;
- DOMElementProxyRef node = main_doc->FindElement(By::Text("span_text"));
- while (node) {
- nested_count++;
- span_name.append("span");
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(node, span_name));
- node = node->FindElement(By::Text("span_text"));
- }
- ASSERT_EQ(3, nested_count);
-
- // Find only visible text.
- DOMElementProxyRef shown_td = main_doc->FindElement(By::Text("table_text"));
- ASSERT_TRUE(shown_td);
- ASSERT_NO_FATAL_FAILURE(EnsureNameMatches(shown_td, "shown"));
-
- // Find text in inputs.
- ASSERT_TRUE(main_doc->FindElement(By::Text("textarea_text")));
- ASSERT_TRUE(main_doc->FindElement(By::Text("input_text")));
-}
-
-IN_PROC_BROWSER_TEST_F(DOMAutomationTest, WaitFor1VisibleElement) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(), GetTestURL("wait/test.html"));
- DOMElementProxyRef main_doc = ui_test_utils::GetActiveDOMDocument(browser());
-
- DOMElementProxyRef div =
- main_doc->WaitFor1VisibleElement(By::Selectors("div"));
- ASSERT_TRUE(div.get());
- ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(div, "div_inner"));
-}
-
-IN_PROC_BROWSER_TEST_F(DOMAutomationTest, WaitForElementsToDisappear) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(), GetTestURL("wait/test.html"));
- DOMElementProxyRef main_doc = ui_test_utils::GetActiveDOMDocument(browser());
-
- ASSERT_TRUE(main_doc->WaitForElementsToDisappear(By::Selectors("img")));
- std::vector<DOMElementProxyRef> img_elements;
- ASSERT_TRUE(main_doc->FindElements(By::Selectors("img"), &img_elements));
- ASSERT_EQ(0u, img_elements.size());
-}
-
-IN_PROC_BROWSER_TEST_F(DOMAutomationTest, EnsureAttributeEventuallyMatches) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(), GetTestURL("wait/test.html"));
- DOMElementProxyRef main_doc = ui_test_utils::GetActiveDOMDocument(browser());
-
- DOMElementProxyRef anchor = main_doc->FindElement(By::Selectors("a"));
- ASSERT_TRUE(anchor.get());
- ASSERT_NO_FATAL_FAILURE(EnsureAttributeEventuallyMatches(
- anchor, "href", "http://www.google.com"));
-}
-
-IN_PROC_BROWSER_TEST_F(DOMAutomationTest, Frames) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(), GetTestURL("frames/test.html"));
- DOMElementProxyRef main_doc = ui_test_utils::GetActiveDOMDocument(browser());
-
- // Get both frame elements.
- std::vector<DOMElementProxyRef> frame_elements;
- ASSERT_TRUE(main_doc->FindElements(By::XPath("//frame"), &frame_elements));
- ASSERT_EQ(2u, frame_elements.size());
-
- // Get both frames, checking their contents are correct.
- DOMElementProxyRef frame1 = frame_elements[0]->GetContentDocument();
- DOMElementProxyRef frame2 = frame_elements[1]->GetContentDocument();
- ASSERT_TRUE(frame1 && frame2);
- DOMElementProxyRef frame_div =
- frame1->FindElement(By::XPath("/html/body/div"));
- ASSERT_TRUE(frame_div);
- ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(frame_div, "frame 1"));
- frame_div = frame2->FindElement(By::XPath("/html/body/div"));
- ASSERT_TRUE(frame_div);
- ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(frame_div, "frame 2"));
-
- // Get both inner iframes, checking their contents are correct.
- DOMElementProxyRef iframe1 =
- frame1->GetDocumentFromFrame("0");
- DOMElementProxyRef iframe2 =
- frame2->GetDocumentFromFrame("0");
- ASSERT_TRUE(iframe1 && iframe2);
- frame_div = iframe1->FindElement(By::XPath("/html/body/div"));
- ASSERT_TRUE(frame_div);
- ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(frame_div, "iframe 1"));
- frame_div = iframe2->FindElement(By::XPath("/html/body/div"));
- ASSERT_TRUE(frame_div);
- ASSERT_NO_FATAL_FAILURE(EnsureInnerHTMLMatches(frame_div, "iframe 2"));
-
- // Get nested frame.
- ASSERT_EQ(iframe1.get(), main_doc->GetDocumentFromFrame("0", "0").get());
- ASSERT_EQ(iframe2.get(), main_doc->GetDocumentFromFrame("1", "0").get());
-}
-
-IN_PROC_BROWSER_TEST_F(DOMAutomationTest, Events) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(), GetTestURL("events/test.html"));
- DOMElementProxyRef main_doc = ui_test_utils::GetActiveDOMDocument(browser());
-
- // Click link and make sure text changes.
- DOMElementProxyRef link = main_doc->FindElement(By::Selectors("a"));
- ASSERT_TRUE(link && link->Click());
- ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(link, "clicked"));
-
- // Click input button and make sure textfield changes.
- DOMElementProxyRef button = main_doc->FindElement(By::Selectors("#button"));
- DOMElementProxyRef textfield =
- main_doc->FindElement(By::Selectors("#textfield"));
- ASSERT_TRUE(textfield && button && button->Click());
- ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(textfield, "clicked"));
-
- // Type in the textfield.
- ASSERT_TRUE(textfield->SetText("test"));
- ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(textfield, "test"));
-
- // Type in the textarea.
- DOMElementProxyRef textarea =
- main_doc->FindElement(By::Selectors("textarea"));
- ASSERT_TRUE(textarea && textarea->Type("test"));
- ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(textarea, "textareatest"));
-}
-
-IN_PROC_BROWSER_TEST_F(DOMAutomationTest, StringEscape) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(),
- GetTestURL("string_escape/test.html"));
- DOMElementProxyRef main_doc = ui_test_utils::GetActiveDOMDocument(browser());
-
- DOMElementProxyRef textarea =
- main_doc->FindElement(By::Selectors("textarea"));
- ASSERT_TRUE(textarea);
- ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(textarea, WideToUTF8(L"\u00FF")));
-
- const wchar_t* set_and_expect_strings[] = {
- L"\u00FF and \u00FF",
- L"\n \t \\",
- L"' \""
- };
- for (size_t i = 0; i < 3; i++) {
- ASSERT_TRUE(textarea->SetText(WideToUTF8(set_and_expect_strings[i])));
- ASSERT_NO_FATAL_FAILURE(EnsureTextMatches(
- textarea, WideToUTF8(set_and_expect_strings[i])));
- }
-}
-
-} // namespace
diff --git a/chrome/test/automation/dom_element_proxy.cc b/chrome/test/automation/dom_element_proxy.cc
deleted file mode 100644
index 3417c5a..0000000
--- a/chrome/test/automation/dom_element_proxy.cc
+++ /dev/null
@@ -1,267 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/test/automation/dom_element_proxy.h"
-
-#include "chrome/test/automation/javascript_execution_controller.h"
-#include "chrome/test/automation/javascript_message_utils.h"
-
-using javascript_utils::JavaScriptPrintf;
-
-// JavaScriptObjectProxy methods
-JavaScriptObjectProxy::JavaScriptObjectProxy(
- JavaScriptExecutionController* executor, int handle)
- : executor_(executor->AsWeakPtr()), handle_(handle) {}
-
-JavaScriptObjectProxy::~JavaScriptObjectProxy() {
- if (is_valid())
- executor_->Remove(handle_);
-}
-
-// DOMElementProxy::By methods
-// static
-DOMElementProxy::By DOMElementProxy::By::XPath(
- const std::string& xpath) {
- return By(TYPE_XPATH, xpath);
-}
-
-// static
-DOMElementProxy::By DOMElementProxy::By::Selectors(
- const std::string& selectors) {
- return By(TYPE_SELECTORS, selectors);
-}
-
-// static
-DOMElementProxy::By DOMElementProxy::By::Text(
- const std::string& text) {
- return By(TYPE_TEXT, text);
-}
-
-// DOMElementProxy methods
-DOMElementProxyRef DOMElementProxy::GetContentDocument() {
- int element_handle;
- if (!GetValue("contentdocument", &element_handle))
- return NULL;
- return executor_->GetObjectProxy<DOMElementProxy>(element_handle);
-}
-
-DOMElementProxyRef DOMElementProxy::GetDocumentFromFrame(
- const std::vector<std::string>& frame_names) {
- if (!is_valid())
- return NULL;
-
- const char* script = "domAutomation.getDocumentFromFrame("
- "domAutomation.getObject(%s), %s);";
- int element_handle;
- if (!executor_->ExecuteJavaScriptAndGetReturn(
- JavaScriptPrintf(script, this->handle(), frame_names),
- &element_handle)) {
- return NULL;
- }
- return executor_->GetObjectProxy<DOMElementProxy>(element_handle);
-}
-
-DOMElementProxyRef DOMElementProxy::GetDocumentFromFrame(
- const std::string& frame_name1, const std::string& frame_name2,
- const std::string& frame_name3) {
- if (!is_valid())
- return NULL;
-
- std::vector<std::string> frame_names;
- frame_names.push_back(frame_name1);
- if (!frame_name2.empty())
- frame_names.push_back(frame_name2);
- if (!frame_name3.empty())
- frame_names.push_back(frame_name3);
- return GetDocumentFromFrame(frame_names);
-}
-
-DOMElementProxyRef DOMElementProxy::FindElement(const By& by) {
- if (!is_valid())
- return NULL;
-
- const char* script = "domAutomation.findElement("
- "domAutomation.getObject(%s), %s);";
- int element_handle;
- if (!executor_->ExecuteJavaScriptAndGetReturn(
- JavaScriptPrintf(script, this->handle(), by), &element_handle)) {
- return NULL;
- }
- return executor_->GetObjectProxy<DOMElementProxy>(element_handle);
-}
-
-bool DOMElementProxy::FindElements(const By& by,
- std::vector<DOMElementProxyRef>* elements) {
- if (!elements) {
- NOTREACHED();
- return false;
- }
- if (!is_valid())
- return false;
-
- const char* script = "domAutomation.findElements("
- "domAutomation.getObject(%s), %s);";
- std::vector<int> element_handles;
- if (!executor_->ExecuteJavaScriptAndGetReturn(
- JavaScriptPrintf(script, this->handle(), by), &element_handles)) {
- return false;
- }
- for (size_t i = 0; i < element_handles.size(); i++) {
- elements->push_back(make_scoped_refptr(
- executor_->GetObjectProxy<DOMElementProxy>(element_handles[i])));
- }
- return true;
-}
-
-bool DOMElementProxy::WaitForVisibleElementCount(
- const By& by, int count, std::vector<DOMElementProxyRef>* elements) {
- if (!elements) {
- NOTREACHED();
- return false;
- }
- if (!is_valid())
- return false;
-
- const char* script = "domAutomation.waitForVisibleElementCount("
- "domAutomation.getObject(%s), %s, %s,"
- "domAutomation.getCallId());";
- std::vector<int> element_handles;
- if (!executor_->ExecuteAsyncJavaScriptAndGetReturn(
- JavaScriptPrintf(script, this->handle(), by, count), &element_handles)) {
- return false;
- }
- if (static_cast<int>(element_handles.size()) == count) {
- for (size_t i = 0; i < element_handles.size(); i++) {
- elements->push_back(make_scoped_refptr(
- executor_->GetObjectProxy<DOMElementProxy>(element_handles[i])));
- }
- }
- return static_cast<int>(element_handles.size()) == count;
-}
-
-DOMElementProxyRef DOMElementProxy::WaitFor1VisibleElement(const By& by) {
- std::vector<DOMElementProxyRef> elements;
- if (!WaitForVisibleElementCount(by, 1, &elements))
- return NULL;
- return elements[0];
-}
-
-bool DOMElementProxy::WaitForElementsToDisappear(const By& by) {
- std::vector<DOMElementProxyRef> elements;
- return WaitForVisibleElementCount(by, 0, &elements);
-}
-
-bool DOMElementProxy::Click() {
- if (!is_valid())
- return false;
-
- const char* script = "domAutomation.click(domAutomation.getObject(%s));";
- return executor_->ExecuteJavaScript(
- JavaScriptPrintf(script, this->handle()));
-}
-
-bool DOMElementProxy::Type(const std::string& text) {
- if (!is_valid())
- return false;
-
- const char* script = "domAutomation.type(domAutomation.getObject(%s), %s);";
- bool success = false;
- if (!executor_->ExecuteJavaScriptAndGetReturn(
- JavaScriptPrintf(script, this->handle(), text), &success)) {
- return false;
- }
- return success;
-}
-
-bool DOMElementProxy::SetText(const std::string& text) {
- if (!is_valid())
- return false;
-
- const char* script = "domAutomation.setText("
- "domAutomation.getObject(%s), %s);";
- bool success = false;
- if (!executor_->ExecuteJavaScriptAndGetReturn(
- JavaScriptPrintf(script, this->handle(), text), &success)) {
- return false;
- }
- return success;
-}
-
-bool DOMElementProxy::GetProperty(const std::string& property,
- std::string* out) {
- if (!out) {
- NOTREACHED();
- return false;
- }
- if (!is_valid())
- return false;
-
- const char* script = "domAutomation.getProperty("
- "domAutomation.getObject(%s), %s);";
- return executor_->ExecuteJavaScriptAndGetReturn(
- JavaScriptPrintf(script, this->handle(), property), out);
-}
-
-bool DOMElementProxy::GetAttribute(const std::string& attribute,
- std::string* out) {
- if (!out) {
- NOTREACHED();
- return false;
- }
- if (!is_valid())
- return false;
-
- const char* script = "domAutomation.getAttribute("
- "domAutomation.getObject(%s), %s);";
- return executor_->ExecuteJavaScriptAndGetReturn(
- JavaScriptPrintf(script, this->handle(), attribute), out);
-}
-
-bool DOMElementProxy::GetText(std::string* text) {
- return GetValue("text", text);
-}
-
-bool DOMElementProxy::GetInnerText(std::string* text) {
- return GetValue("innertext", text);
-}
-
-bool DOMElementProxy::GetInnerHTML(std::string* html) {
- return GetValue("innerhtml", html);
-}
-
-bool DOMElementProxy::GetId(std::string* id) {
- return GetValue("id", id);
-}
-
-bool DOMElementProxy::GetName(std::string* name) {
- return GetAttribute("name", name);
-}
-
-bool DOMElementProxy::GetVisibility(bool* visibility) {
- return GetValue("visibility", visibility);
-}
-
-bool DOMElementProxy::DoesAttributeEventuallyMatch(
- const std::string& attribute, const std::string& new_value) {
- const char* script = "domAutomation.waitForAttribute("
- "domAutomation.getObject(%s), %s, %s,"
- "domAutomation.getCallId())";
- return executor_->ExecuteAsyncJavaScript(
- JavaScriptPrintf(script, this->handle(), attribute, new_value));
-}
-
-template <typename T>
-bool DOMElementProxy::GetValue(const std::string& type, T* value) {
- if (!value) {
- NOTREACHED();
- return false;
- }
- if (!is_valid())
- return false;
-
- const char* script = "domAutomation.getValue("
- "domAutomation.getObject(%s), %s);";
- return executor_->ExecuteJavaScriptAndGetReturn(
- JavaScriptPrintf(script, this->handle(), type), value);
-}
diff --git a/chrome/test/automation/dom_element_proxy.h b/chrome/test/automation/dom_element_proxy.h
deleted file mode 100644
index cb65a34..0000000
--- a/chrome/test/automation/dom_element_proxy.h
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_TEST_AUTOMATION_DOM_ELEMENT_PROXY_H_
-#define CHROME_TEST_AUTOMATION_DOM_ELEMENT_PROXY_H_
-
-#include <string>
-#include <vector>
-
-#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
-
-class DOMElementProxy;
-class JavaScriptExecutionController;
-
-typedef scoped_refptr<DOMElementProxy> DOMElementProxyRef;
-
-// This class is a proxy to an object in JavaScript. It holds a handle which
-// can be used to retrieve the actual object in JavaScript scripts.
-class JavaScriptObjectProxy
- : public base::RefCountedThreadSafe<JavaScriptObjectProxy> {
- public:
- JavaScriptObjectProxy(JavaScriptExecutionController* executor, int handle);
- ~JavaScriptObjectProxy();
-
- int handle() const { return handle_; }
- bool is_valid() const { return executor_.get() != NULL; }
-
- protected:
- base::WeakPtr<JavaScriptExecutionController> executor_;
- int handle_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(JavaScriptObjectProxy);
-};
-
-// This class presents the interface to actions that can be performed on
-// a given DOM element. Note that this object can be invalidated at any
-// time. In that case, any subsequent calls will return false immediately.
-// This class should never be instantiated directly, except by a
-// JavaScriptExecutionController.
-class DOMElementProxy : public JavaScriptObjectProxy {
- public:
- // This class represents the various methods by which elements are located
- // in the DOM.
- class By {
- public:
- enum ByType {
- TYPE_XPATH,
- TYPE_SELECTORS,
- TYPE_TEXT
- };
-
- // Returns a By for locating an element using an XPath query.
- static By XPath(const std::string& xpath);
-
- // Returns a By for locating an element using CSS selectors.
- static By Selectors(const std::string& selectors);
-
- // Returns a By for locating an element by its contained text. For inputs
- // and textareas, this includes the element's value.
- static By Text(const std::string& text);
-
- ByType type() const { return type_; }
- std::string query() const { return query_; }
-
- private:
- By(ByType type, const std::string& query)
- : type_(type), query_(query) {}
-
- ByType type_;
- std::string query_;
- };
-
- DOMElementProxy(JavaScriptExecutionController* executor, int handle)
- : JavaScriptObjectProxy(executor, handle) {}
-
- // Returns the document for this element, which must be of type frame.
- // Returns NULL on failure.
- DOMElementProxyRef GetContentDocument();
-
- // Finds the frame which matches the list of given names, starting from
- // the window that contains this element. Each name in the list is used to
- // select the next sub frame. Returns NULL on failure.
- // A vector of "2" and "ad" is equivalent to the javascript:
- // frame.frames["2"].frames["ad"].
- DOMElementProxyRef GetDocumentFromFrame(
- const std::vector<std::string>& frame_names);
-
- // Same as above but with different argument for convenience.
- DOMElementProxyRef GetDocumentFromFrame(const std::string& frame_name1,
- const std::string& frame_name2 = "",
- const std::string& frame_name3 = "");
-
- // Finds the first element found by the given locator method |by|, or NULL
- // if no element was found.
- DOMElementProxyRef FindElement(const By& by);
-
- // Finds all the elements found by the given locator method and appends
- // them to the given list. Returns true on success.
- bool FindElements(const By& by,
- std::vector<DOMElementProxyRef>* elements);
-
- // Waits until the number of visible elements satisfying the given locator
- // method |by| equals |count|, and appends them to the given list. Returns
- // true when |count| matches the number of visible elements or false if
- // the timeout is exceeded while waiting. If false, the list is not modified.
- bool WaitForVisibleElementCount(const By& by, int count,
- std::vector<DOMElementProxyRef>* elements);
-
- // Waits until exactly 1 element is visible which satisifies the given
- // locator method. Returns the found element, or NULL if the timeout is
- // exceeded. If it is possible for more than 1 element to safisfy the query,
- // use WaitForVisibleElementCount instead.
- DOMElementProxyRef WaitFor1VisibleElement(const By& by);
-
- // Waits until no visible elements satisify the given locator method.
- // Returns true when no more visible elements are found or false if the
- // timeout is exceeded while waiting.
- bool WaitForElementsToDisappear(const By& by);
-
- // Dispatches a click MouseEvent to this element and all its parents.
- // Returns true on success.
- bool Click();
-
- // Adds |text| to this element. Only valid for textareas and textfields.
- // Returns true on success.
- bool Type(const std::string& text);
-
- // Sets the input text to |text|. Only valid for textareas and textfields.
- // Returns true on success.
- bool SetText(const std::string& text);
-
- // Gets the element's value for its |property|. Returns true on success.
- bool GetProperty(const std::string& property,
- std::string* out);
-
- // Gets the element's value for its |attribute|. Returns true on success.
- bool GetAttribute(const std::string& attribute,
- std::string* out);
-
- // Retrieves all the text in this element. This includes the value
- // of textfields and inputs. Returns true on success.
- bool GetText(std::string* text);
- bool GetInnerText(std::string* text);
-
- // Retrieves the element's inner HTML. Returns true on success.
- bool GetInnerHTML(std::string* html);
-
- // Retrieves the element's id. Returns true on success.
- bool GetId(std::string* id);
-
- // Retrieves the element's name. Returns true on success.
- bool GetName(std::string* name);
-
- // Retrieves the element's visibility. Returns true on success.
- bool GetVisibility(bool* visilibity);
-
- // Returns if |expected_value| eventually matches the element's value for
- // |attribute|. This function will block until the timeout is exceeded, in
- // which case it will fail, or until the two values match.
- bool DoesAttributeEventuallyMatch(const std::string& attribute,
- const std::string& expected_value);
-
- private:
- // Gets the element's value for the given type. This is a helper method
- // for simple get methods.
- template <typename T>
- bool GetValue(const std::string& type, T* out);
-
- DISALLOW_COPY_AND_ASSIGN(DOMElementProxy);
-};
-
-#endif // CHROME_TEST_AUTOMATION_DOM_ELEMENT_PROXY_H_
diff --git a/chrome/test/automation/javascript_execution_controller.cc b/chrome/test/automation/javascript_execution_controller.cc
deleted file mode 100644
index cd058cf..0000000
--- a/chrome/test/automation/javascript_execution_controller.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/test/automation/javascript_execution_controller.h"
-
-#include "base/json/json_string_value_serializer.h"
-#include "chrome/test/automation/javascript_message_utils.h"
-
-using javascript_utils::JavaScriptPrintf;
-
-// Initialize this timeout to an invalid value. Each test framework or test
-// must set an appropriate timeout using set_timeout, or the
-// JavaScriptExecutionController will complain.
-int JavaScriptExecutionController::timeout_ms_ = -1;
-
-JavaScriptExecutionController::JavaScriptExecutionController() {}
-
-bool JavaScriptExecutionController::ExecuteJavaScript(
- const std::string& script) {
- scoped_ptr<Value> return_value;
- return ExecuteAndParseHelper(WrapJavaScript(script), &return_value);
-}
-
-bool JavaScriptExecutionController::ExecuteAsyncJavaScript(
- const std::string& script) {
- scoped_ptr<Value> return_value;
- return ExecuteAndParseHelper(WrapAsyncJavaScript(script), &return_value);
-}
-
-JavaScriptExecutionController::~JavaScriptExecutionController() {}
-
-void JavaScriptExecutionController::Remove(int handle) {
- handle_to_object_.erase(handle);
- if (handle_to_object_.empty())
- LastObjectRemoved();
-}
-
-std::string JavaScriptExecutionController::WrapJavaScript(
- const std::string& original_script) {
- const char* script =
- "domAutomationController.setAutomationId(0);"
- "domAutomation.evaluateJavaScript(%s);";
- return JavaScriptPrintf(script, original_script);
-}
-
-std::string JavaScriptExecutionController::WrapAsyncJavaScript(
- const std::string& original_script) {
- if (timeout_ms_ == -1) {
- NOTREACHED() << "Timeout for asynchronous JavaScript methods has not been "
- << "set. Call JavaScriptExecutionController::"
- << "set_timeout(timeout_in_ms).";
- }
- const char* script =
- "domAutomationController.setAutomationId(0);"
- "domAutomation.evaluateAsyncJavaScript(%s, %s);";
- return JavaScriptPrintf(script, original_script, timeout_ms_);
-}
-
-bool JavaScriptExecutionController::ExecuteAndParseHelper(
- const std::string& script, scoped_ptr<Value>* result) {
- std::string json;
- if (!ExecuteJavaScriptAndGetJSON(script, &json)) {
- LOG(ERROR) << "JavaScript either did not execute or did not respond.";
- return false;
- }
-
- // Deserialize the json to a Value.
- JSONStringValueSerializer parse(json);
- std::string parsing_error;
- scoped_ptr<Value> root_value(parse.Deserialize(NULL, &parsing_error));
-
- // Parse the response.
- // The response must be a list of 3 components:
- // - success (boolean): whether the javascript was evaluated with no errors
- // - error (string): the evaluation error message or the empty string if
- // no error occurred
- // - result (string): the result of the evaluation (in JSON), or the
- // exact error if an error occurred (in JSON)
- if (!root_value.get()) {
- if (parsing_error.length()) {
- LOG(ERROR) << "Cannot parse JSON response: " << parsing_error;
- } else {
- LOG(ERROR) << "JSON response is empty";
- }
- return false;
- }
-
- bool success;
- std::string evaluation_error;
- Value* evaluation_result_value;
- if (!root_value->IsType(Value::TYPE_LIST)) {
- LOG(ERROR) << "JSON response was not in correct format";
- return false;
- }
- ListValue* list = static_cast<ListValue*>(root_value.get());
- if (!list->GetBoolean(0, &success) ||
- !list->GetString(1, &evaluation_error) ||
- !list->Remove(2, &evaluation_result_value)) {
- LOG(ERROR) << "JSON response was not in correct format";
- return false;
- }
- if (!success) {
- LOG(WARNING) << "JavaScript evaluation did not complete successfully: "
- << evaluation_error;
- return false;
- }
- result->reset(evaluation_result_value);
- return true;
-}
diff --git a/chrome/test/automation/javascript_execution_controller.h b/chrome/test/automation/javascript_execution_controller.h
deleted file mode 100644
index db78db9..0000000
--- a/chrome/test/automation/javascript_execution_controller.h
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_
-#define CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_
-
-#include <map>
-#include <string>
-
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/time.h"
-#include "base/values.h"
-#include "chrome/test/automation/javascript_message_utils.h"
-
-class JavaScriptObjectProxy;
-
-// This class handles the execution of arbitrary JavaScript, preparing it for
-// execution, and parsing its result (in JSON). It keeps track of all returned
-// JavaScript objects.
-class JavaScriptExecutionController
- : public base::SupportsWeakPtr<JavaScriptExecutionController> {
- public:
- JavaScriptExecutionController();
-
- // Executes |script| and parse the return value. Returns whether the
- // execution and parsing succeeded.
- template <typename T>
- bool ExecuteJavaScriptAndGetReturn(const std::string& script, T* result) {
- scoped_ptr<Value> returnValue;
- if (!ExecuteAndParseHelper(WrapJavaScript(script), &returnValue))
- return false;
- return ValueConversionTraits<T>::SetFromValue(returnValue.get(), result);
- }
-
- // Similar to above, except that it does not get the return value.
- bool ExecuteJavaScript(const std::string& script);
-
- // Executes |script|, waits for it to send a JSON response, and parses the
- // return value. This call itself blocks, but the JavaScript responds
- // asynchronously. Returns whether the execution and parsing succeeded.
- // Will return false on timeouts.
- template <typename T>
- bool ExecuteAsyncJavaScriptAndGetReturn(const std::string& script,
- T* result) {
- scoped_ptr<Value> returnValue;
- if (!ExecuteAndParseHelper(WrapAsyncJavaScript(script), &returnValue))
- return false;
- return ValueConversionTraits<T>::SetFromValue(returnValue.get(), result);
- }
-
- // Similar to above, except that it does not get the return value.
- bool ExecuteAsyncJavaScript(const std::string& script);
-
- // Returns the proxy associated with |handle|, creating one if necessary.
- // The proxy must be inherit JavaScriptObjectProxy.
- template<class JavaScriptObject>
- JavaScriptObject* GetObjectProxy(int handle) {
- JavaScriptObject* obj = NULL;
- HandleToObjectMap::const_iterator iter = handle_to_object_.find(handle);
- if (iter == handle_to_object_.end()) {
- obj = new JavaScriptObject(this, handle);
- if (handle_to_object_.empty())
- FirstObjectAdded();
- handle_to_object_.insert(std::make_pair(handle, obj));
- } else {
- obj = static_cast<JavaScriptObject*>(iter->second);
- }
- return obj;
- }
-
- // Sets a timeout to be used for all JavaScript methods in which a response
- // is returned asynchronously.
- static void set_timeout(base::TimeDelta timeout) {
- timeout_ms_ = timeout.InMilliseconds();
- }
-
- protected:
- virtual ~JavaScriptExecutionController();
-
- // Executes |script| and sets the JSON response |json|. Returns true
- // on success.
- virtual bool ExecuteJavaScriptAndGetJSON(const std::string& script,
- std::string* json) = 0;
-
- // Called when this controller is tracking its first object. Used by
- // reference counted subclasses.
- virtual void FirstObjectAdded() {}
-
- // Called when this controller is no longer tracking any objects. Used by
- // reference counted subclasses.
- virtual void LastObjectRemoved() {}
-
- private:
- typedef std::map<int, JavaScriptObjectProxy*> HandleToObjectMap;
-
- friend class JavaScriptObjectProxy;
- // Called by JavaScriptObjectProxy on destruction.
- void Remove(int handle);
-
- // Helper method for executing JavaScript and parsing the JSON response.
- // If successful, returns true and sets |returnValue| as the script's return
- // value.
- bool ExecuteAndParseHelper(const std::string& script,
- scoped_ptr<Value>* returnValue);
-
- // Returns |script| wrapped and prepared for proper JavaScript execution,
- // via the JavaScript function domAutomation.evaluateJavaScript.
- std::string WrapJavaScript(const std::string& script);
-
- // Returns |script| wrapped and prepared for proper JavaScript execution
- // via the JavaScript function domAutomation.evaluateAsyncJavaScript.
- std::string WrapAsyncJavaScript(const std::string& script);
-
- // Timeout to use for all asynchronous methods.
- static int timeout_ms_;
-
- // Weak pointer to all the object proxies that we create.
- HandleToObjectMap handle_to_object_;
-
- DISALLOW_COPY_AND_ASSIGN(JavaScriptExecutionController);
-};
-
-#endif // CHROME_TEST_AUTOMATION_JAVASCRIPT_EXECUTION_CONTROLLER_H_
diff --git a/chrome/test/automation/javascript_message_utils.h b/chrome/test/automation/javascript_message_utils.h
deleted file mode 100644
index ab18477..0000000
--- a/chrome/test/automation/javascript_message_utils.h
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_TEST_AUTOMATION_JAVASCRIPT_MESSAGE_UTILS_H_
-#define CHROME_TEST_AUTOMATION_JAVASCRIPT_MESSAGE_UTILS_H_
-
-#include <string>
-#include <vector>
-
-#include "base/json/json_writer.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/stringprintf.h"
-#include "base/values.h"
-#include "chrome/test/automation/dom_element_proxy.h"
-#include "chrome/test/automation/value_conversion_traits.h"
-
-template <>
-struct ValueConversionTraits<DOMElementProxy::By> {
- typedef DOMElementProxy::By type;
- static Value* CreateValueFrom(const type& t) {
- DictionaryValue* value = new DictionaryValue();
- std::string by_type;
- switch (t.type()) {
- case type::TYPE_XPATH:
- by_type = "xpath";
- break;
- case type::TYPE_SELECTORS:
- by_type = "selectors";
- break;
- case type::TYPE_TEXT:
- by_type = "text";
- break;
- default:
- NOTREACHED();
- break;
- }
- value->SetString("type", by_type);
- value->SetString("queryString", t.query());
- return value;
- }
-};
-
-template <typename T>
-struct ValueConversionTraits<std::vector<T> > {
- static Value* CreateValueFrom(const std::vector<T>& t) {
- ListValue* value = new ListValue();
- for (size_t i = 0; i < t.size(); i++) {
- value->Append(ValueConversionTraits<T>::CreateValueFrom(t[i]));
- }
- return value;
- }
- static bool SetFromValue(const Value* value, std::vector<T>* t) {
- if (!value->IsType(Value::TYPE_LIST))
- return false;
-
- const ListValue* list_value = static_cast<const ListValue*>(value);
- ListValue::const_iterator iter;
- for (iter = list_value->begin(); iter != list_value->end(); ++iter) {
- if (!ValueConversionTraits<T>::CanConvert(*iter))
- return false;
- }
- for (iter = list_value->begin(); iter != list_value->end(); ++iter) {
- T inner_value;
- ValueConversionTraits<T>::SetFromValue(*iter, &inner_value);
- t->push_back(inner_value);
- }
- return true;
- }
-};
-
-namespace javascript_utils {
-
-// Converts |arg| to a JSON string.
-template <typename T>
-std::string JSONStringify(const T& arg) {
- std::string javascript;
- scoped_ptr<Value> value(ValueConversionTraits<T>::CreateValueFrom(arg));
- base::JSONWriter::Write(value.get(), &javascript);
- return javascript;
-}
-
-// Converts |arg| to a JSON string and returns a string formatted as
-// |format| specifies. |format| should only expect string arguments.
-template <typename T>
-std::string JavaScriptPrintf(const std::string& format, const T& arg) {
- return base::StringPrintf(format.c_str(), JSONStringify(arg).c_str());
-}
-
-// Similar to above, but with an additional argument.
-template <typename T1, typename T2>
-std::string JavaScriptPrintf(const std::string& format, const T1& arg1,
- const T2& arg2) {
- return base::StringPrintf(format.c_str(),
- JSONStringify(arg1).c_str(),
- JSONStringify(arg2).c_str());
-}
-
-// Similar to above, but with an additional argument.
-template <typename T1, typename T2, typename T3>
-std::string JavaScriptPrintf(const std::string& format, const T1& arg1,
- const T2& arg2, const T3& arg3) {
- return base::StringPrintf(format.c_str(),
- JSONStringify(arg1).c_str(),
- JSONStringify(arg2).c_str(),
- JSONStringify(arg3).c_str());
-}
-
-} // namespace javascript_utils
-
-#endif // CHROME_TEST_AUTOMATION_JAVASCRIPT_MESSAGE_UTILS_H_
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index 1e28f7e..e8a063a 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -247,16 +247,6 @@ Value* TabProxy::ExecuteAndExtractValue(const std::wstring& frame_xpath,
return deserializer.Deserialize(NULL, NULL);
}
-DOMElementProxyRef TabProxy::GetDOMDocument() {
- if (!is_valid())
- return NULL;
-
- int element_handle;
- if (!ExecuteJavaScriptAndGetReturn("document", &element_handle))
- return NULL;
- return GetObjectProxy<DOMElementProxy>(element_handle);
-}
-
bool TabProxy::GetCookies(const GURL& url, std::string* cookies) {
if (!is_valid())
return false;
@@ -547,19 +537,6 @@ void TabProxy::OnChannelError() {
TabProxy::~TabProxy() {}
-bool TabProxy::ExecuteJavaScriptAndGetJSON(const std::string& script,
- std::string* json) {
- if (!is_valid())
- return false;
- if (!json) {
- NOTREACHED();
- return false;
- }
- return sender_->Send(new AutomationMsg_DomOperation(handle_, L"",
- UTF8ToWide(script),
- json));
-}
-
void TabProxy::FirstObjectAdded() {
AddRef();
}
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index 62b1ed7..4ce8630 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -19,8 +19,6 @@
#include "base/observer_list.h"
#include "chrome/common/automation_constants.h"
#include "chrome/test/automation/automation_handle_tracker.h"
-#include "chrome/test/automation/dom_element_proxy.h"
-#include "chrome/test/automation/javascript_execution_controller.h"
#include "content/public/browser/save_page_type.h"
#include "content/public/common/page_type.h"
#include "content/public/common/security_style.h"
@@ -38,8 +36,7 @@ namespace base {
class Value;
}
-class TabProxy : public AutomationResourceProxy,
- public JavaScriptExecutionController {
+class TabProxy : public AutomationResourceProxy {
public:
class TabProxyDelegate {
public:
@@ -84,10 +81,6 @@ class TabProxy : public AutomationResourceProxy,
const std::wstring& jscript,
int* value) WARN_UNUSED_RESULT;
- // Returns a DOMElementProxyRef to the tab's current DOM document.
- // This proxy is invalidated when the document changes.
- DOMElementProxyRef GetDOMDocument();
-
// Navigates to a url. This method accepts the same kinds of URL input that
// can be passed to Chrome on the command line. This is a synchronous call and
// hence blocks until the navigation completes.
@@ -274,11 +267,6 @@ class TabProxy : public AutomationResourceProxy,
protected:
virtual ~TabProxy();
- // Override JavaScriptExecutionController methods.
- // Executes |script| and gets the response JSON. Returns true on success.
- bool ExecuteJavaScriptAndGetJSON(const std::string& script,
- std::string* json) WARN_UNUSED_RESULT;
-
// Called when tracking the first object. Used for reference counting
// purposes.
void FirstObjectAdded();
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index ab3d344..77e4a18 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -48,7 +48,6 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_action.h"
-#include "chrome/test/automation/javascript_execution_controller.h"
#include "chrome/test/base/bookmark_load_observer.h"
#include "content/public/browser/dom_operation_notification_details.h"
#include "content/public/browser/download_item.h"
@@ -192,40 +191,6 @@ class FindInPageNotificationObserver : public content::NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver);
};
-class InProcessJavaScriptExecutionController
- : public base::RefCounted<InProcessJavaScriptExecutionController>,
- public JavaScriptExecutionController {
- public:
- explicit InProcessJavaScriptExecutionController(
- RenderViewHost* render_view_host)
- : render_view_host_(render_view_host) {}
-
- protected:
- // Executes |script| and sets the JSON response |json|.
- virtual bool ExecuteJavaScriptAndGetJSON(const std::string& script,
- std::string* json) {
- DOMOperationObserver dom_op_observer(render_view_host_);
- render_view_host_->ExecuteJavascriptInWebFrame(string16(),
- UTF8ToUTF16(script));
- return dom_op_observer.WaitAndGetResponse(json);
- }
-
- virtual void FirstObjectAdded() {
- AddRef();
- }
-
- virtual void LastObjectRemoved() {
- Release();
- }
-
- private:
- friend class base::RefCounted<InProcessJavaScriptExecutionController>;
- virtual ~InProcessJavaScriptExecutionController() {}
-
- // Weak pointer to the associated RenderViewHost.
- RenderViewHost* render_view_host_;
-};
-
// Specifying a prototype so that we can add the WARN_UNUSED_RESULT attribute.
bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host,
const std::wstring& frame_xpath,
@@ -481,15 +446,6 @@ void NavigateToURLBlockUntilNavigationsComplete(Browser* browser,
BROWSER_TEST_WAIT_FOR_NAVIGATION);
}
-DOMElementProxyRef GetActiveDOMDocument(Browser* browser) {
- JavaScriptExecutionController* executor =
- new InProcessJavaScriptExecutionController(
- chrome::GetActiveWebContents(browser)->GetRenderViewHost());
- int element_handle;
- executor->ExecuteJavaScriptAndGetReturn("document;", &element_handle);
- return executor->GetObjectProxy<DOMElementProxy>(element_handle);
-}
-
bool ExecuteJavaScript(RenderViewHost* render_view_host,
const std::wstring& frame_xpath,
const std::wstring& original_script) {
diff --git a/chrome/test/base/ui_test_utils.h b/chrome/test/base/ui_test_utils.h
index 232997c..dbfaf46 100644
--- a/chrome/test/base/ui_test_utils.h
+++ b/chrome/test/base/ui_test_utils.h
@@ -16,7 +16,6 @@
#include "base/scoped_temp_dir.h"
#include "base/string16.h"
#include "chrome/browser/ui/view_ids.h"
-#include "chrome/test/automation/dom_element_proxy.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
@@ -146,10 +145,6 @@ void NavigateToURLBlockUntilNavigationsComplete(Browser* browser,
const GURL& url,
int number_of_navigations);
-// Gets the DOMDocument for the active tab in |browser|.
-// Returns a NULL reference on failure.
-DOMElementProxyRef GetActiveDOMDocument(Browser* browser);
-
// Executes the passed |script| in the frame pointed to by |frame_xpath| (use
// empty string for main frame). The |script| should not invoke
// domAutomationController.send(); otherwise, your test will hang or be flaky.
diff --git a/chrome/test/perf/tab_switching_test.cc b/chrome/test/perf/tab_switching_test.cc
index 76e2eca..92f3b11 100644
--- a/chrome/test/perf/tab_switching_test.cc
+++ b/chrome/test/perf/tab_switching_test.cc
@@ -8,6 +8,7 @@
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
+#include "base/stringprintf.h"
#include "base/threading/platform_thread.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
diff --git a/chrome/test/perf/url_fetch_test.cc b/chrome/test/perf/url_fetch_test.cc
index 8374b18..09ababf 100644
--- a/chrome/test/perf/url_fetch_test.cc
+++ b/chrome/test/perf/url_fetch_test.cc
@@ -8,6 +8,7 @@
#include "base/path_service.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
+#include "base/stringprintf.h"
#include "base/test/test_timeouts.h"
#include "base/utf_string_conversions.h"
#include "chrome/common/chrome_paths.h"
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
index 91da779..0f1f193 100644
--- a/chrome/test/pyautolib/pyautolib.cc
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/base_paths.h"
+#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/path_service.h"
diff --git a/chrome/test/reliability/automated_ui_tests.cc b/chrome/test/reliability/automated_ui_tests.cc
index 515b017..108d44a 100644
--- a/chrome/test/reliability/automated_ui_tests.cc
+++ b/chrome/test/reliability/automated_ui_tests.cc
@@ -18,6 +18,7 @@
#include "base/string_number_conversions.h"
#include "base/string_split.h"
#include "base/string_util.h"
+#include "base/stringprintf.h"
#include "base/threading/platform_thread.h"
#include "base/time.h"
#include "chrome/app/chrome_command_ids.h"
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index dabb5f0..9ee6ead 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -41,7 +41,6 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/automation/automation_proxy.h"
#include "chrome/test/automation/browser_proxy.h"
-#include "chrome/test/automation/javascript_execution_controller.h"
#include "chrome/test/automation/proxy_launcher.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/automation/window_proxy.h"
@@ -119,8 +118,6 @@ void UITestBase::SetUp() {
launcher_->AssertAppNotRunning("Please close any other instances "
"of the app before testing.");
- JavaScriptExecutionController::set_timeout(
- TestTimeouts::action_max_timeout());
test_start_time_ = Time::NowFromSystemTime();
SetLaunchSwitches();
diff --git a/chrome/test/webdriver/webdriver_element_id.cc b/chrome/test/webdriver/webdriver_element_id.cc
index db24d1d..410a6fa 100644
--- a/chrome/test/webdriver/webdriver_element_id.cc
+++ b/chrome/test/webdriver/webdriver_element_id.cc
@@ -5,7 +5,7 @@
#include "chrome/test/webdriver/webdriver_element_id.h"
#include "base/values.h"
-#include "chrome/test/automation/javascript_message_utils.h"
+#include "base/logging.h"
namespace {
diff --git a/content/test/layout_browsertest.cc b/content/test/layout_browsertest.cc
index b45477a..e00e6d2 100644
--- a/content/test/layout_browsertest.cc
+++ b/content/test/layout_browsertest.cc
@@ -60,11 +60,11 @@ bool ReadExpectedResult(const FilePath& result_dir_path,
}
void ScrapeResultFromBrowser(Browser* browser, std::string* actual_text) {
- DOMElementProxyRef doc = ui_test_utils::GetActiveDOMDocument(browser);
- DOMElementProxyRef body =
- doc->FindElement(DOMElementProxy::By::XPath("//body"));
- ASSERT_TRUE(body.get());
- ASSERT_TRUE(body->GetInnerText(actual_text));
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
+ chrome::GetActiveWebContents(browser)->GetRenderViewHost(),
+ L"",
+ L"window.domAutomationController.send(document.body.innerText);",
+ actual_text));
}
static const std::string preamble =