Index: chrome/test/webdriver/webdriver_automation.cc |
diff --git a/chrome/test/webdriver/webdriver_automation.cc b/chrome/test/webdriver/webdriver_automation.cc |
index 72cb45f916828b1c6abc305eb514ee6df83242b8..579f5d49d1b7a9cc41e7d6203f340b5ea8885b72 100644 |
--- a/chrome/test/webdriver/webdriver_automation.cc |
+++ b/chrome/test/webdriver/webdriver_automation.cc |
@@ -306,19 +306,19 @@ void Automation::Terminate() { |
} |
} |
-void Automation::ExecuteScript(int tab_id, |
+void Automation::ExecuteScript(const WebViewId& view_id, |
const FramePath& frame_path, |
const std::string& script, |
std::string* result, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
Value* unscoped_value; |
std::string error_msg; |
- if (!SendExecuteJavascriptJSONRequest(automation(), windex, tab_index, |
+ if (!SendExecuteJavascriptJSONRequest(automation(), view_locator, |
frame_path.value(), script, |
&unscoped_value, &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
@@ -329,190 +329,190 @@ void Automation::ExecuteScript(int tab_id, |
*error = new Error(kUnknownError, "Execute script did not return string"); |
} |
-void Automation::MouseMove(int tab_id, |
+void Automation::MouseMove(const WebViewId& view_id, |
const Point& p, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseMoveJSONRequest( |
- automation(), windex, tab_index, p.rounded_x(), p.rounded_y(), |
+ automation(), view_locator, p.rounded_x(), p.rounded_y(), |
&error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseClick(int tab_id, |
+void Automation::MouseClick(const WebViewId& view_id, |
const Point& p, |
automation::MouseButton button, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseClickJSONRequest( |
- automation(), windex, tab_index, button, p.rounded_x(), |
+ automation(), view_locator, button, p.rounded_x(), |
p.rounded_y(), &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseDrag(int tab_id, |
+void Automation::MouseDrag(const WebViewId& view_id, |
const Point& start, |
const Point& end, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseDragJSONRequest( |
- automation(), windex, tab_index, start.rounded_x(), start.rounded_y(), |
+ automation(), view_locator, start.rounded_x(), start.rounded_y(), |
end.rounded_x(), end.rounded_y(), &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseButtonUp(int tab_id, |
+void Automation::MouseButtonUp(const WebViewId& view_id, |
const Point& p, |
Error** error) { |
*error = CheckAdvancedInteractionsSupported(); |
if (*error) |
return; |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseButtonUpJSONRequest( |
- automation(), windex, tab_index, p.rounded_x(), p.rounded_y(), |
+ automation(), view_locator, p.rounded_x(), p.rounded_y(), |
&error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseButtonDown(int tab_id, |
+void Automation::MouseButtonDown(const WebViewId& view_id, |
const Point& p, |
Error** error) { |
*error = CheckAdvancedInteractionsSupported(); |
if (*error) |
return; |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseButtonDownJSONRequest( |
- automation(), windex, tab_index, p.rounded_x(), p.rounded_y(), |
+ automation(), view_locator, p.rounded_x(), p.rounded_y(), |
&error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::MouseDoubleClick(int tab_id, |
+void Automation::MouseDoubleClick(const WebViewId& view_id, |
const Point& p, |
Error** error) { |
*error = CheckAdvancedInteractionsSupported(); |
if (*error) |
return; |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendMouseDoubleClickJSONRequest( |
- automation(), windex, tab_index, p.rounded_x(), p.rounded_y(), |
+ automation(), view_locator, p.rounded_x(), p.rounded_y(), |
&error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
void Automation::DragAndDropFilePaths( |
- int tab_id, const Point& location, |
+ const WebViewId& view_id, const Point& location, |
const std::vector<FilePath::StringType>& paths, Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) { |
return; |
} |
std::string error_msg; |
if (!SendDragAndDropFilePathsJSONRequest( |
- automation(), windex, tab_index, location.rounded_x(), |
+ automation(), view_locator, location.rounded_x(), |
location.rounded_y(), paths, &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::SendWebKeyEvent(int tab_id, |
+void Automation::SendWebKeyEvent(const WebViewId& view_id, |
const WebKeyEvent& key_event, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendWebKeyEventJSONRequest( |
- automation(), windex, tab_index, key_event, &error_msg)) { |
+ automation(), view_locator, key_event, &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::SendNativeKeyEvent(int tab_id, |
+void Automation::SendNativeKeyEvent(const WebViewId& view_id, |
ui::KeyboardCode key_code, |
int modifiers, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendNativeKeyEventJSONRequest( |
- automation(), windex, tab_index, key_code, modifiers, &error_msg)) { |
+ automation(), view_locator, key_code, modifiers, &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::CaptureEntirePageAsPNG(int tab_id, |
+void Automation::CaptureEntirePageAsPNG(const WebViewId& view_id, |
const FilePath& path, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendCaptureEntirePageJSONRequest( |
- automation(), windex, tab_index, path, &error_msg)) { |
+ automation(), view_locator, path, &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::NavigateToURL(int tab_id, |
+void Automation::NavigateToURL(const WebViewId& view_id, |
const std::string& url, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
AutomationMsg_NavigationResponseValues navigate_response; |
std::string error_msg; |
- if (!SendNavigateToURLJSONRequest(automation(), windex, tab_index, |
+ if (!SendNavigateToURLJSONRequest(automation(), view_locator, |
url, 1, &navigate_response, |
&error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
@@ -523,62 +523,73 @@ void Automation::NavigateToURL(int tab_id, |
*error = new Error(kUnknownError, "Navigation error occurred"); |
} |
-void Automation::NavigateToURLAsync(int tab_id, |
+void Automation::NavigateToURLAsync(const WebViewId& view_id, |
const std::string& url, |
Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
- scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(windex); |
- if (!browser) { |
- *error = new Error(kUnknownError, "Couldn't obtain browser proxy"); |
- return; |
- } |
- scoped_refptr<TabProxy> tab = browser->GetTab(tab_index); |
- if (!tab) { |
- *error = new Error(kUnknownError, "Couldn't obtain tab proxy"); |
- return; |
- } |
- if (!tab->NavigateToURLAsync(GURL(url))) { |
- *error = new Error(kUnknownError, "Unable to navigate to url"); |
- return; |
+ std::string error_msg; |
+ if (!view_id.old_style()) { |
+ AutomationMsg_NavigationResponseValues navigate_response; |
+ if (!SendNavigateToURLJSONRequest(automation(), view_locator, url, |
+ 0, &navigate_response, &error_msg)) { |
+ *error = new Error(kUnknownError, error_msg); |
+ return; |
+ } |
+ } else { |
+ scoped_refptr<BrowserProxy> browser = |
+ automation()->GetBrowserWindow(view_locator.browser_index()); |
+ if (!browser) { |
+ *error = new Error(kUnknownError, "Couldn't obtain browser proxy"); |
+ return; |
+ } |
+ scoped_refptr<TabProxy> tab = browser->GetTab(view_locator.tab_index()); |
+ if (!tab) { |
+ *error = new Error(kUnknownError, "Couldn't obtain tab proxy"); |
+ return; |
+ } |
+ if (!tab->NavigateToURLAsync(GURL(url))) { |
+ *error = new Error(kUnknownError, "Unable to navigate to url"); |
+ return; |
+ } |
} |
} |
-void Automation::GoForward(int tab_id, Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+void Automation::GoForward(const WebViewId& view_id, Error** error) { |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
if (!SendGoForwardJSONRequest( |
- automation(), windex, tab_index, &error_msg)) { |
+ automation(), view_locator, &error_msg)) { |
*error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::GoBack(int tab_id, Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+void Automation::GoBack(const WebViewId& view_id, Error** error) { |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
- if (!SendGoBackJSONRequest(automation(), windex, tab_index, &error_msg)) |
+ if (!SendGoBackJSONRequest(automation(), view_locator, &error_msg)) |
*error = new Error(kUnknownError, error_msg); |
} |
-void Automation::Reload(int tab_id, Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+void Automation::Reload(const WebViewId& view_id, Error** error) { |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
- if (!SendReloadJSONRequest(automation(), windex, tab_index, &error_msg)) |
+ if (!SendReloadJSONRequest(automation(), view_locator, &error_msg)) |
*error = new Error(kUnknownError, error_msg); |
} |
@@ -608,29 +619,45 @@ void Automation::SetCookie(const std::string& url, |
*error = new Error(kUnknownError, error_msg); |
} |
-void Automation::GetTabIds(std::vector<int>* tab_ids, |
- Error** error) { |
+void Automation::GetViews(std::vector<WebViewInfo>* views, |
+ Error** error) { |
+ bool has_views = false; |
+ *error = CompareVersion(963, 0, &has_views); |
+ if (*error) |
+ return; |
+ |
std::string error_msg; |
- if (!SendGetTabIdsJSONRequest(automation(), tab_ids, &error_msg)) |
- *error = new Error(kUnknownError, error_msg); |
+ if (has_views) { |
+ if (!SendGetWebViewsJSONRequest(automation(), views, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
+ } else { |
+ if (!SendGetTabIdsJSONRequest(automation(), views, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
+ } |
} |
-void Automation::DoesTabExist(int tab_id, bool* does_exist, Error** error) { |
+void Automation::DoesViewExist( |
+ const WebViewId& view_id, bool* does_exist, Error** error) { |
std::string error_msg; |
- if (!SendIsTabIdValidJSONRequest( |
- automation(), tab_id, does_exist, &error_msg)) { |
- *error = new Error(kUnknownError, error_msg); |
+ if (view_id.old_style()) { |
+ if (!SendIsTabIdValidJSONRequest( |
+ automation(), view_id, does_exist, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
+ } else { |
+ if (!SendDoesAutomationObjectExistJSONRequest( |
+ automation(), view_id, does_exist, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
} |
} |
-void Automation::CloseTab(int tab_id, Error** error) { |
- int windex = 0, tab_index = 0; |
- *error = GetIndicesForTab(tab_id, &windex, &tab_index); |
+void Automation::CloseView(const WebViewId& view_id, Error** error) { |
+ WebViewLocator view_locator; |
+ *error = ConvertViewIdToLocator(view_id, &view_locator); |
if (*error) |
return; |
std::string error_msg; |
- if (!SendCloseTabJSONRequest(automation(), windex, tab_index, &error_msg)) |
+ if (!SendCloseViewJSONRequest(automation(), view_locator, &error_msg)) |
*error = new Error(kUnknownError, error_msg); |
} |
@@ -681,9 +708,9 @@ void Automation::GetChromeDriverAutomationVersion(int* version, Error** error) { |
*error = new Error(kUnknownError, error_msg); |
} |
-void Automation::WaitForAllTabsToStopLoading(Error** error) { |
+void Automation::WaitForAllViewsToStopLoading(Error** error) { |
std::string error_msg; |
- if (!SendWaitForAllTabsToStopLoadingJSONRequest(automation(), &error_msg)) |
+ if (!SendWaitForAllViewsToStopLoadingJSONRequest(automation(), &error_msg)) |
*error = new Error(kUnknownError, error_msg); |
} |
@@ -693,53 +720,80 @@ void Automation::InstallExtensionDeprecated( |
*error = new Error(kUnknownError, "Failed to install extension"); |
} |
-void Automation::GetInstalledExtensions( |
- std::vector<std::string>* extension_ids, Error** error) { |
+void Automation::InstallExtension( |
+ const FilePath& path, std::string* extension_id, Error** error) { |
+ *error = CheckNewExtensionInterfaceSupported(); |
+ if (*error) |
+ return; |
+ |
+ std::string error_msg; |
+ if (!SendInstallExtensionJSONRequest( |
+ automation(), path, false /* with_ui */, extension_id, |
+ &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
+} |
+ |
+void Automation::GetExtensionsInfo( |
+ base::ListValue* extensions_list, Error** error) { |
*error = CheckNewExtensionInterfaceSupported(); |
if (*error) |
return; |
std::string error_msg; |
- base::ListValue extensions_list; |
if (!SendGetExtensionsInfoJSONRequest( |
- automation(), &extensions_list, &error_msg)) { |
+ automation(), extensions_list, &error_msg)) |
*error = new Error(kUnknownError, error_msg); |
+} |
+ |
+void Automation::IsPageActionVisible( |
+ const WebViewId& tab_id, |
+ const std::string& extension_id, |
+ bool* is_visible, |
+ Error** error) { |
+ *error = CheckNewExtensionInterfaceSupported(); |
+ if (*error) |
return; |
- } |
- for (size_t i = 0; i < extensions_list.GetSize(); i++) { |
- DictionaryValue* extension_dict; |
- if (!extensions_list.GetDictionary(i, &extension_dict)) { |
- *error = new Error(kUnknownError, "Invalid extension dictionary"); |
- return; |
- } |
- bool is_component; |
- if (!extension_dict->GetBoolean("is_component", &is_component)) { |
- *error = new Error(kUnknownError, |
- "Missing or invalid 'is_component_extension'"); |
- return; |
- } |
- if (is_component) |
- continue; |
+ std::string error_msg; |
+ if (!SendIsPageActionVisibleJSONRequest( |
+ automation(), tab_id, extension_id, is_visible, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
+} |
- std::string extension_id; |
- if (!extension_dict->GetString("id", &extension_id)) { |
- *error = new Error(kUnknownError, "Missing or invalid 'id'"); |
- return; |
- } |
- extension_ids->push_back(extension_id); |
- } |
+void Automation::SetExtensionState( |
+ const std::string& extension_id, |
+ bool enable, |
+ Error** error) { |
+ *error = CheckNewExtensionInterfaceSupported(); |
+ if (*error) |
+ return; |
+ |
+ std::string error_msg; |
+ if (!SendSetExtensionStateJSONRequest( |
+ automation(), extension_id, enable /* enable */, |
+ false /* allow_in_incognito */, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
} |
-void Automation::InstallExtension( |
- const FilePath& path, std::string* extension_id, Error** error) { |
+void Automation::ClickExtensionButton( |
+ const std::string& extension_id, |
+ bool browser_action, |
+ Error** error) { |
+ std::string error_msg; |
+ if (!SendClickExtensionButtonJSONRequest( |
+ automation(), extension_id, browser_action, &error_msg)) |
+ *error = new Error(kUnknownError, error_msg); |
+} |
+ |
+void Automation::UninstallExtension( |
+ const std::string& extension_id, Error** error) { |
*error = CheckNewExtensionInterfaceSupported(); |
if (*error) |
return; |
std::string error_msg; |
- if (!SendInstallExtensionJSONRequest( |
- automation(), path, false /* with_ui */, extension_id, &error_msg)) |
+ if (!SendUninstallExtensionJSONRequest( |
+ automation(), extension_id, &error_msg)) |
*error = new Error(kUnknownError, error_msg); |
} |
@@ -747,12 +801,18 @@ AutomationProxy* Automation::automation() const { |
return launcher_->automation(); |
} |
-Error* Automation::GetIndicesForTab( |
- int tab_id, int* browser_index, int* tab_index) { |
- std::string error_msg; |
- if (!SendGetIndicesFromTabIdJSONRequest( |
- automation(), tab_id, browser_index, tab_index, &error_msg)) { |
- return new Error(kUnknownError, error_msg); |
+Error* Automation::ConvertViewIdToLocator( |
+ const WebViewId& view_id, WebViewLocator* view_locator) { |
+ if (view_id.old_style()) { |
+ int browser_index, tab_index; |
+ std::string error_msg; |
+ if (!SendGetIndicesFromTabIdJSONRequest( |
+ automation(), view_id.tab_id(), &browser_index, &tab_index, |
+ &error_msg)) |
+ return new Error(kUnknownError, error_msg); |
+ *view_locator = WebViewLocator::ForIndexPair(browser_index, tab_index); |
+ } else { |
+ *view_locator = WebViewLocator::ForViewId(view_id.GetId()); |
} |
return NULL; |
} |