Changeset 223447 in webkit


Ignore:
Timestamp:
Oct 16, 2017 5:00:40 PM (7 years ago)
Author:
aestes@apple.com
Message:

[Apple Pay] Add subLocality and subAdministrativeArea to ApplePayPaymentContact and ApplePayError
https://bugs.webkit.org/show_bug.cgi?id=178191
<rdar://problem/34906367>

Reviewed by Tim Horton.

Source/WebCore:

Added test cases to http/tests/ssl/applepay/ApplePaySession.html.

  • Modules/applepay/ApplePayError.idl:
  • Modules/applepay/ApplePayPaymentContact.h:
  • Modules/applepay/ApplePayPaymentContact.idl:
  • Modules/applepay/ApplePaySessionPaymentRequest.h:
  • Modules/applepay/cocoa/PaymentContactCocoa.mm:

(WebCore::subLocality):
(WebCore::setSubLocality):
(WebCore::subAdministrativeArea):
(WebCore::setSubAdministrativeArea):
(WebCore::convert):

Source/WebKit:

  • UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:

(WebKit::toNSError):

LayoutTests:

  • http/tests/ssl/applepay/ApplePayError-expected.txt:
  • http/tests/ssl/applepay/ApplePaySession-expected.txt:
  • http/tests/ssl/applepay/ApplePaySession.html:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r223445 r223447  
     12017-10-16  Andy Estes  <aestes@apple.com>
     2
     3        [Apple Pay] Add subLocality and subAdministrativeArea to ApplePayPaymentContact and ApplePayError
     4        https://bugs.webkit.org/show_bug.cgi?id=178191
     5        <rdar://problem/34906367>
     6
     7        Reviewed by Tim Horton.
     8
     9        * http/tests/ssl/applepay/ApplePayError-expected.txt:
     10        * http/tests/ssl/applepay/ApplePaySession-expected.txt:
     11        * http/tests/ssl/applepay/ApplePaySession.html:
     12
    1132017-10-16  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/LayoutTests/http/tests/ssl/applepay/ApplePayError-expected.txt

    r220718 r223447  
    2828
    2929SETUP:
    30 PASS new ApplePayError('unknown', []) threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "phoneticName", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".
     30PASS new ApplePayError('unknown', []) threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "phoneticName", "postalAddress", "addressLines", "subLocality", "locality", "postalCode", "subAdministrativeArea", "administrativeArea", "country", "countryCode".
    3131
    3232SETUP:
    33 PASS new ApplePayError('unknown', '') threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "phoneticName", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".
     33PASS new ApplePayError('unknown', '') threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "phoneticName", "postalAddress", "addressLines", "subLocality", "locality", "postalCode", "subAdministrativeArea", "administrativeArea", "country", "countryCode".
    3434
    3535SETUP:
  • trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt

    r223221 r223447  
    261261PASS new ApplePaySession(2, request) did not throw exception.
    262262
     263SETUP: request = validRequest(); request.billingContact = { subLocality: '', subAdministrativeArea: '' };
     264PASS new ApplePaySession(2, request) did not throw exception.
     265
    263266Testing PaymentRequest.requiredShippingContactFields
    264267
     
    322325PASS new ApplePaySession(2, request) did not throw exception.
    323326
     327SETUP: request = validRequest(); request.shippingContact = { subLocality: '', subAdministrativeArea: '' };
     328PASS new ApplePaySession(2, request) did not throw exception.
     329
    324330Testing PaymentRequest.shippingType
    325331
  • trunk/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html

    r223221 r223447  
    149149    logAndShouldNotThrow("request = validRequest(); request.billingContact = undefined;", "new ApplePaySession(2, request)")
    150150    logAndShouldNotThrow("request = validRequest(); request.billingContact = { };", "new ApplePaySession(2, request)")
     151    logAndShouldNotThrow("request = validRequest(); request.billingContact = { subLocality: '', subAdministrativeArea: '' };", "new ApplePaySession(2, request)")
    151152   
    152153    debug("Testing PaymentRequest.requiredShippingContactFields")
     
    175176    logAndShouldNotThrow("request = validRequest(); request.shippingContact = undefined;", "new ApplePaySession(2, request)")
    176177    logAndShouldNotThrow("request = validRequest(); request.shippingContact = { };", "new ApplePaySession(2, request)")
     178    logAndShouldNotThrow("request = validRequest(); request.shippingContact = { subLocality: '', subAdministrativeArea: '' };", "new ApplePaySession(2, request)")
    177179   
    178180    debug("Testing PaymentRequest.shippingType")
  • trunk/Source/WebCore/ChangeLog

    r223446 r223447  
     12017-10-16  Andy Estes  <aestes@apple.com>
     2
     3        [Apple Pay] Add subLocality and subAdministrativeArea to ApplePayPaymentContact and ApplePayError
     4        https://bugs.webkit.org/show_bug.cgi?id=178191
     5        <rdar://problem/34906367>
     6
     7        Reviewed by Tim Horton.
     8
     9        Added test cases to http/tests/ssl/applepay/ApplePaySession.html.
     10
     11        * Modules/applepay/ApplePayError.idl:
     12        * Modules/applepay/ApplePayPaymentContact.h:
     13        * Modules/applepay/ApplePayPaymentContact.idl:
     14        * Modules/applepay/ApplePaySessionPaymentRequest.h:
     15        * Modules/applepay/cocoa/PaymentContactCocoa.mm:
     16        (WebCore::subLocality):
     17        (WebCore::setSubLocality):
     18        (WebCore::subAdministrativeArea):
     19        (WebCore::setSubAdministrativeArea):
     20        (WebCore::convert):
     21
    1222017-10-16  Alex Christensen  <achristensen@webkit.org>
    223
  • trunk/Source/WebCore/Modules/applepay/ApplePayError.idl

    r220718 r223447  
    4242    "postalAddress",
    4343    "addressLines",
     44    "subLocality",
    4445    "locality",
    4546    "postalCode",
     47    "subAdministrativeArea",
    4648    "administrativeArea",
    4749    "country",
  • trunk/Source/WebCore/Modules/applepay/ApplePayPaymentContact.h

    r223221 r223447  
    4242    String phoneticFamilyName;
    4343    std::optional<Vector<String>> addressLines;
     44    String subLocality;
    4445    String locality;
    4546    String postalCode;
     47    String subAdministrativeArea;
    4648    String administrativeArea;
    4749    String country;
  • trunk/Source/WebCore/Modules/applepay/ApplePayPaymentContact.idl

    r223221 r223447  
    3535    [Conditional=APPLE_PAY_SESSION_V3] DOMString phoneticFamilyName;
    3636    sequence<DOMString> addressLines;
     37    DOMString subLocality;
    3738    DOMString locality;
    3839    DOMString postalCode;
     40    DOMString subAdministrativeArea;
    3941    DOMString administrativeArea;
    4042    DOMString country;
  • trunk/Source/WebCore/Modules/applepay/ApplePaySessionPaymentRequest.h

    r222921 r223447  
    168168        PostalAddress,
    169169        AddressLines,
     170        SubLocality,
    170171        Locality,
    171172        PostalCode,
     173        SubAdministrativeArea,
    172174        AdministrativeArea,
    173175        Country,
  • trunk/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm

    r223221 r223447  
    4747SOFT_LINK_CLASS(PassKit, PKContact)
    4848
     49#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     50@interface CNPostalAddress ()
     51@property (readonly, copy, NS_NONATOMIC_IOSONLY) NSString *subLocality;
     52@property (readonly, copy, NS_NONATOMIC_IOSONLY) NSString *subAdministrativeArea;
     53@end
     54
     55@interface CNMutablePostalAddress ()
     56@property (copy, NS_NONATOMIC_IOSONLY) NSString *subLocality;
     57@property (copy, NS_NONATOMIC_IOSONLY) NSString *subAdministrativeArea;
     58@end
     59#endif
     60
    4961namespace WebCore {
     62
     63static NSString *subLocality(CNPostalAddress *address)
     64{
     65#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     66    if (![address respondsToSelector:@selector(subLocality)])
     67        return nil;
     68#endif
     69    return address.subLocality;
     70}
     71
     72static void setSubLocality(CNMutablePostalAddress *address, NSString *subLocality)
     73{
     74#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     75    if (![address respondsToSelector:@selector(setSubLocality:)])
     76        return;
     77#endif
     78    address.subLocality = subLocality;
     79}
     80
     81static NSString *subAdministrativeArea(CNPostalAddress *address)
     82{
     83#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     84    if (![address respondsToSelector:@selector(subAdministrativeArea)])
     85        return nil;
     86#endif
     87    return address.subAdministrativeArea;
     88}
     89
     90static void setSubAdministrativeArea(CNMutablePostalAddress *address, NSString *subAdministrativeArea)
     91{
     92#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101300
     93    if (![address respondsToSelector:@selector(setSubAdministrativeArea:)])
     94        return;
     95#endif
     96    address.subAdministrativeArea = subAdministrativeArea;
     97}
    5098
    5199static RetainPtr<PKContact> convert(unsigned version, const ApplePayPaymentContact& contact)
     
    101149        [address setStreet:builder.toString()];
    102150
     151        if (!contact.subLocality.isEmpty())
     152            setSubLocality(address.get(), contact.subLocality);
    103153        if (!contact.locality.isEmpty())
    104154            [address setCity:contact.locality];
    105155        if (!contact.postalCode.isEmpty())
    106156            [address setPostalCode:contact.postalCode];
     157        if (!contact.subAdministrativeArea.isEmpty())
     158            setSubAdministrativeArea(address.get(), contact.subAdministrativeArea);
    107159        if (!contact.administrativeArea.isEmpty())
    108160            [address setState:contact.administrativeArea];
     
    141193        result.addressLines = WTFMove(addressLines);
    142194    }
     195    result.subLocality = subLocality(postalAddress);
    143196    result.locality = postalAddress.city;
    144197    result.postalCode = postalAddress.postalCode;
     198    result.subAdministrativeArea = subAdministrativeArea(postalAddress);
    145199    result.administrativeArea = postalAddress.state;
    146200    result.country = postalAddress.country;
  • trunk/Source/WebKit/ChangeLog

    r223444 r223447  
     12017-10-16  Andy Estes  <aestes@apple.com>
     2
     3        [Apple Pay] Add subLocality and subAdministrativeArea to ApplePayPaymentContact and ApplePayError
     4        https://bugs.webkit.org/show_bug.cgi?id=178191
     5        <rdar://problem/34906367>
     6
     7        Reviewed by Tim Horton.
     8
     9        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
     10        (WebKit::toNSError):
     11
    1122017-10-16  Tim Horton  <timothy_horton@apple.com>
    213
  • trunk/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm

    r222921 r223447  
    6464SOFT_LINK_FRAMEWORK(Contacts)
    6565SOFT_LINK_CONSTANT(Contacts, CNPostalAddressStreetKey, NSString *);
     66SOFT_LINK_CONSTANT(Contacts, CNPostalAddressSubLocalityKey, NSString *);
    6667SOFT_LINK_CONSTANT(Contacts, CNPostalAddressCityKey, NSString *);
     68SOFT_LINK_CONSTANT(Contacts, CNPostalAddressSubAdministrativeAreaKey, NSString *);
    6769SOFT_LINK_CONSTANT(Contacts, CNPostalAddressStateKey, NSString *);
    6870SOFT_LINK_CONSTANT(Contacts, CNPostalAddressPostalCodeKey, NSString *);
     
    657659            break;
    658660
     661        case WebCore::PaymentError::ContactField::SubLocality:
     662            pkContactField = getPKContactFieldPostalAddress();
     663            postalAddressKey = getCNPostalAddressSubLocalityKey();
     664            break;
     665
    659666        case WebCore::PaymentError::ContactField::Locality:
    660667            pkContactField = getPKContactFieldPostalAddress();
     
    665672            pkContactField = getPKContactFieldPostalAddress();
    666673            postalAddressKey = getCNPostalAddressPostalCodeKey();
     674            break;
     675
     676        case WebCore::PaymentError::ContactField::SubAdministrativeArea:
     677            pkContactField = getPKContactFieldPostalAddress();
     678            postalAddressKey = getCNPostalAddressSubAdministrativeAreaKey();
    667679            break;
    668680
Note: See TracChangeset for help on using the changeset viewer.