2 <title>Service Worker: Registration</title>
3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script>
7 var t = async_test('Registering normal pattern');
9 navigator.serviceWorker.register(
10 'resources/registration-worker.js',
11 {scope: '/registration/*'}
13 t.step_func(function(worker) {
14 assert_true(worker instanceof ServiceWorker,
15 'Successfully registered.');
18 t.step_func(function(reason) {
19 assert_unreached('Registration should succeed, but failed: ' + reason.name);
26 var t = async_test('Registering scope outside domain');
28 navigator.serviceWorker.register(
29 'resources/registration-worker.js',
30 {scope: 'http://example.com/*'}
32 t.step_func(function(worker) {
33 assert_unreached('Registration scope outside domain should fail.');
35 t.step_func(function(reason) {
36 assert_equals(reason.name, 'SecurityError',
37 'Registration scope outside domain should fail with SecurityError.');
45 var t = async_test('Registering script outside domain');
47 navigator.serviceWorker.register(
48 'http://example.com/worker.js'
50 t.step_func(function(worker) {
51 assert_unreached('Registration script outside domain should fail.');
53 t.step_func(function(reason) {
54 assert_equals(reason.name, 'SecurityError',
55 'Registration script outside domain should fail with SecurityError.');
63 var t = async_test('Registering non-existent script');
65 navigator.serviceWorker.register(
66 'resources/no-such-worker.js'
68 t.step_func(function(worker) {
69 assert_unreached('Registration of non-existent script should fail.');
71 t.step_func(function(reason) {
72 assert_equals(reason.name, 'AbortError',
73 'Registration of non-existent script should fail.');