| 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/'; |
| 11 | 11 |
| 12 return service_worker_unregister_and_register(test, script_url, scope) | 12 return service_worker_unregister_and_register(test, script_url, scope) |
| 13 .then(r => { | 13 .then(r => { |
| 14 registration = r; | 14 registration = r; |
| 15 return wait_for_state(test, registration.installing, 'activated'); | 15 return wait_for_state(test, registration.installing, 'activated'); |
| 16 }) | 16 }) |
| 17 .then(state => { | 17 .then(state => { |
| 18 assert_equals(state, 'activated'); | 18 assert_equals(state, 'activated'); |
| 19 return registration.paymentAppManager.setManifest({ | 19 return registration.paymentManager.setManifest({ |
| 20 name: 'Payment App', | 20 name: 'Payment App', |
| 21 icon: 'payment-app-icon', | 21 icon: 'payment-app-icon', |
| 22 options: [{ | 22 options: [{ |
| 23 name: 'Visa ****', | 23 name: 'Visa ****', |
| 24 icon: 'payment-app-icon', | 24 icon: 'payment-app-icon', |
| 25 id: 'payment-app-id', | 25 id: 'payment-app-id', |
| 26 enabledMethods: ['visa'] | 26 enabledMethods: ['visa'] |
| 27 }] | 27 }] |
| 28 }); | 28 }); |
| 29 }) | 29 }) |
| 30 .then(result => { | 30 .then(result => { |
| 31 assert_equals(result, undefined); | 31 assert_equals(result, undefined); |
| 32 }) | 32 }) |
| 33 .catch(unreached_rejection(test)); | 33 .catch(unreached_rejection(test)); |
| 34 }, 'setManifest() should resolve with undefined if ' | 34 }, 'setManifest() should resolve with undefined if ' |
| 35 + 'setManifest() is succeeded.'); | 35 + 'setManifest() is succeeded.'); |
| 36 | 36 |
| 37 promise_test(test => { | 37 promise_test(test => { |
| 38 var registration; | 38 var registration; |
| 39 var script_url = 'resources/empty-worker.js'; | 39 var script_url = 'resources/empty-worker.js'; |
| 40 var scope = 'resources/'; | 40 var scope = 'resources/'; |
| 41 | 41 |
| 42 return service_worker_unregister_and_register(test, script_url, scope) | 42 return service_worker_unregister_and_register(test, script_url, scope) |
| 43 .then(r => { | 43 .then(r => { |
| 44 registration = r; | 44 registration = r; |
| 45 return wait_for_state(test, registration.installing, 'installed'); | 45 return wait_for_state(test, registration.installing, 'installed'); |
| 46 }) | 46 }) |
| 47 .then(state => { | 47 .then(state => { |
| 48 assert_equals(state, 'installed'); | 48 assert_equals(state, 'installed'); |
| 49 return registration.paymentAppManager.setManifest({ | 49 return registration.paymentManager.setManifest({ |
| 50 name: 'Payment App', | 50 name: 'Payment App', |
| 51 icon: 'payment-app-icon', | 51 icon: 'payment-app-icon', |
| 52 options: [{ | 52 options: [{ |
| 53 name: 'Visa ****', | 53 name: 'Visa ****', |
| 54 icon: 'payment-app-icon', | 54 icon: 'payment-app-icon', |
| 55 id: 'payment-app-id', | 55 id: 'payment-app-id', |
| 56 enabledMethods: ['visa'] | 56 enabledMethods: ['visa'] |
| 57 }] | 57 }] |
| 58 }); | 58 }); |
| 59 }) | 59 }) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 .then(r => { | 73 .then(r => { |
| 74 registration = r; | 74 registration = r; |
| 75 registration.unregister(); | 75 registration.unregister(); |
| 76 return wait_for_state(test, registration.installing, 'redundant'); | 76 return wait_for_state(test, registration.installing, 'redundant'); |
| 77 }) | 77 }) |
| 78 .then(state => { | 78 .then(state => { |
| 79 assert_equals(state, 'redundant'); | 79 assert_equals(state, 'redundant'); |
| 80 assert_equals(registration.installing, null); | 80 assert_equals(registration.installing, null); |
| 81 assert_equals(registration.waiting, null); | 81 assert_equals(registration.waiting, null); |
| 82 assert_equals(registration.active, null); | 82 assert_equals(registration.active, null); |
| 83 return registration.paymentAppManager.setManifest({ | 83 return registration.paymentManager.setManifest({ |
| 84 name: 'Payment App', | 84 name: 'Payment App', |
| 85 icon: 'payment-app-icon', | 85 icon: 'payment-app-icon', |
| 86 options: [{ | 86 options: [{ |
| 87 name: 'Visa ****', | 87 name: 'Visa ****', |
| 88 icon: 'payment-app-icon', | 88 icon: 'payment-app-icon', |
| 89 id: 'payment-app-id', | 89 id: 'payment-app-id', |
| 90 enabledMethods: ['visa'] | 90 enabledMethods: ['visa'] |
| 91 }] | 91 }] |
| 92 }); | 92 }); |
| 93 }) | 93 }) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 113 }] | 113 }] |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 return service_worker_unregister_and_register(test, script_url, scope) | 116 return service_worker_unregister_and_register(test, script_url, scope) |
| 117 .then(r => { | 117 .then(r => { |
| 118 registration = r; | 118 registration = r; |
| 119 return wait_for_state(test, registration.installing, 'activated'); | 119 return wait_for_state(test, registration.installing, 'activated'); |
| 120 }) | 120 }) |
| 121 .then(state => { | 121 .then(state => { |
| 122 assert_equals(state, 'activated'); | 122 assert_equals(state, 'activated'); |
| 123 return registration.paymentAppManager.setManifest(manifest); | 123 return registration.paymentManager.setManifest(manifest); |
| 124 }) | 124 }) |
| 125 .then(result => { | 125 .then(result => { |
| 126 assert_equals(result, undefined); | 126 assert_equals(result, undefined); |
| 127 return registration.paymentAppManager.getManifest(); | 127 return registration.paymentManager.getManifest(); |
| 128 }) | 128 }) |
| 129 .then(read_manifest => { | 129 .then(read_manifest => { |
| 130 assert_object_equals(read_manifest, manifest); | 130 assert_object_equals(read_manifest, manifest); |
| 131 }) | 131 }) |
| 132 .catch(unreached_rejection(test)); | 132 .catch(unreached_rejection(test)); |
| 133 }, 'If getManifest() is succeeded, then resolves stored manifest data.'); | 133 }, 'If getManifest() is succeeded, then resolves stored manifest data.'); |
| 134 | 134 |
| 135 promise_test(test => { | 135 promise_test(test => { |
| 136 var registration; | 136 var registration; |
| 137 var script_url = 'resources/empty-worker.js'; | 137 var script_url = 'resources/empty-worker.js'; |
| 138 var scope = 'resources/'; | 138 var scope = 'resources/'; |
| 139 var manifest = { | 139 var manifest = { |
| 140 name: 'Payment App', | 140 name: 'Payment App', |
| 141 icon: 'payment-app-icon', | 141 icon: 'payment-app-icon', |
| 142 options: [{ | 142 options: [{ |
| 143 name: 'Visa ****', | 143 name: 'Visa ****', |
| 144 icon: 'payment-app-icon', | 144 icon: 'payment-app-icon', |
| 145 id: 'payment-app-id', | 145 id: 'payment-app-id', |
| 146 enabledMethods: ['visa2'] | 146 enabledMethods: ['visa2'] |
| 147 }] | 147 }] |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 return service_worker_unregister_and_register(test, script_url, scope) | 150 return service_worker_unregister_and_register(test, script_url, scope) |
| 151 .then(r => { | 151 .then(r => { |
| 152 registration = r; | 152 registration = r; |
| 153 return wait_for_state(test, registration.installing, 'activated'); | 153 return wait_for_state(test, registration.installing, 'activated'); |
| 154 }) | 154 }) |
| 155 .then(state => { | 155 .then(state => { |
| 156 assert_equals(state, 'activated'); | 156 assert_equals(state, 'activated'); |
| 157 return registration.paymentAppManager.setManifest(manifest); | 157 return registration.paymentManager.setManifest(manifest); |
| 158 }) | 158 }) |
| 159 .then(result => { | 159 .then(result => { |
| 160 assert_equals(result, undefined); | 160 assert_equals(result, undefined); |
| 161 return registration.unregister(); | 161 return registration.unregister(); |
| 162 }) | 162 }) |
| 163 .then(result => { | 163 .then(result => { |
| 164 assert_equals(result, true); | 164 assert_equals(result, true); |
| 165 return registration.paymentAppManager.getManifest(); | 165 return registration.paymentManager.getManifest(); |
| 166 }) | 166 }) |
| 167 .then(unreached_fulfillment(test)) | 167 .then(unreached_fulfillment(test)) |
| 168 .catch(error => { | 168 .catch(error => { |
| 169 assert_equals(error.name, 'AbortError'); | 169 assert_equals(error.name, 'AbortError'); |
| 170 }); | 170 }); |
| 171 }, 'If service worker is unregistered, then manifest is cleared as well.'); | 171 }, 'If service worker is unregistered, then manifest is cleared as well.'); |
| 172 | 172 |
| 173 promise_test(test => { | 173 promise_test(test => { |
| 174 var registration; | 174 var registration; |
| 175 var script_url = 'resources/empty-worker.js'; | 175 var script_url = 'resources/empty-worker.js'; |
| 176 var scope = 'resources/'; | 176 var scope = 'resources/'; |
| 177 | 177 |
| 178 return service_worker_unregister_and_register(test, script_url, scope) | 178 return service_worker_unregister_and_register(test, script_url, scope) |
| 179 .then(r => { | 179 .then(r => { |
| 180 registration = r; | 180 registration = r; |
| 181 return wait_for_state(test, registration.installing, 'activated'); | 181 return wait_for_state(test, registration.installing, 'activated'); |
| 182 }) | 182 }) |
| 183 .then(state => { | 183 .then(state => { |
| 184 assert_equals(state, 'activated'); | 184 assert_equals(state, 'activated'); |
| 185 return registration.paymentAppManager.getManifest(); | 185 return registration.paymentManager.getManifest(); |
| 186 }) | 186 }) |
| 187 .then(unreached_fulfillment(test)) | 187 .then(unreached_fulfillment(test)) |
| 188 .catch(error => { | 188 .catch(error => { |
| 189 assert_equals(error.name, 'AbortError'); | 189 assert_equals(error.name, 'AbortError'); |
| 190 }); | 190 }); |
| 191 }, 'If there is no manifest data, then throws AbortError.'); | 191 }, 'If there is no manifest data, then throws AbortError.'); |
| 192 | 192 |
| 193 promise_test(test => { | 193 promise_test(test => { |
| 194 var registration; | 194 var registration; |
| 195 var script_url = 'resources/empty-worker.js'; | 195 var script_url = 'resources/empty-worker.js'; |
| 196 var scope = 'resources/'; | 196 var scope = 'resources/'; |
| 197 | 197 |
| 198 return service_worker_unregister_and_register(test, script_url, scope) | 198 return service_worker_unregister_and_register(test, script_url, scope) |
| 199 .then(r => { | 199 .then(r => { |
| 200 registration = r; | 200 registration = r; |
| 201 return wait_for_state(test, registration.installing, 'activated'); | 201 return wait_for_state(test, registration.installing, 'activated'); |
| 202 }) | 202 }) |
| 203 .then(state => { | 203 .then(state => { |
| 204 assert_equals(state, 'activated'); | 204 assert_equals(state, 'activated'); |
| 205 return registration.paymentAppManager.setManifest({ | 205 return registration.paymentManager.setManifest({ |
| 206 name: 'Payment App', | 206 name: 'Payment App', |
| 207 icon: 'payment-app-icon', | 207 icon: 'payment-app-icon', |
| 208 options: [{ | 208 options: [{ |
| 209 name: 'Visa ****', | 209 name: 'Visa ****', |
| 210 icon: 'payment-app-icon', | 210 icon: 'payment-app-icon', |
| 211 id: 'payment-app-id' | 211 id: 'payment-app-id' |
| 212 }] | 212 }] |
| 213 }); | 213 }); |
| 214 }) | 214 }) |
| 215 .catch(unreached_rejection(test)); | 215 .catch(unreached_rejection(test)); |
| 216 }, 'enabled_methods of PaymentAppOption is not required member. ' | 216 }, 'enabled_methods of PaymentAppOption is not required member. ' |
| 217 + 'so this test should be pass.'); | 217 + 'so this test should be pass.'); |
| 218 | 218 |
| 219 </script> | 219 </script> |
| OLD | NEW |