Bug 220810 - [Apple Pay] use the first item in `shippingOptions` even when it's not `selected`
Summary: [Apple Pay] use the first item in `shippingOptions` even when it's not `selec...
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: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-01-21 10:42 PST by Devin Rousso
Modified: 2021-01-21 19:51 PST (History)
11 users (show)

See Also:


Attachments
Patch (10.34 KB, patch)
2021-01-21 12:53 PST, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (27.94 KB, patch)
2021-01-21 16:42 PST, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2021-01-21 10:42:09 PST
This matches what PassKit does with `PKShippingMethod`.
Comment 1 Devin Rousso 2021-01-21 12:53:02 PST
Created attachment 418072 [details]
Patch
Comment 2 Andy Estes 2021-01-21 13:55:02 PST
Comment on attachment 418072 [details]
Patch

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

> LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https.html:102
> +    // assert_equals(request.shippingOption, detailsUpdate.shippingOptions.find((shippingOption) => shippingOption.selected).id, "selected shipping option should change");

My preference would be to let this assertion fail and update the test expectation (rather than commenting it out).
Comment 3 Andy Estes 2021-01-21 13:58:09 PST
Do you think we should log to the console when a merchant sets `selected` to true on something other than the first shipping option, letting them know that the selection won't be honored in the Apple Pay UI?
Comment 4 Devin Rousso 2021-01-21 14:09:57 PST
Comment on attachment 418072 [details]
Patch

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

(In reply to Andy Estes from comment #3)
> Do you think we should log to the console when a merchant sets `selected` to true on something other than the first shipping option, letting them know that the selection won't be honored in the Apple Pay UI?
Good idea!

>> LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https.html:102
>> +    // assert_equals(request.shippingOption, detailsUpdate.shippingOptions.find((shippingOption) => shippingOption.selected).id, "selected shipping option should change");
> 
> My preference would be to let this assertion fail and update the test expectation (rather than commenting it out).

I would agree, but AFAIK `assert_equals` actually throws an error, meaning that any `assert_equals` after it won't execute.  Do you know of any ways to deal with this (e.g. have each test log instead of silent-pass-and-throw-on-failure)?
Comment 5 Andy Estes 2021-01-21 14:30:07 PST
Comment on attachment 418072 [details]
Patch

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

>>> LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https.html:102
>>> +    // assert_equals(request.shippingOption, detailsUpdate.shippingOptions.find((shippingOption) => shippingOption.selected).id, "selected shipping option should change");
>> 
>> My preference would be to let this assertion fail and update the test expectation (rather than commenting it out).
> 
> I would agree, but AFAIK `assert_equals` actually throws an error, meaning that any `assert_equals` after it won't execute.  Do you know of any ways to deal with this (e.g. have each test log instead of silent-pass-and-throw-on-failure)?

Good point. You could move this assert into a new `user_activation_test` to isolate it from the others.
Comment 6 Devin Rousso 2021-01-21 16:42:39 PST
Created attachment 418098 [details]
Patch
Comment 7 EWS Watchlist 2021-01-21 16:43:32 PST
This patch modifies the inspector protocol. Please ensure that any frontend changes appropriately use feature checks for new protocol features.
Comment 8 EWS 2021-01-21 19:50:40 PST
Committed r271735: <https://trac.webkit.org/changeset/271735>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 418098 [details].
Comment 9 Radar WebKit Bug Importer 2021-01-21 19:51:14 PST
<rdar://problem/73481254>