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 27 matching lines...) Expand all Loading... |
38 assert_equals(stored_instrument.name, 'Visa ending ****4756'); | 38 assert_equals(stored_instrument.name, 'Visa ending ****4756'); |
39 assert_array_equals(stored_instrument.enabledMethods, ['basic-card']); | 39 assert_array_equals(stored_instrument.enabledMethods, ['basic-card']); |
40 assert_object_equals(stored_instrument.capabilities, { | 40 assert_object_equals(stored_instrument.capabilities, { |
41 supportedNetworks: ['visa'], | 41 supportedNetworks: ['visa'], |
42 supportedTypes: ['credit'] | 42 supportedTypes: ['credit'] |
43 }); | 43 }); |
44 }) | 44 }) |
45 .catch(unreached_rejection(test)); | 45 .catch(unreached_rejection(test)); |
46 }, 'PaymentInstruments set/get methods test'); | 46 }, 'PaymentInstruments set/get methods test'); |
47 | 47 |
| 48 promise_test(test => { |
| 49 var registration; |
| 50 var script_url = 'resources/empty-worker.js'; |
| 51 var scope = 'resources/'; |
| 52 |
| 53 return service_worker_unregister_and_register(test, script_url, scope) |
| 54 .then(r => { |
| 55 registration = r; |
| 56 return wait_for_state(test, registration.installing, 'activated'); |
| 57 }) |
| 58 .then(state => { |
| 59 assert_equals(state, 'activated'); |
| 60 return registration.paymentManager.instruments.set( |
| 61 'test_key', |
| 62 { |
| 63 name: 'Visa ending ****4756', |
| 64 enabledMethods: ['basic-card'], |
| 65 capabilities: { |
| 66 supportedNetworks: ['visa'], |
| 67 supportedTypes: ['credit'] |
| 68 } |
| 69 }); |
| 70 }) |
| 71 .then(result => { |
| 72 assert_equals(result, undefined); |
| 73 return registration.paymentManager.instruments.delete('test_key'); |
| 74 }) |
| 75 .then(result => { |
| 76 assert_equals(result, true); |
| 77 return registration.paymentManager.instruments.delete('test_key'); |
| 78 }) |
| 79 .then(result => { |
| 80 assert_equals(result, false); |
| 81 }) |
| 82 .catch(unreached_rejection(test)); |
| 83 }, 'PaymentInstruments delete method test'); |
| 84 |
48 </script> | 85 </script> |
OLD | NEW |