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

Unified Diff: ios/chrome/browser/web/resources/payment_request.js

Issue 2850723003: [Payment Request] Updates PaymentRequestUpdateEvent.updateWith function (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/web/resources/payment_request.js
diff --git a/ios/chrome/browser/web/resources/payment_request.js b/ios/chrome/browser/web/resources/payment_request.js
index e31b81916c3154ac74c53dddcda39cbbadbf5963..6511e240bed511ce4a1ce49b407c1e2ea97fc50c 100644
--- a/ios/chrome/browser/web/resources/payment_request.js
+++ b/ios/chrome/browser/web/resources/payment_request.js
@@ -230,20 +230,21 @@ var SerializedPaymentResponse;
/**
* Handles invocation of updateWith() on the updateEvent object. Updates the
- * payment details when the |updateWithPromise| is resolved. Throws an error
- * if |updateWithPromise| is not a valid instance of Promise or if it fulfills
- * with an invalid instance of window.PaymentDetails.
- * @param {?Promise<?window.PaymentDetails|undefined>|undefined}
- * updateWithPromise
- */
- __gCrWeb['paymentRequestManager'].updateWith = function(updateWithPromise) {
- // Check to see |updateWithPromise| is an instance of Promise.
- if (!updateWithPromise || !(updateWithPromise.then instanceof Function) ||
- !(updateWithPromise.catch instanceof Function)) {
- throw new TypeError('An instance of Promise must be provided');
+ * payment details. Throws an error if |detailsPromise| is not a valid
+ * instance of window.PaymentDetails or it is a promise that does not fulfill
+ * with a valid one.
+ * @param {!Promise<!window.PaymentDetails>|!window.PaymentDetails}
+ * detailsPromise
+ */
+ __gCrWeb['paymentRequestManager'].updateWith = function(detailsPromise) {
please use gerrit instead 2017/04/28 13:07:23 Nit: Please change this parameter name to "details
Moe 2017/04/28 13:40:43 Done.
+ // if |detailsPromise| is not an instance of a Promise, wrap it in a Promise
+ // that fulfills with |detailsPromise|.
+ if (!detailsPromise || !(detailsPromise.then instanceof Function) ||
+ !(detailsPromise.catch instanceof Function)) {
+ detailsPromise = Promise.resolve(detailsPromise);
}
- updateWithPromise
+ detailsPromise
.then(function(paymentDetails) {
if (!paymentDetails)
throw new TypeError(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698