Skip to content

Commit

Permalink
[SPC] Add support for SPC set-mode to ChromeDriver
Browse files Browse the repository at this point in the history
See:
  - w3c/secure-payment-confirmation#151
  - web-platform-tests/rfcs#101

Bug: 1241090
Change-Id: Ic809485d91c11b6cc70e80e17eee88290a0e90f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3251001
Reviewed-by: Rouslan Solomakhin <[email protected]>
Reviewed-by: Mathias Bynens <[email protected]>
Commit-Queue: Stephen McGruer <[email protected]>
Cr-Commit-Position: refs/heads/main@{#938409}
  • Loading branch information
stephenmcgruer authored and Chromium LUCI CQ committed Nov 4, 2021
1 parent a8be756 commit 33bfda0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client/chromedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,10 @@ def SetUserVerified(self, authenticatorId, isUserVerified):
'isUserVerified': isUserVerified}
return self.ExecuteCommand(Command.SET_USER_VERIFIED, params)

def SetSPCTransactionMode(self, mode):
params = {'mode': mode}
return self.ExecuteCommand(Command.SET_SPC_TRANSACTION_MODE, params)

def GetSessionId(self):
if not hasattr(self, '_session_id'):
return None
Expand Down
3 changes: 3 additions & 0 deletions client/command_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ class Command(object):
SET_USER_VERIFIED = (
_Method.POST,
'/session/:sessionId/webauthn/authenticator/:authenticatorId/uv')
SET_SPC_TRANSACTION_MODE = (
_Method.POST,
'/session/:sessionId/secure-payment-confirmation/set-mode')
SET_PERMISSION = (
_Method.POST, '/session/:sessionId/permissions')

Expand Down
7 changes: 7 additions & 0 deletions server/http_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,13 @@ HttpHandler::HttpHandler(
&ExecuteWebAuthnCommand,
base::BindRepeating(&ExecuteSetUserVerified)))),

// Extensions for Secure Payment Confirmation API:
// https://w3c.github.io/secure-payment-confirmation/#sctn-automation
CommandMapping(
kPost, "session/:sessionId/secure-payment-confirmation/set-mode",
WrapToCommand("SetSPCTransactionMode",
base::BindRepeating(&ExecuteSetSPCTransactionMode))),

// Extension for Permissions Standard Automation "set permission" command:
// https://w3c.github.io/permissions/#set-permission-command
CommandMapping(kPost, "session/:sessionId/permissions",
Expand Down
20 changes: 20 additions & 0 deletions session_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,26 @@ Status ExecuteUnimplementedCommand(Session* session,
return Status(kUnknownCommand);
}

Status ExecuteSetSPCTransactionMode(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value) {
WebView* web_view = nullptr;
Status status = session->GetTargetWindow(&web_view);
if (status.IsError())
return status;

const std::string* mode = params.FindStringKey("mode");
if (!mode)
return Status(kInvalidArgument, "missing parameter 'mode'");

base::Value body(base::Value::Type::DICTIONARY);
body.SetStringKey("mode", *mode);

return web_view->SendCommandAndGetResult("Page.setSPCTransactionMode",
base::Value::AsDictionaryValue(body),
value);
}

Status ExecuteGenerateTestReport(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value) {
Expand Down
4 changes: 4 additions & 0 deletions session_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ Status ExecuteUnimplementedCommand(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value);

Status ExecuteSetSPCTransactionMode(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value);

Status ExecuteGenerateTestReport(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value);
Expand Down

0 comments on commit 33bfda0

Please sign in to comment.