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