Changeset 223701 in webkit


Ignore:
Timestamp:
Oct 19, 2017 1:02:29 PM (6 years ago)
Author:
aestes@apple.com
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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r223686 r223701  
     12017-10-19  Andy Estes  <aestes@apple.com>
     2
     3        [Payment Request] Only process shipping options if shipping is requested, and throw an exception on duplicate shipping option IDs
     4        https://bugs.webkit.org/show_bug.cgi?id=178535
     5
     6        Reviewed by Alex Christensen.
     7
     8        * web-platform-tests/payment-request/payment-request-constructor.https-expected.txt:
     9
    1102017-10-19  Dean Jackson  <dino@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-constructor.https-expected.txt

    r222754 r223701  
    1616PASS For each option in details.shippingOptions: if option.amount.value is not a valid decimal monetary value, then throw a TypeError
    1717PASS If there is no selected shipping option, then PaymentRequest.shippingOption remains null
    18 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"
    19 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"
    20 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 "() => {
    21       new PaymentRequest(defaultMethods, details, { requestShipping: true });
    22     }" did not throw
    23 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 "() => {
    24       new PaymentRequest(defaultMethods, details, { requestShipping: true });
    25     }" did not throw
     18PASS If there is a selected shipping option, and requestShipping is set, then that option becomes synchronously selected
     19PASS If requestShipping is set, and if there is a multiple selected shipping options, only the last is selected.
     20PASS If there are any duplicate shipping option ids, and shipping is requested, then throw a TypeError
     21PASS Throw when there are duplicate shippingOption ids, even if other values are different
    2622PASS Throw TypeError if modifier.total.amount.value is not a valid decimal monetary value
    2723PASS If amount.value of additionalDisplayItems is not a valid decimal monetary value, then throw a TypeError
  • trunk/Source/WebCore/ChangeLog

    r223699 r223701  
     12017-10-19  Andy Estes  <aestes@apple.com>
     2
     3        [Payment Request] Only process shipping options if shipping is requested, and throw an exception on duplicate shipping option IDs
     4        https://bugs.webkit.org/show_bug.cgi?id=178535
     5
     6        Reviewed by Alex Christensen.
     7
     8        Progresses four tests in web-platform-tests/payment-request/payment-request-constructor.https.html.
     9
     10        * Modules/paymentrequest/PaymentRequest.cpp:
     11        (WebCore::PaymentRequest::create):
     12
    1132017-10-19  Daniel Bates  <dabates@apple.com>
    214
  • trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp

    r223160 r223701  
    279279
    280280    String selectedShippingOption;
    281     HashSet<String> seenShippingOptionIDs;
    282     for (auto& shippingOption : details.shippingOptions) {
    283         auto exception = checkAndCanonicalizeAmount(shippingOption.amount);
    284         if (exception.hasException())
    285             return exception.releaseException();
    286 
    287         auto addResult = seenShippingOptionIDs.add(shippingOption.id);
    288         if (!addResult.isNewEntry) {
    289             details.shippingOptions = { };
    290             selectedShippingOption = { };
    291             break;
    292         }
    293 
    294         if (shippingOption.selected)
    295             selectedShippingOption = shippingOption.id;
     281    if (options.requestShipping) {
     282        HashSet<String> seenShippingOptionIDs;
     283        for (auto& shippingOption : details.shippingOptions) {
     284            auto exception = checkAndCanonicalizeAmount(shippingOption.amount);
     285            if (exception.hasException())
     286                return exception.releaseException();
     287
     288            auto addResult = seenShippingOptionIDs.add(shippingOption.id);
     289            if (!addResult.isNewEntry)
     290                return Exception { TypeError, "Shipping option IDs must be unique." };
     291
     292            if (shippingOption.selected)
     293                selectedShippingOption = shippingOption.id;
     294        }
    296295    }
    297296
Note: See TracChangeset for help on using the changeset viewer.