Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp

Issue 2406713002: PaymentRequest: Ignore shipping options if there are duplicated IDs. (Closed)
Patch Set: presubmit Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/payments/PaymentRequest.h" 5 #include "modules/payments/PaymentRequest.h"
6 6
7 #include "bindings/core/v8/JSONValuesForV8.h" 7 #include "bindings/core/v8/JSONValuesForV8.h"
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 "\"value\": \"5.00\"}}," 591 "\"value\": \"5.00\"}},"
592 "\"error\": \"This is an error message.\"}"; 592 "\"error\": \"This is an error message.\"}";
593 593
594 request->onUpdatePaymentDetails(ScriptValue::from( 594 request->onUpdatePaymentDetails(ScriptValue::from(
595 scope.getScriptState(), 595 scope.getScriptState(),
596 fromJSONString(scope.getScriptState(), detailWithErrorMsg, 596 fromJSONString(scope.getScriptState(), detailWithErrorMsg,
597 scope.getExceptionState()))); 597 scope.getExceptionState())));
598 EXPECT_FALSE(scope.getExceptionState().hadException()); 598 EXPECT_FALSE(scope.getExceptionState().hadException());
599 } 599 }
600 600
601 TEST(PaymentRequestTest,
602 ShouldResolveWithEmptyShippingOptionsIfIDsOfShippingOptionsAreDuplicated) {
603 V8TestingScope scope;
604 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
605 makePaymentRequestOriginSecure(scope.document());
606 PaymentDetails details;
607 details.setTotal(buildPaymentItemForTest());
608 HeapVector<PaymentShippingOption> shippingOptions(2);
609 shippingOptions[0] = buildShippingOptionForTest(
610 PaymentTestDataId, PaymentTestOverwriteValue, "standard");
611 shippingOptions[0].setSelected(true);
612 shippingOptions[1] = buildShippingOptionForTest(
613 PaymentTestDataId, PaymentTestOverwriteValue, "standard");
614 details.setShippingOptions(shippingOptions);
615 PaymentOptions options;
616 options.setRequestShipping(true);
617 PaymentRequest* request = PaymentRequest::create(
618 scope.getScriptState(), buildPaymentMethodDataForTest(), details, options,
619 scope.getExceptionState());
620 EXPECT_FALSE(scope.getExceptionState().hadException());
621 EXPECT_TRUE(request->shippingOption().isNull());
622 request->show(scope.getScriptState())
623 .then(funcs.expectNoCall(), funcs.expectNoCall());
624 String detailWithShippingOptions =
625 "{\"total\": {\"label\": \"Total\", \"amount\": {\"currency\": \"USD\", "
626 "\"value\": \"5.00\"}},"
627 "\"shippingOptions\": [{\"id\": \"standardShippingOption\", \"label\": "
628 "\"Standard shipping\", \"amount\": {\"currency\": \"USD\", \"value\": "
629 "\"5.00\"}, \"selected\": true}, {\"id\": \"standardShippingOption\", "
630 "\"label\": \"Standard shipping\", \"amount\": {\"currency\": \"USD\", "
631 "\"value\": \"5.00\"}, \"selected\": true}]}";
632
633 request->onUpdatePaymentDetails(ScriptValue::from(
634 scope.getScriptState(),
635 fromJSONString(scope.getScriptState(), detailWithShippingOptions,
636 scope.getExceptionState())));
637
638 EXPECT_FALSE(scope.getExceptionState().hadException());
639 EXPECT_TRUE(request->shippingOption().isNull());
640 }
641
601 } // namespace 642 } // namespace
602 } // namespace blink 643 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698