2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharness-helpers.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script>
7 function wait_for_install_event(worker) {
8 return new Promise(function(resolve) {
9 worker.addEventListener('statechange', function(event) {
10 if (worker.state == 'installed')
12 else if (worker.state == 'redundant')
18 function make_test(name, script, expect_install) {
19 promise_test(function(t) {
21 return service_worker_unregister_and_register(t, script, scope)
22 .then(function(registration) {
23 return wait_for_install_event(registration.installing);
25 .then(function(did_install) {
26 assert_equals(did_install, expect_install,
27 'The worker was installed');
34 name: 'install handler throws an error',
35 script: 'resources/oninstall-throw-error-worker.js',
39 name: 'install handler throws an error, error handler does not cancel',
40 script: 'resources/oninstall-throw-error-with-empty-onerror-worker.js',
44 name: 'install handler dispatches an event that throws an error',
45 script: 'resources/oninstall-throw-error-from-nested-event-worker.js',
49 name: 'install handler throws an error that is cancelled',
50 script: 'resources/oninstall-throw-error-then-cancel-worker.js',
54 name: 'install handler throws an error and prevents default',
55 script: 'resources/oninstall-throw-error-then-prevent-default-worker.js',
58 ].forEach(function(test_case) {
59 make_test(test_case.name, test_case.script, test_case.expect_install);