Add "countryCode" to ApplePayErrorContactField
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 May 2017 18:57:10 +0000 (18:57 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 May 2017 18:57:10 +0000 (18:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172264
<rdar://problem/32004909>

Reviewed by Anders Carlsson.

Source/WebCore:

Added ApplePayError tests to http/tests/ssl/applepay/ApplePaySession.html

* Modules/applepay/ApplePayError.idl:
* Modules/applepay/PaymentRequest.h:

Source/WebKit2:

* UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::toNSError):

LayoutTests:

* http/tests/ssl/applepay/ApplePaySession-expected.txt:
* http/tests/ssl/applepay/ApplePaySession.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217057 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt
LayoutTests/http/tests/ssl/applepay/ApplePaySession.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/ApplePayError.idl
Source/WebCore/Modules/applepay/PaymentRequest.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm

index 9902e5d..f70961b 100644 (file)
@@ -1,3 +1,14 @@
+2017-05-18  Andy Estes  <aestes@apple.com>
+
+        Add "countryCode" to ApplePayErrorContactField
+        https://bugs.webkit.org/show_bug.cgi?id=172264
+        <rdar://problem/32004909>
+
+        Reviewed by Anders Carlsson.
+
+        * http/tests/ssl/applepay/ApplePaySession-expected.txt:
+        * http/tests/ssl/applepay/ApplePaySession.html:
+
 2017-05-18  Daniel Bates  <dabates@apple.com>
 
         REGRESSION (r209608): Cross-origin plugin document opened in child window blocked by parent
index bbaccd9..02b782e 100644 (file)
@@ -414,6 +414,65 @@ PASS new ApplePaySession(2, request) did not throw exception.
 SETUP: request = validRequest(); request.applicationData = { toString: function() { throw '"Error in toString"'; } };
 PASS new ApplePaySession(2, request) threw exception "Error in toString".
 
+Testing ApplePayError
+
+SETUP: 
+PASS new ApplePayError() threw exception TypeError: Not enough arguments.
+
+SETUP: 
+PASS new ApplePayError([]) threw exception TypeError: Argument 1 ('errorCode') to the ApplePayError constructor must be one of: "unknown", "shippingContactInvalid", "billingContactInvalid", "addressUnserviceable".
+
+SETUP: 
+PASS new ApplePayError('') threw exception TypeError: Argument 1 ('errorCode') to the ApplePayError constructor must be one of: "unknown", "shippingContactInvalid", "billingContactInvalid", "addressUnserviceable".
+
+SETUP: 
+PASS new ApplePayError('unknown') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('shippingContactInvalid') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('billingContactInvalid') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('addressUnserviceable') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', []) threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".
+
+SETUP: 
+PASS new ApplePayError('unknown', '') threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".
+
+SETUP: 
+PASS new ApplePayError('unknown', 'phoneNumber') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', 'emailAddress') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', 'name') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', 'postalAddress') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', 'addressLines') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', 'locality') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', 'postalCode') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', 'administrativeArea') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', 'country') did not throw exception.
+
+SETUP: 
+PASS new ApplePayError('unknown', 'countryCode') did not throw exception.
+
 PASS successfullyParsed is true
 
 TEST COMPLETE
