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

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

Issue 2850723003: [Payment Request] Updates PaymentRequestUpdateEvent.updateWith function (Closed)
Patch Set: Addressed comment 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..2a2cd2b4ef75d05de79cf825a575b4352fa3e96c 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 |detailsOrPromise| 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}
+ * detailsOrPromise
+ */
+ __gCrWeb['paymentRequestManager'].updateWith = function(detailsOrPromise) {
+ // if |detailsOrPromise| is not an instance of a Promise, wrap it in a
+ // Promise that fulfills with |detailsOrPromise|.
+ if (!detailsOrPromise || !(detailsOrPromise.then instanceof Function) ||
+ !(detailsOrPromise.catch instanceof Function)) {
+ detailsOrPromise = Promise.resolve(detailsOrPromise);
}
- updateWithPromise
+ detailsOrPromise
.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