summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/unregister.https.html
blob: 492aecb21a875814e3a8fb89e64069989b9e31f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<script>
async_test(function(t) {
    var scope = 'resources/scope/unregister-twice';
    var registration;
    navigator.serviceWorker.register('resources/empty-worker.js',
                                     {scope: scope})
      .then(function(r) {
          registration = r;
          return registration.unregister();
        })
      .then(function() {
          return registration.unregister();
        })
      .then(function(value) {
          assert_equals(value, false,
                        'unregistering twice should resolve with false');
          t.done();
        })
      .catch(unreached_rejection(t));
  }, 'Unregister twice');

async_test(function(t) {
    var scope = 'resources/scope/successful-unregister/';
    navigator.serviceWorker.register('resources/empty-worker.js',
                                     {scope: scope})
      .then(function(registration) {
          return registration.unregister();
        })
      .then(function(value) {
          assert_equals(value, true,
                        'unregistration should resolve with true');
          t.done();
        })
      .catch(unreached_rejection(t));
  }, 'Register then unregister');
</script>