haikuwebkit/LayoutTests/platform/mac-bigsur-wk2
Devin Rousso 0d84a0f413 [Payment Request] `additionalShippingMethods` are not used if a `paymentMethodType` is provided
https://bugs.webkit.org/show_bug.cgi?id=228599
<rdar://problem/81190366>

Reviewed by Andy Estes.

Source/WebCore:

r275169 made it so that `paymentMethodType` is no longer `required` so that `additionalShippingMethods`
can be specified without having to limit it to a specific payment method type. While this
works in theory, WebKit doesn't know about the user's selected payment method type until the
user actually selects a payment method, meaning that until then the `additionalShippingMethods`
are not used. Unfortunately (until now) `PKPaymentRequestPaymentMethodUpdate` did not
support providing a `NSArray<PKShippingMethod *> *`, so there was no way to update the list
of shipping methods when the user changed their selected payment method, meaning that WebKit
would have to wait/rely on the user to change their shipping address _after_ selecting a
payment method in order for `additionalShippingMethods` to take effect.

This also fixes an issue with WebKit's implementation of the W3C Payment Request API by
allowing any generic (i.e. things not specific to Apple Pay) `shippingOptions` provided in
`PaymentDetailsUpdate` to actually be used and update the Apple Pay sheet accordingly.

Test: http/tests/paymentrequest/ApplePayModifier-paymentMethodType.https.html

* Modules/applepay/ApplePayModifier.idl:
* Modules/applepay/ApplePayModifier.h:
* Modules/applepay/ApplePayPaymentMethodUpdate.idl:
* Modules/applepay/ApplePayPaymentMethodUpdate.h:
(WebCore::ApplePayPaymentMethodUpdate::encode const):
(WebCore::ApplePayPaymentMethodUpdate::decode):
* Modules/applepay/ApplePayShippingMethodUpdate.idl:
* Modules/applepay/ApplePayShippingMethodUpdate.h:
(WebCore::ApplePayShippingMethodUpdate::encode const):
(WebCore::ApplePayShippingMethodUpdate::decode):
Add (or wrap existing) `additionalShippingMethods`/`newShippingMethods` properties.

* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::computeShippingMethods):
(WebCore::ApplePayPaymentHandler::detailsUpdated):
(WebCore::ApplePayPaymentHandler::shippingOptionUpdated):
(WebCore::ApplePayPaymentHandler::paymentMethodUpdated):
Also call `computeShippingMethods()` and add the result to the update.

* testing/MockPaymentCoordinator.cpp:
(WebCore::MockPaymentCoordinator::completeShippingMethodSelection):
(WebCore::MockPaymentCoordinator::completeShippingContactSelection):
(WebCore::MockPaymentCoordinator::completePaymentMethodSelection):
(WebCore::MockPaymentCoordinator::completeCouponCodeChange):
Support for testing.

Source/WebCore/PAL:

r275169 made it so that `paymentMethodType` is no longer `required` so that `additionalShippingMethods`
can be specified without having to limit it to a specific payment method type. While this
works in theory, WebKit doesn't know about the user's selected payment method type until the
user actually selects a payment method, meaning that until then the `additionalShippingMethods`
are not used. Unfortunately (until now) `PKPaymentRequestPaymentMethodUpdate` did not
support providing a `NSArray<PKShippingMethod *> *`, so there was no way to update the list
of shipping methods when the user changed their selected payment method, meaning that WebKit
would have to wait/rely on the user to change their shipping address _after_ selecting a
payment method in order for `additionalShippingMethods` to take effect.

This also fixes an issue with WebKit's implementation of the W3C Payment Request API by
allowing any generic (i.e. things not specific to Apple Pay) `shippingOptions` provided in
`PaymentDetailsUpdate` to actually be used and update the Apple Pay sheet accordingly.

* pal/spi/cocoa/PassKitSPI.h:
 - add the new `shippingMethods` property on `PKPaymentRequestUpdate`
 - add the existing `errors` property on `PKPaymentRequestPaymentMethodUpdate`

Source/WebKit:

r275169 made it so that `paymentMethodType` is no longer `required` so that `additionalShippingMethods`
can be specified without having to limit it to a specific payment method type. While this
works in theory, WebKit doesn't know about the user's selected payment method type until the
user actually selects a payment method, meaning that until then the `additionalShippingMethods`
are not used. Unfortunately (until now) `PKPaymentRequestPaymentMethodUpdate` did not
support providing a `NSArray<PKShippingMethod *> *`, so there was no way to update the list
of shipping methods when the user changed their selected payment method, meaning that WebKit
would have to wait/rely on the user to change their shipping address _after_ selecting a
payment method in order for `additionalShippingMethods` to take effect.

This also fixes an issue with WebKit's implementation of the W3C Payment Request API by
allowing any generic (i.e. things not specific to Apple Pay) `shippingOptions` provided in
`PaymentDetailsUpdate` to actually be used and update the Apple Pay sheet accordingly.

* Platform/cocoa/PaymentAuthorizationPresenter.mm:
(WebKit::PaymentAuthorizationPresenter::completePaymentMethodSelection):
(WebKit::PaymentAuthorizationPresenter::completeShippingMethodSelection):
Also convert and set the `shippingMethods` on the update.

Source/WTF:

r275169 made it so that `paymentMethodType` is no longer `required` so that `additionalShippingMethods`
can be specified without having to limit it to a specific payment method type. While this
works in theory, WebKit doesn't know about the user's selected payment method type until the
user actually selects a payment method, meaning that until then the `additionalShippingMethods`
are not used. Unfortunately (until now) `PKPaymentRequestPaymentMethodUpdate` did not
support providing a `NSArray<PKShippingMethod *> *`, so there was no way to update the list
of shipping methods when the user changed their selected payment method, meaning that WebKit
would have to wait/rely on the user to change their shipping address _after_ selecting a
payment method in order for `additionalShippingMethods` to take effect.

This also fixes an issue with WebKit's implementation of the W3C Payment Request API by
allowing any generic (i.e. things not specific to Apple Pay) `shippingOptions` provided in
`PaymentDetailsUpdate` to actually be used and update the Apple Pay sheet accordingly.

* wtf/PlatformHave.h:
* wtf/PlatformEnableCocoa.h:
Add new compile flags for PassKit supporting modifying shipping methods with any update.

LayoutTests:

* http/tests/paymentrequest/ApplePayModifier-paymentMethodType.https.html: Added.
* http/tests/paymentrequest/ApplePayModifier-paymentMethodType.https-expected.txt: Added.

* platform/ios-14-wk2/TestExpectations:
* platform/mac-bigsur-wk2/TestExpectations: Added.
Skip on older macOS/iOS since they don't support modifying shipping methods with any update.


Canonical link: https://commits.webkit.org/240094@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-30 00:28:45 +00:00
..
fast/events Migrate Monterey expectations to OpenSource and bump version numbers 2021-07-22 20:59:06 +00:00
http/tests Additional new baselines for Monterey 2021-07-27 18:00:44 +00:00
imported/w3c/web-platform-tests Migrate Monterey expectations to OpenSource and bump version numbers 2021-07-22 20:59:06 +00:00
TestExpectations [Payment Request] `additionalShippingMethods` are not used if a `paymentMethodType` is provided 2021-07-30 00:28:45 +00:00