summaryrefslogtreecommitdiffstats
path: root/netwerk/cookie/test/browser/browser_serviceWorker.js
blob: 2a5c9635355889d6f33bcfdfec633fa5056120b5 (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
41
42
43
44
45
"use strict";

CookiePolicyHelper.runTest("ServiceWorker", {
  prefs: [
    ["dom.serviceWorkers.exemptFromPerDomainMax", true],
    ["dom.ipc.processCount", 1],
    ["dom.serviceWorkers.enabled", true],
    ["dom.serviceWorkers.testing.enabled", true],
  ],

  cookieJarAccessAllowed: async w => {
    await w.navigator.serviceWorker
      .register("file_empty.js")
      .then(
        reg => {
          ok(true, "ServiceWorker can be used!");
          return reg;
        },
        _ => {
          ok(false, "ServiceWorker cannot be used! " + _);
        }
      )
      .then(
        reg => reg.unregister(),
        _ => {
          ok(false, "unregister failed");
        }
      )
      .catch(e => ok(false, "Promise rejected: " + e));
  },

  cookieJarAccessDenied: async w => {
    await w.navigator.serviceWorker
      .register("file_empty.js")
      .then(
        _ => {
          ok(false, "ServiceWorker cannot be used!");
        },
        _ => {
          ok(true, "ServiceWorker cannot be used!");
        }
      )
      .catch(e => ok(false, "Promise rejected: " + e));
  },
});