Bug 189938 - [Apple Pay] Support granular errors in PaymentDetailsUpdate
Summary: [Apple Pay] Support granular errors in PaymentDetailsUpdate
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andy Estes
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-09-24 17:12 PDT by Andy Estes
Modified: 2018-10-18 11:06 PDT (History)
15 users (show)

See Also:


Attachments
Patch (42.91 KB, patch)
2018-09-24 17:13 PDT, Andy Estes
no flags Details | Formatted Diff | Diff
Patch (68.68 KB, patch)
2018-09-26 13:55 PDT, Andy Estes
no flags Details | Formatted Diff | Diff
Patch (68.73 KB, patch)
2018-09-26 14:39 PDT, Andy Estes
no flags Details | Formatted Diff | Diff
Patch (68.39 KB, patch)
2018-09-27 09:26 PDT, Andy Estes
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Estes 2018-09-24 17:12:04 PDT
[Apple Pay] Support granular errors in PaymentDetailsUpdate
Comment 1 Andy Estes 2018-09-24 17:13:12 PDT Comment hidden (obsolete)
Comment 2 Andy Estes 2018-09-26 13:55:56 PDT Comment hidden (obsolete)
Comment 3 Andy Estes 2018-09-26 14:39:41 PDT
Created attachment 350903 [details]
Patch
Comment 4 youenn fablet 2018-09-27 09:01:21 PDT
Comment on attachment 350903 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=350903&action=review

> Source/WebCore/Modules/applepay/ApplePayErrorCode.h:2
> + * Copyright (C) 2017-2018 Apple Inc. All rights reserved.

2018?

> Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:315
> +static inline void appendShippingContactInvalidError(String&& message, std::optional<PaymentError::ContactField>&& contactField, Vector<PaymentError>& errors)

If ContactField is an enum, I believe we go with std::optional<> without &&.

> Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:321
> +Vector<PaymentError> ApplePayPaymentHandler::computeErrors(String&& error, AddressErrors&& addressErrors, PayerErrorFields&& payerErrors, JSC::Strong<JSC::JSObject>&& paymentMethodErrors) const

Does paymentMethodErrors need to be a JSC::Strong, can we make it a JSC::JSObject& instead?

> Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:357
> +                    errors.append({ applePayError->code(), applePayError->message(), applePayError->contactField() });

We can probably move applePayError->message()
Comment 5 Andy Estes 2018-09-27 09:15:19 PDT
(In reply to youenn fablet from comment #4)
> Comment on attachment 350903 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=350903&action=review
> 
> > Source/WebCore/Modules/applepay/ApplePayErrorCode.h:2
> > + * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
> 
> 2018?

Yeah I'll remove this.

> 
> > Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:315
> > +static inline void appendShippingContactInvalidError(String&& message, std::optional<PaymentError::ContactField>&& contactField, Vector<PaymentError>& errors)
> 
> If ContactField is an enum, I believe we go with std::optional<> without &&.

Ok.

> 
> > Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:321
> > +Vector<PaymentError> ApplePayPaymentHandler::computeErrors(String&& error, AddressErrors&& addressErrors, PayerErrorFields&& payerErrors, JSC::Strong<JSC::JSObject>&& paymentMethodErrors) const
> 
> Does paymentMethodErrors need to be a JSC::Strong, can we make it a
> JSC::JSObject& instead?

We can make it a JSC::JSObject*. It might be null.

> 
> > Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:357
> > +                    errors.append({ applePayError->code(), applePayError->message(), applePayError->contactField() });
> 
> We can probably move applePayError->message()

Yes.

Thanks for reviewing!
Comment 6 Andy Estes 2018-09-27 09:23:07 PDT
(In reply to Andy Estes from comment #5)
> (In reply to youenn fablet from comment #4)
> > Comment on attachment 350903 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=350903&action=review
> > 
> > > Source/WebCore/Modules/applepay/ApplePayErrorCode.h:2
> > > + * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
> > 
> > 2018?
> 
> Yeah I'll remove this.
> 
> > 
> > > Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:315
> > > +static inline void appendShippingContactInvalidError(String&& message, std::optional<PaymentError::ContactField>&& contactField, Vector<PaymentError>& errors)
> > 
> > If ContactField is an enum, I believe we go with std::optional<> without &&.
> 
> Ok.
> 
> > 
> > > Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:321
> > > +Vector<PaymentError> ApplePayPaymentHandler::computeErrors(String&& error, AddressErrors&& addressErrors, PayerErrorFields&& payerErrors, JSC::Strong<JSC::JSObject>&& paymentMethodErrors) const
> > 
> > Does paymentMethodErrors need to be a JSC::Strong, can we make it a
> > JSC::JSObject& instead?
> 
> We can make it a JSC::JSObject*. It might be null.
> 
> > 
> > > Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:357
> > > +                    errors.append({ applePayError->code(), applePayError->message(), applePayError->contactField() });
> > 
> > We can probably move applePayError->message()
> 
> Yes.

Actually we don't need to move, because since message() returns a temporary the compiler will elide the copy.
Comment 7 Andy Estes 2018-09-27 09:26:26 PDT
Created attachment 350969 [details]
Patch
Comment 8 WebKit Commit Bot 2018-09-27 09:44:56 PDT
Comment on attachment 350969 [details]
Patch

Clearing flags on attachment: 350969

Committed r236552: <https://trac.webkit.org/changeset/236552>
Comment 9 WebKit Commit Bot 2018-09-27 09:44:58 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2018-09-27 09:45:25 PDT
<rdar://problem/44833449>
Comment 11 Truitt Savell 2018-10-08 08:39:54 PDT
The new test: 
http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html

added in:
https://trac.webkit.org/changeset/236552/webkit

is flakey failure.

History:
https://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.html#showAllRuns=true&tests=http%2Ftests%2Fssl%2Fapplepay%2FApplePayShippingAddressChangeEventErrorsV3.https.html

Diff:
--- /Volumes/Data/slave/highsierra-debug-tests-wk2/build/layout-test-results/http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https-expected.txt
+++ /Volumes/Data/slave/highsierra-debug-tests-wk2/build/layout-test-results/http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https-actual.txt
@@ -1,3 +1,4 @@
+CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state.
 Test specifying Apple Pay errors in response to the shippingaddresschange event.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Comment 12 Andy Estes 2018-10-18 11:06:17 PDT
(In reply to Truitt Savell from comment #11)
> The new test: 
> http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html
> 
> added in:
> https://trac.webkit.org/changeset/236552/webkit
> 
> is flakey failure.
> 
> History:
> https://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.
> html#showAllRuns=true&tests=http%2Ftests%2Fssl%2Fapplepay%2FApplePayShippingA
> ddressChangeEventErrorsV3.https.html
> 
> Diff:
> ---
> /Volumes/Data/slave/highsierra-debug-tests-wk2/build/layout-test-results/
> http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https-
> expected.txt
> +++
> /Volumes/Data/slave/highsierra-debug-tests-wk2/build/layout-test-results/
> http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https-
> actual.txt
> @@ -1,3 +1,4 @@
> +CONSOLE MESSAGE: Unhandled Promise Rejection: InvalidStateError: The object
> is in an invalid state.
>  Test specifying Apple Pay errors in response to the shippingaddresschange
> event.
>  
>  On success, you will see a series of "PASS" messages, followed by "TEST
> COMPLETE".

Tracked by bug #190650.