Title: [235797] branches/safari-606-branch
Revision
235797
Author
[email protected]
Date
2018-09-07 13:07:58 -0700 (Fri, 07 Sep 2018)

Log Message

Cherry-pick r235318. rdar://problem/44209848

    [Apple Pay] Allow $0 totals
    https://bugs.webkit.org/show_bug.cgi?id=185150
    <rdar://problem/39212331>

    Reviewed by Dan Bernstein.

    Source/WebCore:

    Relaxed payment request validation to allow $0 totals. This matches PassKit behavior.

    Updated test cases in http/tests/ssl/applepay/.

    * Modules/applepay/PaymentRequestValidator.mm:
    (WebCore::PaymentRequestValidator::validateTotal):

    LayoutTests:

    * http/tests/ssl/applepay/ApplePaySession-expected.txt:
    * http/tests/ssl/applepay/ApplePaySession.html:
    * http/tests/ssl/applepay/ApplePaySessionV3-expected.txt:
    * http/tests/ssl/applepay/ApplePaySessionV3.html:
    * http/tests/ssl/applepay/ApplePaySessionV4-expected.txt:
    * http/tests/ssl/applepay/ApplePaySessionV4.html:
    * http/tests/ssl/applepay/PaymentRequest.https-expected.txt:
    * http/tests/ssl/applepay/PaymentRequest.https.html:

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

Modified Paths

Diff

Modified: branches/safari-606-branch/LayoutTests/ChangeLog (235796 => 235797)


--- branches/safari-606-branch/LayoutTests/ChangeLog	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/LayoutTests/ChangeLog	2018-09-07 20:07:58 UTC (rev 235797)
@@ -1,5 +1,55 @@
 2018-09-06  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r235318. rdar://problem/44209848
+
+    [Apple Pay] Allow $0 totals
+    https://bugs.webkit.org/show_bug.cgi?id=185150
+    <rdar://problem/39212331>
+    
+    Reviewed by Dan Bernstein.
+    
+    Source/WebCore:
+    
+    Relaxed payment request validation to allow $0 totals. This matches PassKit behavior.
+    
+    Updated test cases in http/tests/ssl/applepay/.
+    
+    * Modules/applepay/PaymentRequestValidator.mm:
+    (WebCore::PaymentRequestValidator::validateTotal):
+    
+    LayoutTests:
+    
+    * http/tests/ssl/applepay/ApplePaySession-expected.txt:
+    * http/tests/ssl/applepay/ApplePaySession.html:
+    * http/tests/ssl/applepay/ApplePaySessionV3-expected.txt:
+    * http/tests/ssl/applepay/ApplePaySessionV3.html:
+    * http/tests/ssl/applepay/ApplePaySessionV4-expected.txt:
+    * http/tests/ssl/applepay/ApplePaySessionV4.html:
+    * http/tests/ssl/applepay/PaymentRequest.https-expected.txt:
+    * http/tests/ssl/applepay/PaymentRequest.https.html:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235318 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-08-24  Andy Estes  <[email protected]>
+
+            [Apple Pay] Allow $0 totals
+            https://bugs.webkit.org/show_bug.cgi?id=185150
+            <rdar://problem/39212331>
+
+            Reviewed by Dan Bernstein.
+
+            * http/tests/ssl/applepay/ApplePaySession-expected.txt:
+            * http/tests/ssl/applepay/ApplePaySession.html:
+            * http/tests/ssl/applepay/ApplePaySessionV3-expected.txt:
+            * http/tests/ssl/applepay/ApplePaySessionV3.html:
+            * http/tests/ssl/applepay/ApplePaySessionV4-expected.txt:
+            * http/tests/ssl/applepay/ApplePaySessionV4.html:
+            * http/tests/ssl/applepay/PaymentRequest.https-expected.txt:
+            * http/tests/ssl/applepay/PaymentRequest.https.html:
+
+2018-09-06  Babak Shafiei  <[email protected]>
+
         Cherry-pick r235251. rdar://problem/44209840
 
     [Apple Pay] Introduce Apple Pay JS v4 on iOS 12 and macOS Mojave

Modified: branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt (235796 => 235797)


--- branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt	2018-09-07 20:07:58 UTC (rev 235797)
@@ -8,6 +8,7 @@
 PASS ApplePaySession.supportsVersion(0) threw exception InvalidAccessError: The object does not support the operation or argument..
 PASS ApplePaySession.supportsVersion(1) is true
 PASS ApplePaySession.supportsVersion(2) is true
+
 Testing PaymentRequest
 
 PASS new ApplePaySession(2, { }) threw exception TypeError: Member ApplePayPaymentRequest.countryCode is required and must be an instance of DOMString.
@@ -148,11 +149,8 @@
 SETUP: request = validRequest(); request.total = { label: 'label', amount: 'amount' };
 PASS new ApplePaySession(2, request) threw exception TypeError: "amount" is not a valid amount..
 
-SETUP: request = validRequest(); request.total = { label: 'label', amount: '0' };
-PASS new ApplePaySession(2, request) threw exception TypeError: Total amount must be greater than zero..
-
 SETUP: request = validRequest(); request.total = { label: 'label', amount: '-10.00' };
-PASS new ApplePaySession(2, request) threw exception TypeError: Total amount must be greater than zero..
+PASS new ApplePaySession(2, request) threw exception TypeError: Total amount must not be negative..
 
 SETUP: request = validRequest(); request.total = { label: 'label', amount: '10000000000.00' };
 PASS new ApplePaySession(2, request) threw exception TypeError: Total amount is too big..

Modified: branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html (235796 => 235797)


--- branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html	2018-09-07 20:07:58 UTC (rev 235797)
@@ -38,9 +38,10 @@
 function go() {
     debug("Testing supportsVersion");
     debug("");
-	shouldThrow("ApplePaySession.supportsVersion(0)");
-	shouldBeTrue("ApplePaySession.supportsVersion(1)");
-	shouldBeTrue("ApplePaySession.supportsVersion(2)");
+    shouldThrow("ApplePaySession.supportsVersion(0)");
+    shouldBeTrue("ApplePaySession.supportsVersion(1)");
+    shouldBeTrue("ApplePaySession.supportsVersion(2)");
+    debug("");
 
     debug("Testing PaymentRequest")
     debug("");
@@ -107,7 +108,6 @@
     logAndShouldThrow("request = validRequest(); request.total = { };", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.total = { label: 'label' };", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.total = { label: 'label', amount: 'amount' };", "new ApplePaySession(2, request)")
-    logAndShouldThrow("request = validRequest(); request.total = { label: 'label', amount: '0' };", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.total = { label: 'label', amount: '-10.00' };", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.total = { label: 'label', amount: '10000000000.00' };", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.total = { label: 'label', amount: '10.00', type: 'invalid' };", "new ApplePaySession(2, request)")

Modified: branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt (235796 => 235797)


--- branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt	2018-09-07 20:07:58 UTC (rev 235797)
@@ -9,6 +9,7 @@
 PASS ApplePaySession.supportsVersion(1) is true
 PASS ApplePaySession.supportsVersion(2) is true
 PASS ApplePaySession.supportsVersion(3) is true
+
 Testing PaymentRequest (v3)
 
 PASS new ApplePaySession(3, { }) threw exception TypeError: Member ApplePayPaymentRequest.countryCode is required and must be an instance of DOMString.

Modified: branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html (235796 => 235797)


--- branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html	2018-09-07 20:07:58 UTC (rev 235797)
@@ -38,10 +38,11 @@
 function go() {
     debug("Testing supportsVersion");
     debug("");
-	shouldThrow("ApplePaySession.supportsVersion(0)");
-	shouldBeTrue("ApplePaySession.supportsVersion(1)");
-	shouldBeTrue("ApplePaySession.supportsVersion(2)");
-	shouldBeTrue("ApplePaySession.supportsVersion(3)");
+    shouldThrow("ApplePaySession.supportsVersion(0)");
+    shouldBeTrue("ApplePaySession.supportsVersion(1)");
+    shouldBeTrue("ApplePaySession.supportsVersion(2)");
+    shouldBeTrue("ApplePaySession.supportsVersion(3)");
+    debug("");
 
     debug("Testing PaymentRequest (v3)")
     debug("");

Modified: branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV4-expected.txt (235796 => 235797)


--- branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV4-expected.txt	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV4-expected.txt	2018-09-07 20:07:58 UTC (rev 235797)
@@ -10,11 +10,18 @@
 PASS ApplePaySession.supportsVersion(2) is true
 PASS ApplePaySession.supportsVersion(3) is true
 PASS ApplePaySession.supportsVersion(4) is true
+
 Testing PaymentRequest (v4)
 
 PASS new ApplePaySession(4, { }) threw exception TypeError: Member ApplePayPaymentRequest.countryCode is required and must be an instance of DOMString.
 PASS new ApplePaySession(4, validRequest()) did not throw exception.
 
+Testing PaymentRequest.total
+
+SETUP: request = validRequest(); request.total = { label: 'label', amount: '0' };
+PASS new ApplePaySession(4, request) did not throw exception.
+
+
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV4.html (235796 => 235797)


--- branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV4.html	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV4.html	2018-09-07 20:07:58 UTC (rev 235797)
@@ -38,11 +38,12 @@
 function go() {
     debug("Testing supportsVersion");
     debug("");
-	shouldThrow("ApplePaySession.supportsVersion(0)");
-	shouldBeTrue("ApplePaySession.supportsVersion(1)");
-	shouldBeTrue("ApplePaySession.supportsVersion(2)");
-	shouldBeTrue("ApplePaySession.supportsVersion(3)");
-	shouldBeTrue("ApplePaySession.supportsVersion(4)");
+    shouldThrow("ApplePaySession.supportsVersion(0)");
+    shouldBeTrue("ApplePaySession.supportsVersion(1)");
+    shouldBeTrue("ApplePaySession.supportsVersion(2)");
+    shouldBeTrue("ApplePaySession.supportsVersion(3)");
+    shouldBeTrue("ApplePaySession.supportsVersion(4)");
+    debug("");
 
     debug("Testing PaymentRequest (v4)")
     debug("");
@@ -50,6 +51,11 @@
     shouldNotThrow("new ApplePaySession(4, validRequest())");
     debug("");
 
+    debug("Testing PaymentRequest.total")
+    debug("");
+    logAndShouldNotThrow("request = validRequest(); request.total = { label: 'label', amount: '0' };", "new ApplePaySession(4, request)")
+    debug("");
+
     document.querySelector("button").remove();
 
     finishJSTest();

Modified: branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https-expected.txt (235796 => 235797)


--- branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https-expected.txt	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https-expected.txt	2018-09-07 20:07:58 UTC (rev 235797)
@@ -154,8 +154,6 @@
 SETUP: paymentDetails = validPaymentDetails(); paymentDetails.total = { label: 'label', amount: { currency: '', value: '0' } };
 PASS request = new PaymentRequest([validPaymentMethod()], paymentDetails); request.show() threw exception RangeError: "" is not a valid currency code..
 
-SETUP: paymentDetails = validPaymentDetails(); paymentDetails.total = { label: 'label', amount: { currency: 'USD', value: '0' } };
-PASS request = new PaymentRequest([validPaymentMethod()], paymentDetails); request.show() rejected promise  with TypeError: Total amount must be greater than zero..
 
 SETUP: paymentDetails = validPaymentDetails(); paymentDetails.total = { label: 'label', amount: { currency: 'USD', value:'-10.00'} };
 PASS request = new PaymentRequest([validPaymentMethod()], paymentDetails); request.show() threw exception TypeError: Total currency values cannot be negative..

Modified: branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html (235796 => 235797)


--- branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html	2018-09-07 20:07:58 UTC (rev 235797)
@@ -154,7 +154,6 @@
     await logAndShouldThrow("paymentDetails = validPaymentDetails(); paymentDetails.total = { label: 'label' };", "request = new PaymentRequest([validPaymentMethod()], paymentDetails); request.show()")
     await logAndShouldThrow("paymentDetails = validPaymentDetails(); paymentDetails.total = { label: 'label', amount: 'amount' };", "request = new PaymentRequest([validPaymentMethod()], paymentDetails); request.show()")
     await logAndShouldThrow("paymentDetails = validPaymentDetails(); paymentDetails.total = { label: 'label', amount: { currency: '', value: '0' } };", "request = new PaymentRequest([validPaymentMethod()], paymentDetails); request.show()")
-    await logAndShouldReject("paymentDetails = validPaymentDetails(); paymentDetails.total = { label: 'label', amount: { currency: 'USD', value: '0' } };", "request = new PaymentRequest([validPaymentMethod()], paymentDetails); request.show()")
     debug("")
     await logAndShouldThrow("paymentDetails = validPaymentDetails(); paymentDetails.total = { label: 'label', amount: { currency: 'USD', value:'-10.00'} };", "request = new PaymentRequest([validPaymentMethod()], paymentDetails); request.show()")
     await logAndShouldReject("paymentDetails = validPaymentDetails(); paymentDetails.total = { label: 'label', amount: { currency: 'USD', value: '10000000000.00' } };", "request = new PaymentRequest([validPaymentMethod()], paymentDetails); request.show()")

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (235796 => 235797)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-09-07 20:07:58 UTC (rev 235797)
@@ -1,5 +1,53 @@
 2018-09-06  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r235318. rdar://problem/44209848
+
+    [Apple Pay] Allow $0 totals
+    https://bugs.webkit.org/show_bug.cgi?id=185150
+    <rdar://problem/39212331>
+    
+    Reviewed by Dan Bernstein.
+    
+    Source/WebCore:
+    
+    Relaxed payment request validation to allow $0 totals. This matches PassKit behavior.
+    
+    Updated test cases in http/tests/ssl/applepay/.
+    
+    * Modules/applepay/PaymentRequestValidator.mm:
+    (WebCore::PaymentRequestValidator::validateTotal):
+    
+    LayoutTests:
+    
+    * http/tests/ssl/applepay/ApplePaySession-expected.txt:
+    * http/tests/ssl/applepay/ApplePaySession.html:
+    * http/tests/ssl/applepay/ApplePaySessionV3-expected.txt:
+    * http/tests/ssl/applepay/ApplePaySessionV3.html:
+    * http/tests/ssl/applepay/ApplePaySessionV4-expected.txt:
+    * http/tests/ssl/applepay/ApplePaySessionV4.html:
+    * http/tests/ssl/applepay/PaymentRequest.https-expected.txt:
+    * http/tests/ssl/applepay/PaymentRequest.https.html:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235318 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-08-24  Andy Estes  <[email protected]>
+
+            [Apple Pay] Allow $0 totals
+            https://bugs.webkit.org/show_bug.cgi?id=185150
+            <rdar://problem/39212331>
+
+            Reviewed by Dan Bernstein.
+
+            Relaxed payment request validation to allow $0 totals. This matches PassKit behavior.
+
+            Updated test cases in http/tests/ssl/applepay/.
+
+            * Modules/applepay/PaymentRequestValidator.mm:
+            (WebCore::PaymentRequestValidator::validateTotal):
+
+2018-09-06  Babak Shafiei  <[email protected]>
+
         Cherry-pick r235251. rdar://problem/44209840
 
     [Apple Pay] Introduce Apple Pay JS v4 on iOS 12 and macOS Mojave

Modified: branches/safari-606-branch/Source/WebCore/Modules/applepay/PaymentRequestValidator.mm (235796 => 235797)


--- branches/safari-606-branch/Source/WebCore/Modules/applepay/PaymentRequestValidator.mm	2018-09-07 20:07:54 UTC (rev 235796)
+++ branches/safari-606-branch/Source/WebCore/Modules/applepay/PaymentRequestValidator.mm	2018-09-07 20:07:58 UTC (rev 235797)
@@ -86,8 +86,8 @@
 
     double amount = [NSDecimalNumber decimalNumberWithString:total.amount locale:@{ NSLocaleDecimalSeparator : @"." }].doubleValue;
 
-    if (amount <= 0)
-        return Exception { TypeError, "Total amount must be greater than zero." };
+    if (amount < 0)
+        return Exception { TypeError, "Total amount must not be negative." };
 
     if (amount > 100000000)
         return Exception { TypeError, "Total amount is too big." };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to