OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <meta charset="utf-8"> | 2 <meta charset="utf-8"> |
3 <title>PaymentHandler: Tests for PaymentInstruments</title> | 3 <title>PaymentHandler: Tests for PaymentInstruments</title> |
4 <link rel="help" href="https://w3c.github.io/webpayments-payment-apps-api/#payme
nt-instruments"> | 4 <link rel="help" href="https://w3c.github.io/webpayments-payment-apps-api/#payme
nt-instruments"> |
5 <script src="../resources/testharness.js"></script> | 5 <script src="../resources/testharness.js"></script> |
6 <script src="../resources/testharnessreport.js"></script> | 6 <script src="../resources/testharnessreport.js"></script> |
7 <script src="../../serviceworker/resources/test-helpers.js"></script> | 7 <script src="../../serviceworker/resources/test-helpers.js"></script> |
8 <script> | 8 <script> |
9 | 9 |
10 promise_test(test => { | 10 promise_test(test => { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 .then(result => { | 112 .then(result => { |
113 assert_equals(result, true); | 113 assert_equals(result, true); |
114 return registration.paymentManager.instruments.has('unstored_test_key'
); | 114 return registration.paymentManager.instruments.has('unstored_test_key'
); |
115 }) | 115 }) |
116 .then(result => { | 116 .then(result => { |
117 assert_equals(result, false); | 117 assert_equals(result, false); |
118 }) | 118 }) |
119 .catch(unreached_rejection(test)); | 119 .catch(unreached_rejection(test)); |
120 }, 'PaymentInstruments |has| method test'); | 120 }, 'PaymentInstruments |has| method test'); |
121 | 121 |
122 promise_test(test => { | |
123 var registration; | |
124 var script_url = 'resources/empty-worker.js'; | |
125 var scope = 'resources/'; | |
126 | |
127 return service_worker_unregister_and_register(test, script_url, scope) | |
128 .then(r => { | |
129 registration = r; | |
130 return wait_for_state(test, registration.installing, 'activated'); | |
131 }) | |
132 .then(state => { | |
133 assert_equals(state, 'activated'); | |
134 var instruments = [ | |
135 registration.paymentManager.instruments.set( | |
136 'test_key1', | |
137 { | |
138 name: 'Visa ending ****4756', | |
139 enabledMethods: ['basic-card'], | |
140 capabilities: { | |
141 supportedNetworks: ['visa'], | |
142 supportedTypes: ['credit'] | |
143 } | |
144 }), | |
145 registration.paymentManager.instruments.set( | |
146 'test_key2', | |
147 { | |
148 name: "My Bob Pay Account: john@example.com", | |
149 enabledMethods: ["https://bobpay.com/"] | |
150 }) | |
151 ]; | |
152 return Promise.all(instruments); | |
153 }) | |
154 .then(result => { | |
155 assert_array_equals(result, [undefined, undefined]); | |
156 return registration.paymentManager.instruments.keys(); | |
157 }) | |
158 .then(result => { | |
159 assert_array_equals(result, ['test_key1', 'test_key2']); | |
160 }) | |
161 .catch(unreached_rejection(test)); | |
162 }, 'PaymentInstruments |keys| method test'); | |
163 | |
164 </script> | 122 </script> |
OLD | NEW |