haikuwebkit/Source/WebCore/testing/MockPaymentError.idl

34 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

[Apple Pay] Support granular errors in PaymentDetailsUpdate https://bugs.webkit.org/show_bug.cgi?id=189938 Reviewed by Youenn Fablet. Source/WebCore: Implemented the shippingAddressErrors, payerErrors, and paymentMethodErrors properties on PaymentDetailsUpdate, as specified in the Payment Request API W3C Editor's Draft of 26 September 2018. When these errors are specified in a PaymentDetailsUpdate, map them to PaymentErrors. For shippingAddressErrors and payerErrors, we use the "shippingContactInvalid" code and a contact field that matches the shippingAddressError or payerError property specified. For paymentMethodErrors, we interpret this as a sequence of ApplePayErrors, which are converted to PaymentErrors as in Apple Pay JS. Tests: http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrors.https.html http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html * DerivedSources.make: Removed some tabs and added new .idl files. * Modules/applepay/ApplePayError.idl: Moved ApplePayErrorCode and ApplePayErrorContactField into their own .idl files so they can be used in MockPaymentError. * Modules/applepay/ApplePayErrorCode.h: Added. * Modules/applepay/ApplePayErrorCode.idl: Added. * Modules/applepay/ApplePayErrorContactField.h: Added. * Modules/applepay/ApplePayErrorContactField.idl: Added. * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp: (WebCore::appendShippingContactInvalidError): Appended a "shippingContactInvalid" PaymentError to errors if the message is non-null. (WebCore::ApplePayPaymentHandler::computeErrors const): (WebCore::ApplePayPaymentHandler::detailsUpdated): (WebCore::ApplePayPaymentHandler::shippingAddressUpdated): Computed a vector of PaymentErrors based on shippingAddressErrors, payerErrors, and paymentMethodErrors. * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h: * Modules/paymentrequest/PaymentDetailsUpdate.h: * Modules/paymentrequest/PaymentDetailsUpdate.idl: Defined shippingAddressErrors, payerErrors, and paymentMethodErrors. * Modules/paymentrequest/PaymentHandler.h: * Modules/paymentrequest/PaymentRequest.cpp: (WebCore::PaymentRequest::paymentMethodChanged): (WebCore::PaymentRequest::settleDetailsPromise): Passed shippingAddressErrors, payerErrors, and paymentMethodErrors to the payment handler. * SourcesCocoa.txt: * WebCore.xcodeproj/project.pbxproj: * testing/MockPaymentCoordinator.cpp: (WebCore::MockPaymentCoordinator::completeShippingContactSelection): Stored errors in m_errors. * testing/MockPaymentCoordinator.h: * testing/MockPaymentCoordinator.idl: Added an errors attribute. * testing/MockPaymentError.h: Added. * testing/MockPaymentError.idl: Added. LayoutTests: * http/tests/resources/payment-request.js: (validPaymentDetails): (updateDetailsOnShippingAddressChange): * http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrors.https-expected.txt: Added. * http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrors.https.html: Added. * http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https-expected.txt: Added. * http/tests/ssl/applepay/ApplePayShippingAddressChangeEventErrorsV3.https.html: Added. * platform/mac-wk2/TestExpectations: Canonical link: https://commits.webkit.org/204992@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236552 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-27 16:44:49 +00:00
/*
* Copyright (C) 2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
[
Conditional=APPLE_PAY,
JSGenerateToJSObject,
] dictionary MockPaymentError {
required ApplePayErrorCode code;
required DOMString message;
ApplePayErrorContactField contactField;
};