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

Unified Diff: chrome/test/data/android/payments/metrics.js

Issue 2199813003: [Payments] Add metrics for Payment Request aborts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metrics
Patch Set: Moved metrics enum to PaymentRequestMetrics.java Created 4 years, 4 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/android/payments/metrics.js
diff --git a/chrome/test/data/android/payments/metrics.js b/chrome/test/data/android/payments/metrics.js
new file mode 100644
index 0000000000000000000000000000000000000000..e41b7eda90388e033c67b3f5a1fbacf3439be0f8
--- /dev/null
+++ b/chrome/test/data/android/payments/metrics.js
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2016 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 toDictionary:false */
+
+/**
+ * Launches the PaymentRequest UI that accepts credit cards.
+ */
+function buy() { // eslint-disable-line no-unused-vars
+ try {
+ var request = new PaymentRequest(
+ [{supportedMethods: ['visa']}], {
+ total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
+ shippingOptions: [{
+ id: 'freeShippingOption',
+ label: 'Free global shipping',
+ amount: {currency: 'USD', value: '0'},
+ selected: true
+ }]
+ },
+ {requestShipping: true});
+ 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);
+ }
+}
+
+/**
+ * Launches the PaymentRequest UI which accepts a supported payment method but
+ * does not accept credit cards.
+ */
+function noMatching() { // eslint-disable-line no-unused-vars
+ try {
+ var request = new PaymentRequest(
+ [{supportedMethods: ['https://bobpay.com']}], {
+ total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
+ shippingOptions: [{
+ id: 'freeShippingOption',
+ label: 'Free global shipping',
+ amount: {currency: 'USD', value: '0'},
+ selected: true
+ }]
+ },
+ {requestShipping: true});
+ 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);
+ }
+}
+
+/**
+ * Launches the PaymentRequest UI which accepts only and unsupported payment
please use gerrit instead 2016/08/03 18:05:23 s/and/an/
sebsg 2016/08/03 19:47:33 Done.
+ */
+function noSupported() { // eslint-disable-line no-unused-vars
+ try {
+ var request = new PaymentRequest(
+ [{supportedMethods: ['https://randompay.com']}], {
+ total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}},
+ shippingOptions: [{
+ id: 'freeShippingOption',
+ label: 'Free global shipping',
+ amount: {currency: 'USD', value: '0'},
+ selected: true
+ }]
+ },
+ {requestShipping: true});
+ 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);
+ }
+}
+
+/**
+ * Aborts the current PaymentRequest.
+ */
+function abort() { // eslint-disable-line no-unused-vars
+ try {
+ request.abort().then(() => {
+ print('Aborted');
+ }).catch(() => {
+ print('Cannot abort');
+ });
+ } catch (error) {
+ print(error.message);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698