[WebIDL] Remove use of Dictionary in ApplePaySession
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Dec 2016 18:47:01 +0000 (18:47 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Dec 2016 18:47:01 +0000 (18:47 +0000)
commit86dd2953b2c58197f862d9095f866e645f2605e5
treeac481294234985dc32b0dded3724ed17ae5132b4
parentd98bb0d87cafd2cbad9e2e73a8f3e1db45ef7189
[WebIDL] Remove use of Dictionary in ApplePaySession
https://bugs.webkit.org/show_bug.cgi?id=165787

Reviewed by Anders Carlsson.

Source/WebCore:

First take at generating the bindings for ApplePaySession and removing
all use of Dictionary.

- Removes all use of Dictionary!
- Removes use of logging errors to the console with improved Exception messages.
- Use ExceptionOr extensively to pass exception state.

Still to do:
    - Reconcile / merge ApplePaySession::PaymentRequest with WebCore::PaymentRequest
      and all the sub-objects held within.
    - Remove PaymentRequestValidator entirely, merging validation into the validation
      we already do in ApplePaySession.cpp
    - Make ApplePayEvents use generated dictionary creation code.

Test: http/tests/ssl/applepay/ApplePaySession.html

* Modules/applepay/ApplePaySession.cpp:
(WebCore::convertAndValidate):
(WebCore::canCallApplePaySessionAPIs):
(WebCore::ApplePaySession::create):
(WebCore::ApplePaySession::ApplePaySession):
(WebCore::ApplePaySession::supportsVersion):
(WebCore::ApplePaySession::canMakePayments):
(WebCore::ApplePaySession::canMakePaymentsWithActiveCard):
(WebCore::ApplePaySession::openPaymentSetup):
(WebCore::ApplePaySession::begin):
(WebCore::ApplePaySession::completeMerchantValidation):
(WebCore::ApplePaySession::completeShippingMethodSelection):
(WebCore::ApplePaySession::completeShippingContactSelection):
(WebCore::ApplePaySession::completePaymentMethodSelection):
(WebCore::ApplePaySession::didSelectShippingMethod):
(WebCore::createContactFields): Deleted.
(WebCore::toLineItemType): Deleted.
(WebCore::isValidLineItemPropertyName): Deleted.
(WebCore::createLineItem): Deleted.
(WebCore::createLineItems): Deleted.
(WebCore::createMerchantCapabilities): Deleted.
(WebCore::createSupportedNetworks): Deleted.
(WebCore::toShippingType): Deleted.
(WebCore::isValidShippingMethodPropertyName): Deleted.
(WebCore::createShippingMethod): Deleted.
(WebCore::createShippingMethods): Deleted.
(WebCore::isValidPaymentRequestPropertyName): Deleted.
(WebCore::createPaymentRequest): Deleted.
* Modules/applepay/ApplePaySession.h:
Replace hand written dictionary extraction code with autogenerated code
and hand written additional validation.

* Modules/applepay/ApplePaySession.idl:
Add helper dictionaries and enums.

* Modules/applepay/PaymentRequestValidator.cpp:
(WebCore::PaymentRequestValidator::validate):
(WebCore::PaymentRequestValidator::validateTotal):
(WebCore::validateCountryCode):
(WebCore::validateCurrencyCode):
(WebCore::validateMerchantCapabilities):
(WebCore::validateSupportedNetworks):
(WebCore::validateShippingMethod):
(WebCore::validateShippingMethods):
(WebCore::PaymentRequestValidator::PaymentRequestValidator): Deleted.
(WebCore::PaymentRequestValidator::~PaymentRequestValidator): Deleted.
(WebCore::PaymentRequestValidator::validateCountryCode): Deleted.
(WebCore::PaymentRequestValidator::validateCurrencyCode): Deleted.
(WebCore::PaymentRequestValidator::validateMerchantCapabilities): Deleted.
(WebCore::PaymentRequestValidator::validateShippingMethod): Deleted.
(WebCore::PaymentRequestValidator::validateSupportedNetworks): Deleted.
(WebCore::PaymentRequestValidator::validateShippingMethods): Deleted.
* Modules/applepay/PaymentRequestValidator.h:
Instead of reporting the validation errors to the console, pass them in the exception.
This allows us to remove the window member, and move the helpers to the implementation
file as statics.

* WebCore.xcodeproj/project.pbxproj:
Remove file.

* bindings/generic/IDLTypes.h:
(WebCore::IDLObject::nullValue):
(WebCore::IDLObject::isNullValue):
(WebCore::IDLObject::extractValueFromNullable):
Add nullability traits for IDLObject.

* bindings/js/JSApplePaySessionCustom.cpp:
Removed.

Tools:

* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
(WTR::TestController::platformCreateWebView):
Enable ApplePay for the tests (where supported).

LayoutTests:

* http/tests/ssl/applepay: Added.
* http/tests/ssl/applepay/ApplePaySession-expected.txt: Added.
* http/tests/ssl/applepay/ApplePaySession.html: Added.
Add a compressive test of the handling of the payment request to the ApplePaySession
constructor. For further testing, we will need to mock out bits of the underlying
coordinator, but this allows for testing the aspect I am changing. The applepay
directory is in the ssl directory, as all use of ApplePay requires https.

* TestExpectations:
* platform/ios-simulator-wk2/TestExpectations:
* platform/mac-wk2/TestExpectations:
Only enable the tests on iOS 10.10 and greater, and macOS 10.12 and greater, WebKit2.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209760 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/ssl/applepay/ApplePaySession.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator-wk2/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/ApplePaySession.cpp
Source/WebCore/Modules/applepay/ApplePaySession.h
Source/WebCore/Modules/applepay/ApplePaySession.idl
Source/WebCore/Modules/applepay/PaymentRequestValidator.cpp
Source/WebCore/Modules/applepay/PaymentRequestValidator.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/generic/IDLTypes.h
Source/WebCore/bindings/js/JSApplePaySessionCustom.cpp [deleted file]
Tools/ChangeLog
Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm