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.paymentAppManager.setManifest({ |
20 label: 'Payment App' | 20 label: 'Payment App' |
21 }); | 21 }); |
22 }) | 22 }) |
23 .then(result => { | 23 .then(result => { |
24 unreached_fulfillment(test); | 24 assert_equals(result, undefined); |
25 }) | 25 }) |
| 26 .catch(unreached_rejection(test)); |
| 27 }, 'setManifest() should resolve with undefined if ' |
| 28 + 'setManifest() is succeeded.'); |
| 29 |
| 30 promise_test(test => { |
| 31 var registration; |
| 32 var script_url = 'resources/empty-worker.js'; |
| 33 var scope = 'resources/'; |
| 34 |
| 35 return service_worker_unregister_and_register(test, script_url, scope) |
| 36 .then(r => { |
| 37 registration = r; |
| 38 return wait_for_state(test, registration.installing, 'installed'); |
| 39 }) |
| 40 .then(state => { |
| 41 assert_equals(state, 'installed'); |
| 42 return registration.paymentAppManager.setManifest({ |
| 43 label: 'Payment App' |
| 44 }); |
| 45 }) |
| 46 .then(result => { |
| 47 assert_equals(result, undefined); |
| 48 }) |
| 49 .catch(unreached_rejection(test)); |
| 50 }, 'If registration has waiting worker, then wait for active worker and ' |
| 51 + 'then setManifest() is succeeded.'); |
| 52 |
| 53 promise_test(test => { |
| 54 var registration; |
| 55 var script_url = 'resources/empty-worker.js'; |
| 56 var scope = 'resources/'; |
| 57 |
| 58 return service_worker_unregister_and_register(test, script_url, scope) |
| 59 .then(r => { |
| 60 registration = r; |
| 61 registration.unregister(); |
| 62 return wait_for_state(test, registration.installing, 'redundant'); |
| 63 }) |
| 64 .then(state => { |
| 65 assert_equals(state, 'redundant'); |
| 66 assert_equals(registration.installing, null); |
| 67 assert_equals(registration.waiting, null); |
| 68 assert_equals(registration.active, null); |
| 69 return registration.paymentAppManager.setManifest({ |
| 70 label: 'Payment App' |
| 71 }); |
| 72 }) |
| 73 .then(unreached_fulfillment(test)) |
26 .catch(error => { | 74 .catch(error => { |
27 assert_equals(error.name, 'NotSupportedError'); | 75 assert_equals(error.name, 'InvalidStateError'); |
28 }); | 76 }); |
29 }, 'setManifest() should reject NotSupportedError for now'); | 77 }, 'If registration has no active worker, no waiting worker and ' |
| 78 + 'no installing worker, then throws InvalidStateError.'); |
30 | 79 |
31 </script> | 80 </script> |
OLD | NEW |