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

Side by Side Diff: chrome/test/data/payments/can_make_payment_metrics.js

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

Powered by Google App Engine
This is Rietveld 408576698