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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 .then(result => { | 75 .then(result => { |
76 assert_equals(result, true); | 76 assert_equals(result, true); |
77 return registration.paymentManager.instruments.delete('test_key'); | 77 return registration.paymentManager.instruments.delete('test_key'); |
78 }) | 78 }) |
79 .then(result => { | 79 .then(result => { |
80 assert_equals(result, false); | 80 assert_equals(result, false); |
81 }) | 81 }) |
82 .catch(unreached_rejection(test)); | 82 .catch(unreached_rejection(test)); |
83 }, 'PaymentInstruments delete method test'); | 83 }, 'PaymentInstruments delete method test'); |
84 | 84 |
| 85 promise_test(test => { |
| 86 var registration; |
| 87 var script_url = 'resources/empty-worker.js'; |
| 88 var scope = 'resources/'; |
| 89 |
| 90 return service_worker_unregister_and_register(test, script_url, scope) |
| 91 .then(r => { |
| 92 registration = r; |
| 93 return wait_for_state(test, registration.installing, 'activated'); |
| 94 }) |
| 95 .then(state => { |
| 96 assert_equals(state, 'activated'); |
| 97 return registration.paymentManager.instruments.set( |
| 98 'test_key', |
| 99 { |
| 100 name: 'Visa ending ****4756', |
| 101 enabledMethods: ['basic-card'], |
| 102 capabilities: { |
| 103 supportedNetworks: ['visa'], |
| 104 supportedTypes: ['credit'] |
| 105 } |
| 106 }); |
| 107 }) |
| 108 .then(result => { |
| 109 assert_equals(result, undefined); |
| 110 return registration.paymentManager.instruments.has('test_key'); |
| 111 }) |
| 112 .then(result => { |
| 113 assert_equals(result, true); |
| 114 return registration.paymentManager.instruments.has('unstored_test_key'
); |
| 115 }) |
| 116 .then(result => { |
| 117 assert_equals(result, false); |
| 118 }) |
| 119 .catch(unreached_rejection(test)); |
| 120 }, 'PaymentInstruments |has| method test'); |
| 121 |
85 </script> | 122 </script> |
OLD | NEW |