Commit f3906091 authored by sandromaggi's avatar sandromaggi Committed by Commit Bot

[Autofill Assistant] Send failing step

This CL adds reporting for which web-action failed. This
is useful for actions that execute in multiple steps, e.g.
|ClickAction|:

* WaitForDocumentToBecomeInteractive
* ScrollIntoView
* ClickOrTap

Bug: b/169924567
Change-Id: I644178737fc21039767670ffcb5853d794ab754b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2475115
Commit-Queue: Sandro Maggi <sandromaggi@google.com>
Reviewed-by: default avatarStephane Zermatten <szermatt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818373}
parent 7501f245
...@@ -108,6 +108,36 @@ TEST_F(ActionDelegateUtilTest, FindElementAndExecuteMultipleActions) { ...@@ -108,6 +108,36 @@ TEST_F(ActionDelegateUtilTest, FindElementAndExecuteMultipleActions) {
base::Unretained(this))); base::Unretained(this)));
} }
TEST_F(ActionDelegateUtilTest,
FindElementAndExecuteMultipleActionsAbortsOnError) {
InSequence sequence;
Selector expected_selector({"#element"});
auto expected_element =
test_util::MockFindElement(mock_action_delegate_, expected_selector);
EXPECT_CALL(*this, MockIndexedAction(1, EqualsElement(expected_element), _))
.WillOnce(RunOnceCallback<2>(OkClientStatus()));
EXPECT_CALL(*this, MockIndexedAction(2, EqualsElement(expected_element), _))
.WillOnce(RunOnceCallback<2>(ClientStatus(UNEXPECTED_JS_ERROR)));
EXPECT_CALL(*this, MockIndexedAction(3, EqualsElement(expected_element), _))
.Times(0);
EXPECT_CALL(*this, MockDone(EqualsStatus(ClientStatus(UNEXPECTED_JS_ERROR))));
auto actions = std::make_unique<ElementActionVector>();
actions->emplace_back(base::BindOnce(
&ActionDelegateUtilTest::MockIndexedAction, base::Unretained(this), 1));
actions->emplace_back(base::BindOnce(
&ActionDelegateUtilTest::MockIndexedAction, base::Unretained(this), 2));
actions->emplace_back(base::BindOnce(
&ActionDelegateUtilTest::MockIndexedAction, base::Unretained(this), 3));
FindElementAndPerformAll(&mock_action_delegate_, expected_selector,
std::move(actions),
base::BindOnce(&ActionDelegateUtilTest::MockDone,
base::Unretained(this)));
}
TEST_F(ActionDelegateUtilTest, ActionDelegateDeletedDuringExecution) { TEST_F(ActionDelegateUtilTest, ActionDelegateDeletedDuringExecution) {
InSequence sequence; InSequence sequence;
......
...@@ -650,6 +650,9 @@ message ProcessedActionStatusDetailsProto { ...@@ -650,6 +650,9 @@ message ProcessedActionStatusDetailsProto {
// More information included for |SetFormFieldValueProto| related errors. // More information included for |SetFormFieldValueProto| related errors.
optional SetFormFieldErrorInfoProto form_field_error_info = 4; optional SetFormFieldErrorInfoProto form_field_error_info = 4;
// Additional information from the |WebController|.
optional WebControllerErrorInfoProto web_controller_error_info = 5;
} }
message NavigationInfoProto { message NavigationInfoProto {
...@@ -761,6 +764,63 @@ message SetFormFieldErrorInfoProto { ...@@ -761,6 +764,63 @@ message SetFormFieldErrorInfoProto {
optional int32 invalid_keypress_index = 1; optional int32 invalid_keypress_index = 1;
} }
// Message to report errors related to WebController execution.
message WebControllerErrorInfoProto {
enum WebAction {
UNSPECIFIED_WEB_ACTION = 0;
// Scroll an element into view by centering it on the page. This uses
// native JS functionality.
SCROLL_INTO_VIEW = 1;
// Waiting for the document ready state to be interactive.
WAIT_FOR_DOCUMENT_TO_BECOME_INTERACTIVE = 2;
// Send a click or tap event to an element.
CLICK_OR_TAP_ELEMENT = 3;
// Select an option from an HTML dropdown.
SELECT_OPTION = 4;
// Set the element's style to be highlighted by adding a BoxShadow to the
// element.
HIGHLIGHT_ELEMENT = 5;
// Scroll the element into view with padding. This does not use native JS
// functionality but calculates the scrolling manually.
SCROLL_INTO_VIEW_WITH_PADDING = 6;
// Get the |value| attribute of an element.
GET_FIELD_VALUE = 7;
// Get any attribute of an element.
GET_STRING_ATTRIBUTE = 8;
// Select an element's value. This does only work for text elements.
SELECT_FIELD_VALUE = 9;
// Set the |value| attribute of an element.
SET_VALUE_ATTRIBUTE = 10;
// Set any attribute of an element.
SET_ATTRIBUTE = 11;
// Send a series of keystroke inputs. This requires an element to have
// focus to receive them.
SEND_KEYBOARD_INPUT = 12;
// Get the outer HTML of an element.
GET_OUTER_HTML = 13;
// Get the tag of an element.
GET_ELEMENT_TAG = 14;
}
// The web-action that failed. This is usually a step in an execution chain
// for an action.
optional WebAction failed_web_action = 1;
}
// The pseudo type values come from // The pseudo type values come from
// https://chromedevtools.github.io/devtools-protocol/tot/DOM#type-PseudoType. // https://chromedevtools.github.io/devtools-protocol/tot/DOM#type-PseudoType.
enum PseudoType { enum PseudoType {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "components/autofill_assistant/browser/web/web_controller_util.h" #include "components/autofill_assistant/browser/web/web_controller_util.h"
#include "components/autofill_assistant/browser/devtools/devtools/domains/types_runtime.h" #include "components/autofill_assistant/browser/devtools/devtools/domains/types_runtime.h"
#include "components/autofill_assistant/browser/service.pb.h"
namespace autofill_assistant { namespace autofill_assistant {
...@@ -56,6 +57,14 @@ ClientStatus FillAutofillErrorStatus(ClientStatus status) { ...@@ -56,6 +57,14 @@ ClientStatus FillAutofillErrorStatus(ClientStatus status) {
return status; return status;
} }
void FillWebControllerErrorInfo(
WebControllerErrorInfoProto::WebAction failed_web_action,
ClientStatus* status) {
status->mutable_details()
->mutable_web_controller_error_info()
->set_failed_web_action(failed_web_action);
}
bool SafeGetObjectId(const runtime::RemoteObject* result, std::string* out) { bool SafeGetObjectId(const runtime::RemoteObject* result, std::string* out) {
if (result && result->HasObjectId()) { if (result && result->HasObjectId()) {
*out = result->GetObjectId(); *out = result->GetObjectId();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "components/autofill_assistant/browser/client_status.h" #include "components/autofill_assistant/browser/client_status.h"
#include "components/autofill_assistant/browser/devtools/devtools/domains/types_runtime.h" #include "components/autofill_assistant/browser/devtools/devtools/domains/types_runtime.h"
#include "components/autofill_assistant/browser/devtools/devtools_client.h" #include "components/autofill_assistant/browser/devtools/devtools_client.h"
#include "components/autofill_assistant/browser/service.pb.h"
namespace autofill_assistant { namespace autofill_assistant {
...@@ -57,6 +58,11 @@ ClientStatus CheckJavaScriptResult( ...@@ -57,6 +58,11 @@ ClientStatus CheckJavaScriptResult(
// Fills a ClientStatus with appropriate details for a Chrome Autofill error. // Fills a ClientStatus with appropriate details for a Chrome Autofill error.
ClientStatus FillAutofillErrorStatus(ClientStatus status); ClientStatus FillAutofillErrorStatus(ClientStatus status);
// Fills a ClientStatus with appropriate details from the
void FillWebControllerErrorInfo(
WebControllerErrorInfoProto::WebAction failed_web_action,
ClientStatus* status);
// Safely gets an object id from a RemoteObject // Safely gets an object id from a RemoteObject
bool SafeGetObjectId(const runtime::RemoteObject* result, std::string* out); bool SafeGetObjectId(const runtime::RemoteObject* result, std::string* out);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment