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

Unified Diff: chrome/test/data/payments/can_make_payment_metrics.js

Issue 2642213005: [Payments] Add CanMakePayment metrics. (Closed)
Patch Set: Created 3 years, 11 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
Index: chrome/test/data/payments/can_make_payment_metrics.js
diff --git a/chrome/test/data/payments/can_make_payment_metrics.js b/chrome/test/data/payments/can_make_payment_metrics.js
new file mode 100644
index 0000000000000000000000000000000000000000..f5795313014c63f8eebc15d1a5a4dfe787266ca8
--- /dev/null
+++ b/chrome/test/data/payments/can_make_payment_metrics.js
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2017 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* global PaymentRequest:false */
+/* global print:false */
+
+/**
+ * Do not query CanMakePayment before showing the Payment Request.
+ */
+function noQueryShow() { // eslint-disable-line no-unused-vars
+ try {
+ var request = new PaymentRequest(
+ [{supportedMethods: ['https://bobpay.com', 'visa']}],
+ {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
+ request.show()
+ .then(function(resp) {
+ resp.complete('success')
+ .then(function() {
+ print(
+ resp.shippingOption + '<br>' +
+ JSON.stringify(
+ toDictionary(resp.shippingAddress), undefined, 2) +
+ '<br>' + resp.methodName + '<br>' +
+ JSON.stringify(resp.details, undefined, 2));
+ })
+ .catch(function(error) { print(error); });
+ })
+ .catch(function(error) { print(error); });
+ } catch (error) {
+ print(error.message);
+ }
+}
+
+/**
+ * Queries CanMakePayment and the shows the PaymentRequest after.
+ */
+function queryShow() { // eslint-disable-line no-unused-vars
+ try {
+ var request = new PaymentRequest(
+ [{supportedMethods: ['https://bobpay.com', 'visa']}],
+ {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
+ request.canMakePayment()
+ .then(function(result) { print(result); })
+ .catch(function(error) { print(error); });
+ request.show()
+ .then(function(resp) {
+ resp.complete('success')
+ .then(function() {
+ print(
+ resp.shippingOption + '<br>' +
+ JSON.stringify(
+ toDictionary(resp.shippingAddress), undefined, 2) +
+ '<br>' + resp.methodName + '<br>' +
+ JSON.stringify(resp.details, undefined, 2));
+ })
+ .catch(function(error) { print(error); });
+ })
+ .catch(function(error) { print(error); });
+ } catch (error) {
+ print(error.message);
+ }
+}
+
+/**
+ * Queries CanMakePayment but does not show the PaymentRequest after.
+ */
+function queryNoShow() { // eslint-disable-line no-unused-vars
+ try {
+ var request = new PaymentRequest(
+ [{supportedMethods: ['https://bobpay.com', 'visa']}],
+ {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
+ request.canMakePayment()
+ .then(function(result) { print(result); })
+ .catch(function(error) { print(error); });
+ } catch (error) {
+ print(error.message);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698