-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
supportedCountries only works on ApplePaySession, not PaymentRequest …
…(affects Shopify) https://bugs.webkit.org/show_bug.cgi?id=259940 rdar://113557607 Reviewed by Alex Christensen. The `supportedCountries` property only seems to be reflected in a payment request when it is set in an ApplePayJS request, and not the W3C Payment Request API. This is because we end up calling `WebCore::convertAndValidate()` multiple times for `ApplePayRequestBase` in the Payment Request flow, which means we end up `WTFMove`-ing the `supportedCountries` vector on the first call and said vector is empty on subsequent entries into the function, so we ultimately set it to an empty vector. The multiple calls to `WebCore::convertAndValidate()` is an architectural issue that we should address (https://bugs.webkit.org/show_bug.cgi?id=260050), but in the meantime we opt to fix the issue by copying the `supportedCountries` vector before moving it at the `setSupportedCountries()` callsite in `WebCore::convertAndValidate()`. We also modify `WebCore::convertAndValidate()`'s signature to expect a const L-value reference to `ApplePayRequestBase` instead, which should mitigate against accidental data corruption. This patch also introduces a layout test (and some associated Internals plumbing) that improves our test coverage for the `supportedCountries` attribute in payment requests. * LayoutTests/http/tests/paymentrequest/paymentrequest-supportedCountries.https-expected.txt: Added. * LayoutTests/http/tests/paymentrequest/paymentrequest-supportedCountries.https.html: Added. * LayoutTests/http/tests/resources/payment-request.js: (async validPaymentMethod): * Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp: (WebCore::convertAndValidate): * Source/WebCore/Modules/applepay/ApplePayRequestBase.h: * Source/WebCore/testing/MockPaymentCoordinator.cpp: (WebCore::MockPaymentCoordinator::showPaymentUI): * Source/WebCore/testing/MockPaymentCoordinator.h: * Source/WebCore/testing/MockPaymentCoordinator.idl: Canonical link: https://commits.webkit.org/266829@main
- Loading branch information
Showing
8 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
LayoutTests/http/tests/paymentrequest/paymentrequest-supportedCountries.https-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
PASS Should not have a default value for `supportedCountries`. | ||
PASS Should propagate `supportedCountries` if provided. | ||
|
51 changes: 51 additions & 0 deletions
51
LayoutTests/http/tests/paymentrequest/paymentrequest-supportedCountries.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Tests for providing `supportedCountries` in `data` as part of `PaymentMethodData`.</title> | ||
<script src="/js-test-resources/ui-helper.js"></script> | ||
<script src="/resources/payment-request.js"></script> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<body> | ||
<script> | ||
setup({ explicit_done: true, explicit_timeout: true }); | ||
|
||
user_activation_test(async (test) => { | ||
let request = new PaymentRequest([validPaymentMethod()], validPaymentDetails()); | ||
request.addEventListener("merchantvalidation", (event) => { | ||
event.complete({ }); | ||
}); | ||
request.addEventListener("shippingaddresschange", (event) => { | ||
assert_array_equals(internals.mockPaymentCoordinator.supportedCountries, [], "check that `supportedCountries` is still empty after an update"); | ||
event.updateWith({ }); | ||
internals.mockPaymentCoordinator.acceptPayment(); | ||
}); | ||
|
||
let response = await request.show(); | ||
|
||
assert_array_equals(internals.mockPaymentCoordinator.supportedCountries, [], "check that `supportedCountries` is still empty after the payment is accepted"); | ||
|
||
await response.complete("success"); | ||
}, "Should not have a default value for `supportedCountries`."); | ||
|
||
user_activation_test(async (test) => { | ||
const method = validPaymentMethod(); | ||
method.data.supportedCountries = ['CA', 'GB', 'US']; | ||
|
||
let request = new PaymentRequest([method], validPaymentDetails()); | ||
request.addEventListener("merchantvalidation", (event) => { | ||
event.complete({ }); | ||
}); | ||
request.addEventListener("shippingaddresschange", (event) => { | ||
assert_array_equals(internals.mockPaymentCoordinator.supportedCountries, method.data.supportedCountries, "check that `supportedCountries` still matches after an update"); | ||
event.updateWith({ }); | ||
internals.mockPaymentCoordinator.acceptPayment(); | ||
}); | ||
|
||
let response = await request.show(); | ||
|
||
assert_array_equals(internals.mockPaymentCoordinator.supportedCountries, method.data.supportedCountries, "check that `supportedCountries` still matches after the payment is accepted"); | ||
|
||
await response.complete("success"); | ||
}, "Should propagate `supportedCountries` if provided."); | ||
done(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters