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

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

Issue 1938843002: More thorough tests for PaymentDetails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-output-dir
Patch Set: Address comments Created 4 years, 7 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/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/JSONValuesForV8.h" 8 #include "bindings/core/v8/JSONValuesForV8.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 namespace blink { 102 namespace blink {
103 namespace { 103 namespace {
104 104
105 // Validates ShippingOption and PaymentItem dictionaries, which happen to have i dentical fields. 105 // Validates ShippingOption and PaymentItem dictionaries, which happen to have i dentical fields.
106 template <typename T> 106 template <typename T>
107 void validateShippingOptionsOrPaymentItems(HeapVector<T> items, ExceptionState& exceptionState) 107 void validateShippingOptionsOrPaymentItems(HeapVector<T> items, ExceptionState& exceptionState)
108 { 108 {
109 String errorMessage; 109 String errorMessage;
110 for (const auto& item : items) { 110 for (const auto& item : items) {
111 if (!item.hasId()) { 111 if (!item.hasId() || item.id().isEmpty()) {
112 exceptionState.throwTypeError("Item id required"); 112 exceptionState.throwTypeError("Item id required");
113 return; 113 return;
114 } 114 }
115 115
116 if (!item.hasLabel()) { 116 if (!item.hasLabel() || item.label().isEmpty()) {
117 exceptionState.throwTypeError("Item label required"); 117 exceptionState.throwTypeError("Item label required");
118 return; 118 return;
119 } 119 }
120 120
121 if (!item.hasAmount()) { 121 if (!item.hasAmount()) {
122 exceptionState.throwTypeError("Currency amount required"); 122 exceptionState.throwTypeError("Currency amount required");
123 return; 123 return;
124 } 124 }
125 125
126 if (!item.amount().hasCurrencyCode()) { 126 if (!item.amount().hasCurrencyCode()) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 void PaymentRequest::cleanUp() 365 void PaymentRequest::cleanUp()
366 { 366 {
367 m_completeResolver.clear(); 367 m_completeResolver.clear();
368 m_showResolver.clear(); 368 m_showResolver.clear();
369 if (m_clientBinding.is_bound()) 369 if (m_clientBinding.is_bound())
370 m_clientBinding.Close(); 370 m_clientBinding.Close();
371 m_paymentProvider.reset(); 371 m_paymentProvider.reset();
372 } 372 }
373 373
374 } // namespace blink 374 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698