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/testharness-helpers.js"></script> | 3 <script src="resources/testharness-helpers.js"></script> |
4 <script src="/resources/testharnessreport.js"></script> | 4 <script src="/resources/testharnessreport.js"></script> |
5 <script src="resources/test-helpers.sub.js"></script> | 5 <script src="resources/test-helpers.sub.js"></script> |
6 <script> | 6 <script> |
7 function wait_for_install(worker) { | 7 function wait_for_install(worker) { |
8 return new Promise(function(resolve, reject) { | 8 return new Promise(function(resolve, reject) { |
9 worker.addEventListener('statechange', function(event) { | 9 worker.addEventListener('statechange', function(event) { |
10 if (worker.state == 'installed') | 10 if (worker.state == 'installed') |
(...skipping 19 matching lines...) Expand all Loading... | |
30 promise_test(function(t) { | 30 promise_test(function(t) { |
31 var scope = script; | 31 var scope = script; |
32 var registration; | 32 var registration; |
33 return service_worker_unregister_and_register(t, script, scope) | 33 return service_worker_unregister_and_register(t, script, scope) |
34 .then(function(r) { | 34 .then(function(r) { |
35 registration = r; | 35 registration = r; |
36 return wait_for_install(registration.installing); | 36 return wait_for_install(registration.installing); |
37 }) | 37 }) |
38 .then(function() { | 38 .then(function() { |
39 // 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 | |
46 return wait_for_activate(registration.waiting); | 40 return wait_for_activate(registration.waiting); |
47 }); | 41 }); |
falken
2017/05/19 02:19:04
I think we need to unregister the worker.
mike3
2017/05/19 15:54:51
Done.
| |
48 }, name); | 42 }, name); |
49 } | 43 } |
50 | 44 |
51 [ | 45 [ |
52 { | 46 { |
53 name: 'activate handler throws an error', | 47 name: 'activate handler throws an error', |
54 script: 'resources/onactivate-throw-error-worker.js', | 48 script: 'resources/onactivate-throw-error-worker.js', |
55 }, | 49 }, |
56 { | 50 { |
57 name: 'activate handler throws an error, error handler does not cancel', | 51 name: 'activate handler throws an error, error handler does not cancel', |
58 script: 'resources/onactivate-throw-error-with-empty-onerror-worker.js', | 52 script: 'resources/onactivate-throw-error-with-empty-onerror-worker.js', |
59 }, | 53 }, |
60 { | 54 { |
61 name: 'activate handler dispatches an event that throws an error', | 55 name: 'activate handler dispatches an event that throws an error', |
62 script: 'resources/onactivate-throw-error-from-nested-event-worker.js', | 56 script: 'resources/onactivate-throw-error-from-nested-event-worker.js', |
63 }, | 57 }, |
64 { | 58 { |
65 name: 'activate handler throws an error that is cancelled', | 59 name: 'activate handler throws an error that is cancelled', |
66 script: 'resources/onactivate-throw-error-then-cancel-worker.js', | 60 script: 'resources/onactivate-throw-error-then-cancel-worker.js', |
67 }, | 61 }, |
68 { | 62 { |
69 name: 'activate handler throws an error and prevents default', | 63 name: 'activate handler throws an error and prevents default', |
70 script: 'resources/onactivate-throw-error-then-prevent-default-worker.js', | 64 script: 'resources/onactivate-throw-error-then-prevent-default-worker.js', |
71 } | 65 } |
72 ].forEach(function(test_case) { | 66 ].forEach(function(test_case) { |
73 make_test(test_case.name, test_case.script); | 67 make_test(test_case.name, test_case.script); |
74 }); | 68 }); |
75 </script> | 69 </script> |
OLD | NEW |