Title: [211703] branches/safari-603-branch

Diff

Modified: branches/safari-603-branch/LayoutTests/ChangeLog (211702 => 211703)


--- branches/safari-603-branch/LayoutTests/ChangeLog	2017-02-06 05:50:57 UTC (rev 211702)
+++ branches/safari-603-branch/LayoutTests/ChangeLog	2017-02-06 05:51:01 UTC (rev 211703)
@@ -1,5 +1,22 @@
 2017-02-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r211446. rdar://problem/30273885
+
+    2017-01-31  Anders Carlsson  <ander...@apple.com>
+
+            Apple Pay button does nothing on nytimes.com
+            https://bugs.webkit.org/show_bug.cgi?id=167664
+            rdar://problem/30273885
+
+            Reviewed by Sam Weinig.
+
+            Add a new test.
+
+            * http/tests/ssl/applepay/ApplePaySession-expected.txt:
+            * http/tests/ssl/applepay/ApplePaySession.html:
+
+2017-02-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r211616. rdar://problem/30060142
 
     2017-02-02  Alexey Proskuryakov  <a...@apple.com>

Modified: branches/safari-603-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt (211702 => 211703)


--- branches/safari-603-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt	2017-02-06 05:50:57 UTC (rev 211702)
+++ branches/safari-603-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt	2017-02-06 05:51:01 UTC (rev 211703)
@@ -169,6 +169,9 @@
 SETUP: request = validRequest(); request.lineItems = { };
 PASS new ApplePaySession(2, request) threw exception TypeError: Type error.
 
+SETUP: request = validRequest(); request.lineItems = [{ label: 'label', type: 'pending' }];
+PASS new ApplePaySession(2, request) did not throw exception.
+
 SETUP: request = validRequest(); request.lineItems = [];
 PASS new ApplePaySession(2, request) did not throw exception.
 

Modified: branches/safari-603-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html (211702 => 211703)


--- branches/safari-603-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html	2017-02-06 05:50:57 UTC (rev 211702)
+++ branches/safari-603-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html	2017-02-06 05:51:01 UTC (rev 211703)
@@ -112,7 +112,7 @@
     logAndShouldThrow("request = validRequest(); request.lineItems = null;", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.lineItems = 7;", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.lineItems = { };", "new ApplePaySession(2, request)")
-    // FIXME: Should we allow an empty lineItems sequence?
+    logAndShouldNotThrow("request = validRequest(); request.lineItems = [{ label: 'label', type: 'pending' }];", "new ApplePaySession(2, request)")
     logAndShouldNotThrow("request = validRequest(); request.lineItems = [];", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.lineItems = [''];", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.lineItems = [null];", "new ApplePaySession(2, request)")

Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (211702 => 211703)


--- branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-06 05:50:57 UTC (rev 211702)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-06 05:51:01 UTC (rev 211703)
@@ -1,5 +1,31 @@
 2017-02-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r211446. rdar://problem/30273885
+
+    2017-01-31  Anders Carlsson  <ander...@apple.com>
+
+            Apple Pay button does nothing on nytimes.com
+            https://bugs.webkit.org/show_bug.cgi?id=167664
+            rdar://problem/30273885
+
+            Reviewed by Sam Weinig.
+
+            Separate line item validation into convertAndValidateTotal and convertAndValidate. The former
+            works on totals (which require an amount), and the latter works on regular line items that do not require an amount
+            if the item type is "pending".
+
+            * Modules/applepay/ApplePaySession.cpp:
+            (WebCore::convertAndValidateTotal):
+            (WebCore::convertAndValidate):
+            Only check the amount if the type is not pending.
+
+            (WebCore::ApplePaySession::completeShippingMethodSelection):
+            (WebCore::ApplePaySession::completeShippingContactSelection):
+            (WebCore::ApplePaySession::completePaymentMethodSelection):
+            Call convertAndValidateTotal for totals.
+
+2017-02-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r211455. rdar://problem/30241193
 
     2017-01-31  Chris Dumez  <cdu...@apple.com>

Modified: branches/safari-603-branch/Source/WebCore/Modules/applepay/ApplePaySession.cpp (211702 => 211703)


--- branches/safari-603-branch/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2017-02-06 05:50:57 UTC (rev 211702)
+++ branches/safari-603-branch/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2017-02-06 05:51:01 UTC (rev 211703)
@@ -162,7 +162,7 @@
     return amount;
 }
 
-static ExceptionOr<PaymentRequest::LineItem> convertAndValidate(ApplePayLineItem&& lineItem)
+static ExceptionOr<PaymentRequest::LineItem> convertAndValidateTotal(ApplePayLineItem&& lineItem)
 {
     auto amount = parseAmount(lineItem.amount);
     if (!amount)
@@ -176,6 +176,25 @@
     return WTFMove(result);
 }
 
+static ExceptionOr<PaymentRequest::LineItem> convertAndValidate(ApplePayLineItem&& lineItem)
+{
+    PaymentRequest::LineItem result;
+
+    // It is OK for pending types to not have an amount.
+    if (lineItem.type != PaymentRequest::LineItem::Type::Pending) {
+        auto amount = parseAmount(lineItem.amount);
+        if (!amount)
+            return Exception { TypeError, makeString("\"" + lineItem.amount, "\" is not a valid amount.") };
+
+        result.amount = *amount;
+    }
+
+    result.type = lineItem.type;
+    result.label = lineItem.label;
+
+    return WTFMove(result);
+}
+
 static ExceptionOr<Vector<PaymentRequest::LineItem>> convertAndValidate(Vector<ApplePayLineItem>&& lineItems)
 {
     Vector<PaymentRequest::LineItem> result;
@@ -295,7 +314,7 @@
 {
     PaymentRequest result;
 
-    auto total = convertAndValidate(WTFMove(paymentRequest.total));
+    auto total = convertAndValidateTotal(WTFMove(paymentRequest.total));
     if (total.hasException())
         return total.releaseException();
     result.setTotal(total.releaseReturnValue());
@@ -609,7 +628,7 @@
     if (!authorizationStatus)
         return Exception { INVALID_ACCESS_ERR };
 
-    auto convertedNewTotal = convertAndValidate(WTFMove(newTotal));
+    auto convertedNewTotal = convertAndValidateTotal(WTFMove(newTotal));
     if (convertedNewTotal.hasException())
         return convertedNewTotal.releaseException();
 
@@ -646,7 +665,7 @@
     if (convertedNewShippingMethods.hasException())
         return convertedNewShippingMethods.releaseException();
 
-    auto convertedNewTotal = convertAndValidate(WTFMove(newTotal));
+    auto convertedNewTotal = convertAndValidateTotal(WTFMove(newTotal));
     if (convertedNewTotal.hasException())
         return convertedNewTotal.releaseException();
 
@@ -675,7 +694,7 @@
     if (!canCompletePaymentMethodSelection())
         return Exception { INVALID_ACCESS_ERR };
 
-    auto convertedNewTotal = convertAndValidate(WTFMove(newTotal));
+    auto convertedNewTotal = convertAndValidateTotal(WTFMove(newTotal));
     if (convertedNewTotal.hasException())
         return convertedNewTotal.releaseException();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to