Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider specifying a testing IDL for a mock payment UI #799

Open
aestes opened this issue Oct 24, 2018 · 7 comments
Open

Consider specifying a testing IDL for a mock payment UI #799

aestes opened this issue Oct 24, 2018 · 7 comments

Comments

@aestes
Copy link
Collaborator

aestes commented Oct 24, 2018

WebKit has converted some of the manual payment-request tests into automated tests by creating a mock payment UI in our testing harness that can be scripted from the test. Here's what the IDL looks like right now:

interface MockPaymentCoordinator {
    void setShippingAddress(MockPaymentAddress shippingAddress);
    void changeShippingOption(DOMString shippingOption);
    void changePaymentMethod(ApplePayPaymentMethod paymentMethod);
    void acceptPayment();
    void cancelPayment();

    readonly attribute ApplePayLineItem total;
    readonly attribute sequence<ApplePayLineItem> lineItems;
    readonly attribute sequence<MockPaymentError> errors;
};

This is specific to Apple Pay right now, and is missing some stuff, so obviously this wouldn't be used as-is.

But maybe we could specify something like this so that (a) the WebKit-specific tests could be upstreamed to WPT, and (b) other browsers could run them.

@ianbjacobs
Copy link
Collaborator

cc @sideshowbarker

@aestes
Copy link
Collaborator Author

aestes commented Oct 24, 2018

@ianbjacobs
Copy link
Collaborator

Hi @aestes,

Did you get the answer to your original question? Are you able to share Webkit tests in the Payment Request test suite?

Ian

@rsolomakhin
Copy link
Collaborator

I support this.

@danyao
Copy link
Collaborator

danyao commented Feb 4, 2019

I started looking at how we might implement such a test API in Chrome. The main thing I'd like is a way for tests to inject a payment instrument (e.g. credit card or payment app). We currently have some test hooks that can directly manipulate the database in the browser process [1]. To make this available to WPT, we'd need to expose corresponding JavaScript bindings. This raises two issues:

  1. Increase in binary size. Is it worth it for a test-only API?
  2. Website abusing the test API to confuse user (e.g. injecting a bogus payment instrument that makes it looks like to user that their browser is hijacked), even if they cannot directly steal money from user's existing payment types.

What do other vendors think about these?

As a data point, the Chrome Web Bluetooth folks ran into similar issues [2] and decided to put the test API behind a compile flag, so it's only available for content_shell. The downside was that the tests can't be run using the regular web platform test scripts.

[1] https://cs.chromium.org/chromium/src/chrome/browser/ui/views/payments/payment_request_browsertest_base.h?l=181
[2] https://docs.google.com/document/d/1Nhv_oVDCodd1pEH_jj9k8gF4rPGb_84VYaZ9IG8M_WY/edit#heading=h.ydr456a07ivp

@marcoscaceres
Copy link
Member

Related discussion w3c/payment-method-basic-card#41

@foolip
Copy link
Member

foolip commented Feb 12, 2019

@danyao can you describe the minimal required API to make this work? Would it suffice to just instruct the browser to provide mock UI-free payment methods? Would there have to be a callback to the test code when the payment instrument has been used, or could tests just try to make a payment and then look at the result?

I think there are similarities with web-platform-tests/wpt#12046, and possibly something simple like https://w3c.github.io/permissions/#automation could suffice.

This would also allow web developers to test their code, although I don't know if that's a real ask or if they'd just mock out the entire API instead.

CC @LukeZielinski

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants