Title: [223701] trunk
Revision
223701
Author
[email protected]
Date
2017-10-19 13:02:29 -0700 (Thu, 19 Oct 2017)

Log Message

[Payment Request] Only process shipping options if shipping is requested, and throw an exception on duplicate shipping option IDs
https://bugs.webkit.org/show_bug.cgi?id=178535

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

* web-platform-tests/payment-request/payment-request-constructor.https-expected.txt:

Source/WebCore:

Progresses four tests in web-platform-tests/payment-request/payment-request-constructor.https.html.

* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::create):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (223700 => 223701)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-10-19 19:57:00 UTC (rev 223700)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-10-19 20:02:29 UTC (rev 223701)
@@ -1,3 +1,12 @@
+2017-10-19  Andy Estes  <[email protected]>
+
+        [Payment Request] Only process shipping options if shipping is requested, and throw an exception on duplicate shipping option IDs
+        https://bugs.webkit.org/show_bug.cgi?id=178535
+
+        Reviewed by Alex Christensen.
+
+        * web-platform-tests/payment-request/payment-request-constructor.https-expected.txt:
+
 2017-10-19  Dean Jackson  <[email protected]>
 
         Import W3C Web Platform Tests for createImageBitmap

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-constructor.https-expected.txt (223700 => 223701)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-constructor.https-expected.txt	2017-10-19 19:57:00 UTC (rev 223700)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-constructor.https-expected.txt	2017-10-19 20:02:29 UTC (rev 223701)
@@ -15,14 +15,10 @@
 PASS it handles high precision currency values without throwing 
 PASS For each option in details.shippingOptions: if option.amount.value is not a valid decimal monetary value, then throw a TypeError 
 PASS If there is no selected shipping option, then PaymentRequest.shippingOption remains null 
-FAIL If there is a selected shipping option, and requestShipping is set, then that option becomes synchronously selected assert_equals: Must be null when no shipping is requested (defaults to false) expected (object) null but got (string) "the-id"
-FAIL If requestShipping is set, and if there is a multiple selected shipping options, only the last is selected. assert_equals: shippingOption must be null, as requestShipping is false expected (object) null but got (string) "the-id"
-FAIL If there are any duplicate shipping option ids, and shipping is requested, then throw a TypeError assert_throws: Expected to throw a TypeError because duplicate IDs function "() => {
-      new PaymentRequest(defaultMethods, details, { requestShipping: true });
-    }" did not throw
-FAIL Throw when there are duplicate shippingOption ids, even if other values are different assert_throws: Expected to throw a TypeError because duplicate IDs function "() => {
-      new PaymentRequest(defaultMethods, details, { requestShipping: true });
-    }" did not throw
+PASS If there is a selected shipping option, and requestShipping is set, then that option becomes synchronously selected 
+PASS If requestShipping is set, and if there is a multiple selected shipping options, only the last is selected. 
+PASS If there are any duplicate shipping option ids, and shipping is requested, then throw a TypeError 
+PASS Throw when there are duplicate shippingOption ids, even if other values are different 
 PASS Throw TypeError if modifier.total.amount.value is not a valid decimal monetary value 
 PASS If amount.value of additionalDisplayItems is not a valid decimal monetary value, then throw a TypeError 
 PASS Modifier data must be JSON-serializable object (an Array in this case) 

Modified: trunk/Source/WebCore/ChangeLog (223700 => 223701)


--- trunk/Source/WebCore/ChangeLog	2017-10-19 19:57:00 UTC (rev 223700)
+++ trunk/Source/WebCore/ChangeLog	2017-10-19 20:02:29 UTC (rev 223701)
@@ -1,3 +1,15 @@
+2017-10-19  Andy Estes  <[email protected]>
+
+        [Payment Request] Only process shipping options if shipping is requested, and throw an exception on duplicate shipping option IDs
+        https://bugs.webkit.org/show_bug.cgi?id=178535
+
+        Reviewed by Alex Christensen.
+
+        Progresses four tests in web-platform-tests/payment-request/payment-request-constructor.https.html.
+
+        * Modules/paymentrequest/PaymentRequest.cpp:
+        (WebCore::PaymentRequest::create):
+
 2017-10-19  Daniel Bates  <[email protected]>
 
         Share logic in InlineTextBox to compute selection rect

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (223700 => 223701)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2017-10-19 19:57:00 UTC (rev 223700)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2017-10-19 20:02:29 UTC (rev 223701)
@@ -278,21 +278,20 @@
     }
 
     String selectedShippingOption;
-    HashSet<String> seenShippingOptionIDs;
-    for (auto& shippingOption : details.shippingOptions) {
-        auto exception = checkAndCanonicalizeAmount(shippingOption.amount);
-        if (exception.hasException())
-            return exception.releaseException();
+    if (options.requestShipping) {
+        HashSet<String> seenShippingOptionIDs;
+        for (auto& shippingOption : details.shippingOptions) {
+            auto exception = checkAndCanonicalizeAmount(shippingOption.amount);
+            if (exception.hasException())
+                return exception.releaseException();
 
-        auto addResult = seenShippingOptionIDs.add(shippingOption.id);
-        if (!addResult.isNewEntry) {
-            details.shippingOptions = { };
-            selectedShippingOption = { };
-            break;
+            auto addResult = seenShippingOptionIDs.add(shippingOption.id);
+            if (!addResult.isNewEntry)
+                return Exception { TypeError, "Shipping option IDs must be unique." };
+
+            if (shippingOption.selected)
+                selectedShippingOption = shippingOption.id;
         }
-
-        if (shippingOption.selected)
-            selectedShippingOption = shippingOption.id;
     }
 
     Vector<String> serializedModifierData;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to