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

Side by Side Diff: chrome/test/data/android/payments/active_payment_query_bobpay.js

Issue 2507063009: Return cached query result for canMakeActivePayment. (Closed)
Patch Set: Merge methods, add more tests, simplify impl" Created 4 years 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 2016 The Chromium Authors. All rights reserved. 2 * Copyright 2016 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 first;
11 var second;
12
10 /** 13 /**
11 * Checks for existence of Bob Pay. 14 * Sets the |first| variable and prints both |first| and |second| only if both
15 * were set.
16 */
17 function printFirst(result) {
18 first = result.toString();
19 if (first && second) {
20 print(first + ', ' + second);
21 }
22 }
23
24 /**
25 * Sets the |second| variable and prints both |first| and |second| only if both
26 * were set.
27 */
28 function printSecond(result) {
29 second = result.toString();
30 if (first && second) {
31 print(first + ', ' + second);
32 }
33 }
34
35 /**
36 * Checks for existence of Bob Pay twice.
12 */ 37 */
13 function buy() { // eslint-disable-line no-unused-vars 38 function buy() { // eslint-disable-line no-unused-vars
39 first = null;
40 second = null;
41
14 try { 42 try {
15 var request = new PaymentRequest( 43 new PaymentRequest(
16 [{supportedMethods: ['https://bobpay.com']}], 44 [{supportedMethods: ['https://bobpay.com']}],
17 {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}}); 45 {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
18 request.canMakeActivePayment() 46 .canMakeActivePayment()
19 .then(function(result) { 47 .then(function(result) { printFirst(result); })
20 print(result); 48 .catch(function(error) { printFirst(error); });
21 })
22 .catch(function(error) {
23 print(error);
24 });
25 } catch (error) { 49 } catch (error) {
26 print(error.message); 50 printFirst(error);
51 }
52
53 try {
54 new PaymentRequest(
55 [{supportedMethods: ['https://bobpay.com']}],
56 {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
57 .canMakeActivePayment()
58 .then(function(result) { printSecond(result); })
59 .catch(function(error) { printSecond(error); });
60 } catch (error) {
61 printSecond(error);
27 } 62 }
28 } 63 }
64
65 /**
66 * Checks for existence of Bob Pay and AlicePay.
67 */
68 function otherBuy() { // eslint-disable-line no-unused-vars
69 first = null;
70 second = null;
71
72 try {
73 new PaymentRequest(
74 [{supportedMethods: ['https://bobpay.com']}],
75 {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
76 .canMakeActivePayment()
77 .then(function(result) { printFirst(result); })
78 .catch(function(error) { printFirst(error); });
79 } catch (error) {
80 printFirst(error);
81 }
82
83 try {
84 new PaymentRequest(
85 [{supportedMethods: ['https://alicepay.com']}],
86 {total: {label: 'Total', amount: {currency: 'USD', value: '5.00'}}})
87 .canMakeActivePayment()
88 .then(function(result) { printSecond(result); })
89 .catch(function(error) { printSecond(error); });
90 } catch (error) {
91 printSecond(error);
92 }
93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698