OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 <script src="../../serviceworker/resources/test-helpers.js"></script> | 4 <script src="../../serviceworker/resources/test-helpers.js"></script> |
5 <script> | 5 <script> |
6 | 6 |
7 promise_test(test => { | 7 promise_test(test => { |
8 var registration; | 8 var registration; |
9 var script_url = 'resources/empty-worker.js'; | 9 var script_url = 'resources/empty-worker.js'; |
10 var scope = 'resources/'; | 10 var scope = 'resources/'; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 label: 'Payment App' | 70 label: 'Payment App' |
71 }); | 71 }); |
72 }) | 72 }) |
73 .then(unreached_fulfillment(test)) | 73 .then(unreached_fulfillment(test)) |
74 .catch(error => { | 74 .catch(error => { |
75 assert_equals(error.name, 'InvalidStateError'); | 75 assert_equals(error.name, 'InvalidStateError'); |
76 }); | 76 }); |
77 }, 'If registration has no active worker, no waiting worker and ' | 77 }, 'If registration has no active worker, no waiting worker and ' |
78 + 'no installing worker, then throws InvalidStateError.'); | 78 + 'no installing worker, then throws InvalidStateError.'); |
79 | 79 |
| 80 promise_test(test => { |
| 81 var registration; |
| 82 var script_url = 'resources/empty-worker.js'; |
| 83 var scope = 'resources/'; |
| 84 var manifest = { |
| 85 label: 'Payment App', |
| 86 icon: 'payment-app-icon', |
| 87 options: [{ |
| 88 label: 'Visa ****', |
| 89 icon: 'payment-app-icon', |
| 90 id: 'payment-app-id', |
| 91 enabledMethods: ['visa2'] |
| 92 }] |
| 93 }; |
| 94 |
| 95 return service_worker_unregister_and_register(test, script_url, scope) |
| 96 .then(r => { |
| 97 registration = r; |
| 98 return wait_for_state(test, registration.installing, 'activated'); |
| 99 }) |
| 100 .then(state => { |
| 101 assert_equals(state, 'activated'); |
| 102 return registration.paymentAppManager.setManifest(manifest); |
| 103 }) |
| 104 .then(result => { |
| 105 assert_equals(result, undefined); |
| 106 return registration.paymentAppManager.getManifest(); |
| 107 }) |
| 108 .then(read_manifest => { |
| 109 assert_object_equals(read_manifest, manifest); |
| 110 }) |
| 111 .catch(unreached_rejection(test)); |
| 112 }, 'If getManifest() is succeeded, then resolves stored manifest data.'); |
| 113 |
| 114 promise_test(test => { |
| 115 var registration; |
| 116 var script_url = 'resources/empty-worker.js'; |
| 117 var scope = 'resources/'; |
| 118 var manifest = { |
| 119 label: 'Payment App', |
| 120 icon: 'payment-app-icon', |
| 121 options: [{ |
| 122 label: 'Visa ****', |
| 123 icon: 'payment-app-icon', |
| 124 id: 'payment-app-id', |
| 125 enabledMethods: ['visa2'] |
| 126 }] |
| 127 }; |
| 128 |
| 129 return service_worker_unregister_and_register(test, script_url, scope) |
| 130 .then(r => { |
| 131 registration = r; |
| 132 return wait_for_state(test, registration.installing, 'activated'); |
| 133 }) |
| 134 .then(state => { |
| 135 assert_equals(state, 'activated'); |
| 136 return registration.paymentAppManager.setManifest(manifest); |
| 137 }) |
| 138 .then(result => { |
| 139 assert_equals(result, undefined); |
| 140 return registration.unregister(); |
| 141 }) |
| 142 .then(result => { |
| 143 assert_equals(result, true); |
| 144 return registration.paymentAppManager.getManifest(); |
| 145 }) |
| 146 .then(unreached_fulfillment(test)) |
| 147 .catch(error => { |
| 148 assert_equals(error.name, 'AbortError'); |
| 149 }); |
| 150 }, 'If service worker is unregistered, then manifest is cleared as well.'); |
| 151 |
| 152 promise_test(test => { |
| 153 var registration; |
| 154 var script_url = 'resources/empty-worker.js'; |
| 155 var scope = 'resources/'; |
| 156 |
| 157 return service_worker_unregister_and_register(test, script_url, scope) |
| 158 .then(r => { |
| 159 registration = r; |
| 160 return wait_for_state(test, registration.installing, 'activated'); |
| 161 }) |
| 162 .then(state => { |
| 163 assert_equals(state, 'activated'); |
| 164 return registration.paymentAppManager.getManifest(); |
| 165 }) |
| 166 .then(unreached_fulfillment(test)) |
| 167 .catch(error => { |
| 168 assert_equals(error.name, 'AbortError'); |
| 169 }); |
| 170 }, 'If there is no manifest data, then throws AbortError.'); |
| 171 |
80 </script> | 172 </script> |
OLD | NEW |