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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2017 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7 /* global PaymentRequest:false */
8 /* global print:false */
9
10 /**
11 * Do not query CanMakePayment before showing the Payment Request.
12 */
13 function noQueryShow() { // eslint-disable-line no-unused-vars
14 try {
15 var request = new PaymentRequest(
16 [{supportedMethods: ['https://bobpay.com', 'visa']}],
17 {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
18 request.show()
19 .then(function(resp) {
20 resp.complete('success')
21 .then(function() {
22 print(
23 resp.shippingOption + '<br>' +
24 JSON.stringify(
25 toDictionary(resp.shippingAddress), undefined, 2) +
26 '<br>' + resp.methodName + '<br>' +
27 JSON.stringify(resp.details, undefined, 2));
28 })
29 .catch(function(error) { print(error); });
30 })
31 .catch(function(error) { print(error); });
32 } catch (error) {
33 print(error.message);
34 }
35 }
36
37 /**
38 * Queries CanMakePayment and the shows the PaymentRequest after.
39 */
40 function queryShow() { // eslint-disable-line no-unused-vars
41 try {
42 var request = new PaymentRequest(
43 [{supportedMethods: ['https://bobpay.com', 'visa']}],
44 {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
45 request.canMakePayment()
46 .then(function(result) { print(result); })
47 .catch(function(error) { print(error); });
48 request.show()
49 .then(function(resp) {
50 resp.complete('success')
51 .then(function() {
52 print(
53 resp.shippingOption + '<br>' +
54 JSON.stringify(
55 toDictionary(resp.shippingAddress), undefined, 2) +
56 '<br>' + resp.methodName + '<br>' +
57 JSON.stringify(resp.details, undefined, 2));
58 })
59 .catch(function(error) { print(error); });
60 })
61 .catch(function(error) { print(error); });
62 } catch (error) {
63 print(error.message);
64 }
65 }
66
67 /**
68 * Queries CanMakePayment but does not show the PaymentRequest after.
69 */
70 function queryNoShow() { // eslint-disable-line no-unused-vars
71 try {
72 var request = new PaymentRequest(
73 [{supportedMethods: ['https://bobpay.com', 'visa']}],
74 {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}});
75 request.canMakePayment()
76 .then(function(result) { print(result); })
77 .catch(function(error) { print(error); });
78 } catch (error) {
79 print(error.message);
80 }
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698