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/testharness-helpers.js"></script> |
4 <script src="resources/test-helpers.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
| 5 <script src="resources/test-helpers.sub.js"></script> |
5 <script> | 6 <script> |
6 function wait_for_install(worker) { | 7 function wait_for_install(worker) { |
7 return new Promise(function(resolve, reject) { | 8 return new Promise(function(resolve, reject) { |
8 worker.addEventListener('statechange', function(event) { | 9 worker.addEventListener('statechange', function(event) { |
9 if (worker.state == 'installed') | 10 if (worker.state == 'installed') |
10 resolve(); | 11 resolve(); |
11 else if (worker.state == 'redundant') | 12 else if (worker.state == 'redundant') |
12 reject(); | 13 reject(); |
13 }); | 14 }); |
14 }); | 15 }); |
(...skipping 14 matching lines...) Expand all Loading... |
29 promise_test(function(t) { | 30 promise_test(function(t) { |
30 var scope = script; | 31 var scope = script; |
31 var registration; | 32 var registration; |
32 return service_worker_unregister_and_register(t, script, scope) | 33 return service_worker_unregister_and_register(t, script, scope) |
33 .then(function(r) { | 34 .then(function(r) { |
34 registration = r; | 35 registration = r; |
35 return wait_for_install(registration.installing); | 36 return wait_for_install(registration.installing); |
36 }) | 37 }) |
37 .then(function() { | 38 .then(function() { |
38 // Activate should succeed regardless of script errors. | 39 // Activate should succeed regardless of script errors. |
| 40 if (registration.active && registration.active.state == 'activated')
{ |
| 41 return Promise.resolve(); |
| 42 } else if (registration.active) { |
| 43 return wait_for_activate(registration.active); |
| 44 } |
| 45 |
39 return wait_for_activate(registration.waiting); | 46 return wait_for_activate(registration.waiting); |
40 }); | 47 }); |
41 }, name); | 48 }, name); |
42 } | 49 } |
43 | 50 |
44 [ | 51 [ |
45 { | 52 { |
46 name: 'activate handler throws an error', | 53 name: 'activate handler throws an error', |
47 script: 'resources/onactivate-throw-error-worker.js', | 54 script: 'resources/onactivate-throw-error-worker.js', |
48 }, | 55 }, |
(...skipping 10 matching lines...) Expand all Loading... |
59 script: 'resources/onactivate-throw-error-then-cancel-worker.js', | 66 script: 'resources/onactivate-throw-error-then-cancel-worker.js', |
60 }, | 67 }, |
61 { | 68 { |
62 name: 'activate handler throws an error and prevents default', | 69 name: 'activate handler throws an error and prevents default', |
63 script: 'resources/onactivate-throw-error-then-prevent-default-worker.js', | 70 script: 'resources/onactivate-throw-error-then-prevent-default-worker.js', |
64 } | 71 } |
65 ].forEach(function(test_case) { | 72 ].forEach(function(test_case) { |
66 make_test(test_case.name, test_case.script); | 73 make_test(test_case.name, test_case.script); |
67 }); | 74 }); |
68 </script> | 75 </script> |
OLD | NEW |