index f344c20..f9e7f9f 100644 (file)
@@ -213,6 +213,28 @@ function go() {
     logAndShouldNotThrow("request = validRequest(); request.applicationData = { };", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.applicationData = { toString: function() { throw '\"Error in toString\"'; } };", "new ApplePaySession(2, request)")
 
+    debug("Testing ApplePayError")
+    debug("");
+    logAndShouldThrow("", "new ApplePayError()")
+    logAndShouldThrow("", "new ApplePayError([])")
+    logAndShouldThrow("", "new ApplePayError('')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown')")
+    logAndShouldNotThrow("", "new ApplePayError('shippingContactInvalid')")
+    logAndShouldNotThrow("", "new ApplePayError('billingContactInvalid')")
+    logAndShouldNotThrow("", "new ApplePayError('addressUnserviceable')")
+    logAndShouldThrow("", "new ApplePayError('unknown', [])")
+    logAndShouldThrow("", "new ApplePayError('unknown', '')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'phoneNumber')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'emailAddress')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'name')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'postalAddress')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'addressLines')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'locality')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'postalCode')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'administrativeArea')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'country')")
+    logAndShouldNotThrow("", "new ApplePayError('unknown', 'countryCode')")
+
     document.querySelector("button").remove();
 
     finishJSTest();
index b442ee6..4a6da9b 100644 (file)
@@ -1,3 +1,16 @@
+2017-05-18  Andy Estes  <aestes@apple.com>
+
+        Add "countryCode" to ApplePayErrorContactField
+        https://bugs.webkit.org/show_bug.cgi?id=172264
+        <rdar://problem/32004909>
+
+        Reviewed by Anders Carlsson.
+
+        Added ApplePayError tests to http/tests/ssl/applepay/ApplePaySession.html
+
+        * Modules/applepay/ApplePayError.idl:
+        * Modules/applepay/PaymentRequest.h:
+
 2017-05-18  Daniel Bates  <dabates@apple.com>
 
         Cleanup: Remove unnecessary call to AddToImplIncludes("RuntimeEnabledFeatures.h") in GenerateImplementation()
index 76378b1..cb90ff5 100644 (file)
@@ -43,7 +43,8 @@
     "locality",
     "postalCode",
     "administrativeArea",
-    "country"
+    "country",
+    "countryCode"
 };
 
 [
index 46734b3..1c1b64e 100644 (file)
@@ -168,6 +168,7 @@ struct PaymentError {
         PostalCode,
         AdministrativeArea,
         Country,
+        CountryCode,
     };
 
     Code code;
@@ -222,7 +223,8 @@ template<> struct EnumTraits<WebCore::PaymentError::ContactField> {
         WebCore::PaymentError::ContactField::Locality,
         WebCore::PaymentError::ContactField::PostalCode,
         WebCore::PaymentError::ContactField::AdministrativeArea,
-        WebCore::PaymentError::ContactField::Country
+        WebCore::PaymentError::ContactField::Country,
+        WebCore::PaymentError::ContactField::CountryCode
     >;
 };
 
index 471a1d3..fdc589f 100644 (file)
@@ -1,3 +1,14 @@
+2017-05-18  Andy Estes  <aestes@apple.com>
+
+        Add "countryCode" to ApplePayErrorContactField
+        https://bugs.webkit.org/show_bug.cgi?id=172264
+        <rdar://problem/32004909>
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+        (WebKit::toNSError):
+
 2017-05-18  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r217031, r217032, and r217037.
index 91386da..e60fc6a 100644 (file)
@@ -64,6 +64,7 @@ SOFT_LINK_CONSTANT(Contacts, CNPostalAddressCityKey, NSString *);
 SOFT_LINK_CONSTANT(Contacts, CNPostalAddressStateKey, NSString *);
 SOFT_LINK_CONSTANT(Contacts, CNPostalAddressPostalCodeKey, NSString *);
 SOFT_LINK_CONSTANT(Contacts, CNPostalAddressCountryKey, NSString *);
+SOFT_LINK_CONSTANT(Contacts, CNPostalAddressISOCountryCodeKey, NSString *);
 SOFT_LINK_CLASS(PassKit, PKPaymentAuthorizationResult)
 SOFT_LINK_CLASS(PassKit, PKPaymentRequestPaymentMethodUpdate)
 SOFT_LINK_CLASS(PassKit, PKPaymentRequestShippingContactUpdate)
@@ -635,6 +636,11 @@ static RetainPtr<NSError> toNSError(const WebCore::PaymentError& error)
             pkContactField = getPKContactFieldPostalAddress();
             postalAddressKey = getCNPostalAddressCountryKey();
             break;
+
+        case WebCore::PaymentError::ContactField::CountryCode:
+            pkContactField = getPKContactFieldPostalAddress();
+            postalAddressKey = getCNPostalAddressISOCountryCodeKey();
+            break;
         }
 
         [userInfo setObject:pkContactField forKey:getPKPaymentErrorContactFieldUserInfoKey()];